diff --git a/.aht.py b/.aht.py new file mode 100755 index 0000000..e21e290 --- /dev/null +++ b/.aht.py @@ -0,0 +1,39 @@ +#!/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 +import subprocess + +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__': + 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) 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" "$@" diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..c075ffd --- /dev/null +++ b/Dockerfile @@ -0,0 +1,16 @@ +FROM registry.fedoraproject.org/fedora:25 +RUN dnf -y install \ + git \ + python-pip \ + libselinux-python \ + python-devel \ + libffi-devel \ + redhat-rpm-config \ + 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 +COPY .aht.py /aht.py +ENTRYPOINT ["/aht.py"] 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"