Last active
April 20, 2023 15:44
-
-
Save shantanoo-desai/52a533c17a1e2613c27cdd7d5c12dcbe to your computer and use it in GitHub Desktop.
Revisions
-
shantanoo-desai revised this gist
Apr 20, 2023 . 1 changed file with 0 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,24 +0,0 @@ -
shantanoo-desai revised this gist
Apr 20, 2023 . 1 changed file with 2 additions and 21 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -7,35 +7,16 @@ paths: "{{ playbook_dir }}/../Tests" recurse: false excludes: '000_Template' patterns: "{{ omit if custom is not defined else (custom | map('regex_replace', '^(.*)$', '\\1_*')) }}" file_type: directory register: testcases - debug: var=testcases - set_fact: tests: "{{ tests|default([]) + [ { 'number': item | basename | split('_') | first, 'name': item | basename } ] }}" loop: "{{ testcases.files | map(attribute='path') | list }}" - name: generate Gitlab-CI File template: -
shantanoo-desai revised this gist
Apr 20, 2023 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,6 +23,7 @@ file_type: directory loop: "{{ custom }}" register: testcases when: "custom | length > 0" - debug: var=testcases -
shantanoo-desai created this gist
Apr 20, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ include: '.gitlab-ci-config.yml' stages: - single_test {% for testcase in tests %} test_{{ testcase.number }}: extends: - .test script: - ci/prepare_tests.sh -s {{ testcase.number }} - ci/run_test.sh - ci/qemu/stop_qemu.sh {% endfor %} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ ``` ansible-playbook ansible/gitlab-single-test.yml -e '{"custom":[]}' ``` ```bash PLAY [localhost] ********************************************************************************************************************************************************************* TASK [Obtaining Test Cases Information from the "Tests" Directory] ******************************************************************************************************************* ok: [localhost] TASK [Obtaining Specified Test Cases Information from the "Tests" Directory] ********************************************************************************************************* TASK [set_fact] ********************************************************************************************************************************************************************** fatal: [localhost]: FAILED! => {"msg": "'dict object' has no attribute 'files'"} PLAY RECAP *************************************************************************************************************************************************************************** localhost : ok=1 changed=0 unreachable=0 failed=1 skipped=1 rescued=0 ignored=0 ``` BUT this works! ``` ansible-playbook ansible/gitlab-single-test.yml -e '{"custom":["001","002","004"]}' ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ --- - hosts: localhost gather_facts: false tasks: - name: Obtaining Test Cases Information from the "Tests" Directory ansible.builtin.find: paths: "{{ playbook_dir }}/../Tests" recurse: false excludes: '000_Template' file_type: directory register: testcases when: "custom | length == 0" - debug: var=testcases - name: Obtaining Specified Test Cases Information from the "Tests" Directory ansible.builtin.find: paths: "{{ playbook_dir }}/../Tests" recurse: false excludes: '000_Template' patterns: - "{{ item }}_*" file_type: directory loop: "{{ custom }}" register: testcases - debug: var=testcases - set_fact: tests: "{{ tests|default([]) + [ { 'number': item | basename | split('_') | first, 'name': item | basename } ] }}" loop: "{{ testcases.files | map(attribute='path') | list }}" when: "custom | length == 0" - set_fact: tests: "{{ tests|default([]) + [ { 'number': item[0].path | basename | split('_') | first, 'name': item[0].path | basename } ] }}" loop: "{{ testcases.results | map(attribute='files') }}" when: "custom | length > 0" - name: generate Gitlab-CI File template: src: "{{ playbook_dir }}/templates/.gitlab-ci-single_test.yml.j2" dest: "./.gitlab-ci-single_test.yml" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ Tests/ ├── 000_Template ├── 001_startup_completion ├── 002_NR_Influx_Std ├── 003_PY_Influx_Std ├── 004_PY_MYSQL_Std ├── 005_PY_Influx_MQTT ├── 007_Chronograf ├── 008_Grafana ├── 010_MQTT_Basic_Test ├── 011_MySQL_Basic_Test ├── 012_MySQL_User_Privileges ├── 013_influxdb_user_privileges_test ├── 014_Grafana_Datasources ├── 900_changePW_frontend_playwright