Skip to content

Commit dcdcdc0

Browse files
committed
ci: Add test plan that runs CI tests and customize it for each role
* Calculate number of managed nodes with this formula: (( number_of_test_playbooks / 10 + 1 )) * Add README explaining how to run the plan locally and remotely Signed-off-by: Sergei Petrosian <[email protected]>
1 parent 62d3bdc commit dcdcdc0

File tree

3 files changed

+70
-15
lines changed

3 files changed

+70
-15
lines changed

.codespellrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ check-hidden = true
55
ignore-multiline-regex = codespell:ignore-begin.*codespell:ignore-end
66
ignore-words = .codespell_ignores
77
# skip-file is not available https://github.com/codespell-project/codespell/pull/2759
8+
# .pandoc_template.html5 contains a typo in Licence that we shouldn't edit
9+
# .README.html is generated from README.md automatically - no need to check spelling
810
skip = .pandoc_template.html5,.README.html,./tests/files/client.key.nocrypt,./tests/files/client.pem

plans/README-plans.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Introduction CI Testing Plans
2+
3+
Linux System Roles CI runs [tmt](https://tmt.readthedocs.io/en/stable/index.html) test plans in [Testing farm](https://docs.testing-farm.io/Testing%20Farm/0.1/index.html) with the [tft.yml](https://github.com/linux-system-roles/network/blob/main/.github/workflows/tft.yml) GitHub workflow.
4+
5+
The `plans/test_playbooks_parallel.fmf` plan is a test plan that runs test playbooks in parallel on multiple managed nodes.
6+
`plans/test_playbooks_parallel.fmf` is generated centrally from `https://github.com/linux-system-roles/.github/`.
7+
The automation calculates the number of managed nodes to provision with this formula:
8+
9+
```plain
10+
number-of-test-playbooks / 10 + 1
11+
```
12+
13+
The `plans/test_playbooks_parallel.fmf` plan does the following steps:
14+
15+
1. Provisions systems to be used as a control node and as managed nodes.
16+
2. Does the required preparation on systems.
17+
3. For the given role and the given PR, runs the general test from [test.sh](https://github.com/linux-system-roles/tft-tests/blob/main/tests/general/test.sh).
18+
19+
The [tft.yml](https://github.com/linux-system-roles/network/blob/main/.github/workflows/tft.yml) workflow runs the above plan and uploads the results to our Fedora storage for public access.
20+
This workflow uses Testing Farm's Github Action [Schedule tests on Testing Farm](https://github.com/marketplace/actions/schedule-tests-on-testing-farm).
21+
22+
## Running Tests
23+
24+
You can run tests locally with the `tmt try` cli or remotely in Testing Far.
25+
26+
### Running Tests Locally
27+
28+
1. Install `tmt` as described in [Installation](https://tmt.readthedocs.io/en/stable/stories/install.html).
29+
2. Change to the role repository directory.
30+
3. Modify `plans/test_playbooks_parallel.fmf` to suit your requirements:
31+
1. Due to [issue #3138](https://github.com/teemtee/tmt/issues/3138), comment out all managed nodes except for one.
32+
2. Optionally modify environment variables to, e.g. run only specified test playbooks by modifying `SYSTEM_ROLES_ONLY_TESTS`.
33+
4. Enter `tmt try -p plans/test_playbooks_parallel <platform>`.
34+
This command identifies the `plans/test_playbooks_parallel.fmf` plan and provisions local VMs, a control node and a managed node.
35+
5. tmt try is in development and does not identify tests from URL automatically, so after provisioning the machines, you must type `t`, `p`, `t` from the interactive prompt to identify tests, run preparation steps, and run the tests.
36+
37+
### Running in Testing Farm
38+
39+
1. Install `testing-farm` as described in [Installation](https://gitlab.com/testing-farm/cli/-/blob/main/README.adoc#user-content-installation).
40+
2. Change to the role repository directory.
41+
3. If you want to run tests with edits in your branch, you need to commit and push changes first to some branch.
42+
4. You can uncomment "Inject your ssh public key to test systems" discover step in the plan if you want to troubleshoot tests by SSHing into test systems in Testing Farm.
43+
5. Enter `testing-farm request`.
44+
Edit to your needs.
45+
46+
```bash
47+
$ TESTING_FARM_API_TOKEN=<your_api_token> \
48+
testing-farm request --pipeline-type="tmt-multihost" \
49+
--plan-filter="tag:playbooks_parallel" \
50+
--git-url "https://github.com/<my_user>/network" \
51+
--git-ref "<my_branch>" \
52+
--compose CentOS-Stream-9 \
53+
-e "SYSTEM_ROLES_ONLY_TESTS=tests_default.yml" \
54+
--no-wait
55+
```

plans/test_playbooks_parallel.fmf

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,50 +12,50 @@ provision:
1212
- name: managed-node1
1313
role: managed_node
1414
connection: system
15-
hardware:
16-
network:
15+
hardware: network:
1716
- type: eth
1817
- type: eth
1918
- name: managed-node2
2019
role: managed_node
2120
connection: system
22-
hardware:
23-
network:
21+
hardware: network:
2422
- type: eth
2523
- type: eth
2624
- name: managed-node3
2725
role: managed_node
2826
connection: system
29-
hardware:
30-
network:
27+
hardware: network:
3128
- type: eth
3229
- type: eth
3330
- name: managed-node4
3431
role: managed_node
3532
connection: system
36-
hardware:
37-
network:
33+
hardware: network:
3834
- type: eth
3935
- type: eth
4036
- name: managed-node5
4137
role: managed_node
4238
connection: system
43-
hardware:
44-
network:
39+
hardware: network:
4540
- type: eth
4641
- type: eth
4742
- name: managed-node6
4843
role: managed_node
4944
connection: system
50-
hardware:
51-
network:
45+
hardware: network:
46+
- type: eth
47+
- type: eth
48+
- name: managed-node7
49+
role: managed_node
50+
connection: system
51+
hardware: network:
5252
- type: eth
5353
- type: eth
5454
environment:
5555
ANSIBLE_VER: 2.17
5656
REPO_NAME: network
5757
PYTHON_VERSION: 3.12
58-
SYSTEM_ROLES_ONLY_TESTS: ""
58+
SYSTEM_ROLES_ONLY_TESTS: "" # tests_default.yml
5959
TEST_LOCAL_CHANGES: true
6060
PR_NUM: ""
6161
LINUXSYSTEMROLES_USER: ""
@@ -82,8 +82,6 @@ prepare:
8282
fi
8383
yum install epel-release yum-utils -y
8484
yum-config-manager --enable epel epel-debuginfo epel-source
85-
- name: Test NICs
86-
script: lshw -C network
8785
discover:
8886
- name: Prepare managed node
8987
how: fmf

0 commit comments

Comments
 (0)