From ce8b31deb2249adb4874f0eaafa94fbbc2393446 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Duchaussois?= Date: Fri, 5 Nov 2021 11:08:53 +0100 Subject: setup basic tests --- .github/workflows/pr.yml | 35 +++++++++++++++++++++++++++++++++++ tests/inventory | 3 +-- tests/requirements.txt | 2 ++ tests/rundeck_files/test.yaml | 13 +++++++++++++ tests/test.yml | 10 +++++----- tests/tokens.properties | 1 + 6 files changed, 57 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/pr.yml create mode 100644 tests/requirements.txt create mode 100644 tests/rundeck_files/test.yaml create mode 100644 tests/tokens.properties diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml new file mode 100644 index 0000000..fed51c4 --- /dev/null +++ b/.github/workflows/pr.yml @@ -0,0 +1,35 @@ +name: Test PR +on: + push: + branches: + - master + pull_request: + branches: + - master +jobs: + tests: + runs-on: ubuntu-latest + services: + rundeck: + image: rundeck/rundeck:3.4.3 + ports: + - 4440:4440 + env: + RUNDECK_TOKENS_FILE: /tokens.properties + volumes: + - ${{ github.workspace }}/test/tokens.properties:/tokens.properties + options: >- + --health-interval=10s + --health-cmd="wget -t 1 -q -O /dev/null http://localhost:4440" + --health-timeout 5s + --health-retries 15 + + steps: + - uses: actions/checkout@v2 + - run: | + apt update && apt install -y python3-pip wait-for-it + pip3 install -r requirements.txt + pip3 install -r tests/requirements.txt + - run: http localhost:4440/api/26/projects name=test X-Rundeck-Auth-Token:testtoken Accept:application/json + - run: | + cd tests && ansible-playbook -i inventory test.yml diff --git a/tests/inventory b/tests/inventory index 878877b..2302eda 100644 --- a/tests/inventory +++ b/tests/inventory @@ -1,2 +1 @@ -localhost - +localhost ansible_connection=local diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 0000000..3f27cc4 --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,2 @@ +httpie +ansible diff --git a/tests/rundeck_files/test.yaml b/tests/rundeck_files/test.yaml new file mode 100644 index 0000000..19fe18d --- /dev/null +++ b/tests/rundeck_files/test.yaml @@ -0,0 +1,13 @@ +- defaultTab: summary + description: Test job + executionEnabled: true + loglevel: INFO + name: Test job 2 + nodeFilterEditable: false + scheduleEnabled: true + sequence: + commands: + - exec: "false" + keepgoing: false + strategy: node-first + diff --git a/tests/test.yml b/tests/test.yml index 25ef811..5d85628 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -1,8 +1,8 @@ --- - hosts: localhost roles: - - role: ansible-rundeck-jobs - rundeck_api_url: https://rundeck.example.org - rundeck_project: Test - rundeck_api_token: token - rundeck_jobs_path: tests/rundeck_files + - role: ../../ansible-rundeck-jobs + rundeck_api_url: http://localhost:4440/api + rundeck_project: test + rundeck_api_token: testtoken + rundeck_jobs_path: rundeck_files diff --git a/tests/tokens.properties b/tests/tokens.properties new file mode 100644 index 0000000..3f44bf8 --- /dev/null +++ b/tests/tokens.properties @@ -0,0 +1 @@ +admin: testtoken, admin -- cgit v1.2.3