From 5e44747ef5628ced3e8446a8161bed4e86bf9759 Mon Sep 17 00:00:00 2001 From: samvarankashyap Date: Fri, 2 Jun 2017 16:34:50 -0400 Subject: [PATCH 1/7] Added Dockerfile inoder have containerized runs of tests --- Dockerfile | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 Dockerfile diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..5ea3832 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,13 @@ +FROM fedora +RUN dnf update -y +RUN dnf install -y git python-pip +RUN dnf install -y libselinux-python +RUN dnf groupinstall -y "Development Tools" +RUN dnf install -y python-devel +RUN dnf install -y libffi-devel +RUN dnf install -y redhat-rpm-config +RUN dnf install -y openssl-devel +RUN pip install ansible +RUN git clone https://github.com/projectatomic/atomic-host-tests +WORKDIR "/atomic-host-tests" +RUN echo "$PWD" From b2b7028d17d6a07c2ec3410edc684ec571ef0869 Mon Sep 17 00:00:00 2001 From: Samvaran Kashyap Date: Wed, 7 Jun 2017 13:42:23 +0000 Subject: [PATCH 2/7] Restructured Dockerfile and added shellscript entrypoint --- Dockerfile | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5ea3832..e8b3bd9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,13 +1,15 @@ -FROM fedora -RUN dnf update -y -RUN dnf install -y git python-pip -RUN dnf install -y libselinux-python -RUN dnf groupinstall -y "Development Tools" -RUN dnf install -y python-devel -RUN dnf install -y libffi-devel -RUN dnf install -y redhat-rpm-config -RUN dnf install -y openssl-devel -RUN pip install ansible +FROM registry.fedoraproject.org/fedora:25 +RUN dnf -y install \ + git \ + python-pip \ + libselinux-python \ + python-devel \ + libffi-devel \ + redhat-rpm-config \ + openssl-devel && \ + dnf -y groupinstall "Development Tools" RUN git clone https://github.com/projectatomic/atomic-host-tests WORKDIR "/atomic-host-tests" -RUN echo "$PWD" +RUN pip install -r requirements.txt +COPY .aht.sh /aht.sh +ENTRYPOINT ["/aht.sh"] From 0dc3d84060d95d374551d6447141e491b7d85b88 Mon Sep 17 00:00:00 2001 From: Samvaran Kashyap Date: Wed, 7 Jun 2017 13:43:16 +0000 Subject: [PATCH 3/7] Added entrypoint shellscript for simplified run of ansible playbooks --- .aht.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100755 .aht.sh diff --git a/.aht.sh b/.aht.sh new file mode 100755 index 0000000..fd05a13 --- /dev/null +++ b/.aht.sh @@ -0,0 +1,10 @@ +#!/bin/bash +if [ -z "$TEST_PATH" ]; then + echo "No test provided; please supply a value for TEST_PATH" + exit 1 +fi +if [ ! -f "/atomic-host-tests/$TEST_PATH" ]; then + echo "The value for TEST_PATH does not exist" + exit 1 +fi +env ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook "/atomic-host-tests/$TEST_PATH" "$@" From 40ec4aee2239f3c4c0caa92bd3715124c7f2fe0c Mon Sep 17 00:00:00 2001 From: samvarankashyap Date: Mon, 17 Jul 2017 10:49:08 -0400 Subject: [PATCH 4/7] Reduced the dependencies inturn reducing the image size --- Dockerfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e8b3bd9..b1aeb45 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,8 +6,9 @@ RUN dnf -y install \ python-devel \ libffi-devel \ redhat-rpm-config \ - openssl-devel && \ - dnf -y groupinstall "Development Tools" + openssl-devel \ + gcc \ + rpm-build RUN git clone https://github.com/projectatomic/atomic-host-tests WORKDIR "/atomic-host-tests" RUN pip install -r requirements.txt From 84063e1b3c196e579a84ce620fee736043e72a38 Mon Sep 17 00:00:00 2001 From: samvarankashyap Date: Mon, 17 Jul 2017 13:15:09 -0400 Subject: [PATCH 5/7] Added test playbooks for testing : will be removed --- tests/test/test.yml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 tests/test/test.yml diff --git a/tests/test/test.yml b/tests/test/test.yml new file mode 100644 index 0000000..6834e60 --- /dev/null +++ b/tests/test/test.yml @@ -0,0 +1,6 @@ +--- +- hosts: localhost + connection: local + tasks: + - debug: + msg: "Hi there" From 63d601f4868750c9b031988320afd472662f3b4b Mon Sep 17 00:00:00 2001 From: samvarankashyap Date: Mon, 17 Jul 2017 13:16:26 -0400 Subject: [PATCH 6/7] Added python helper script and updated dockerfile --- .aht.py | 35 +++++++++++++++++++++++++++++++++++ Dockerfile | 4 ++-- 2 files changed, 37 insertions(+), 2 deletions(-) create mode 100755 .aht.py diff --git a/.aht.py b/.aht.py new file mode 100755 index 0000000..e316643 --- /dev/null +++ b/.aht.py @@ -0,0 +1,35 @@ +#!/bin/python +#if [ -z "$TEST_PATH" ]; then +# echo "No test provided; please supply a value for TEST_PATH" +# exit 1 +#fi +#if [ ! -f "/atomic-host-tests/$TEST_PATH" ]; then +# echo "The value for TEST_PATH does not exist" +# exit 1 +#fi +#env ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook "/atomic-host-tests/$TEST_PATH" "$@" + +import os +import sys +import argparse + +def parse_args(args=None): + parser = argparse.ArgumentParser(description='Atomic hosts tests helper script') + parser.add_argument('-tp', '--testpath', + help='Test path relative to \ + /atomic-host-test folder \ + inside the container', + required='True') + results = parser.parse_args(args[0:2]) + actual_path = "/atomic-host-tests/tests/{0}".format(results.testpath) + if not os.path.exists(actual_path): + print("TESTPATH does not exist Please mention the tests from following") + print(os.listdir("/atomic-host-tests/tests/")) + else: + print("env ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook {0} {1}".format(actual_path, " ".join(args[2:]))) + os.system("env ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook {0} {1}".format(actual_path, " ".join(args[2:]))) + return(actual_path) + +if __name__ == '__main__': + testpath = parse_args(sys.argv[1:]) + print(testpath) diff --git a/Dockerfile b/Dockerfile index b1aeb45..c075ffd 100644 --- a/Dockerfile +++ b/Dockerfile @@ -12,5 +12,5 @@ RUN dnf -y install \ RUN git clone https://github.com/projectatomic/atomic-host-tests WORKDIR "/atomic-host-tests" RUN pip install -r requirements.txt -COPY .aht.sh /aht.sh -ENTRYPOINT ["/aht.sh"] +COPY .aht.py /aht.py +ENTRYPOINT ["/aht.py"] From 02af2fc18652266c5f11066332d869fc52f81911 Mon Sep 17 00:00:00 2001 From: samvarankashyap Date: Mon, 17 Jul 2017 13:29:50 -0400 Subject: [PATCH 7/7] Updated .aht.py to fetch the latest code from atomic-host-test repo for everyrun --- .aht.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.aht.py b/.aht.py index e316643..e21e290 100755 --- a/.aht.py +++ b/.aht.py @@ -12,6 +12,7 @@ import os import sys import argparse +import subprocess def parse_args(args=None): parser = argparse.ArgumentParser(description='Atomic hosts tests helper script') @@ -31,5 +32,8 @@ def parse_args(args=None): return(actual_path) if __name__ == '__main__': + path = os.path.dirname("/atomic-host-tests/") + p = subprocess.Popen(["/usr/bin/git", "pull", "origin", "master"], cwd=path) + p.wait() testpath = parse_args(sys.argv[1:]) print(testpath)