Skip to content

Commit 775a85e

Browse files
committed
ci: Update fmf plan to add a separate job to prepare managed nodes
* Add a preparation job to run on managed nodes * Update instructions to run tests locally * From tft workflow, remove condition for commenter author_association. This would require us to add all trusted users, running workflow is not dangerous. * Keep the plan minimal, only run prep steps required to install beakerlib Signed-off-by: Sergei Petrosian <[email protected]>
1 parent 3d2e312 commit 775a85e

File tree

3 files changed

+18
-42
lines changed

3 files changed

+18
-42
lines changed

.github/workflows/tft.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ jobs:
2020
if: |
2121
github.event.issue.pull_request
2222
&& (contains(github.event.comment.body, '[citest]') || contains(github.event.comment.body, '[citest-all]'))
23-
&& (contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR", "CONTRIBUTOR"]'), github.event.comment.author_association)
24-
|| contains('systemroller', github.event.comment.user.login))
2523
runs-on: ubuntu-latest
2624
outputs:
2725
supported_platforms: ${{ steps.supported_platforms.outputs.supported_platforms }}
@@ -151,7 +149,8 @@ jobs:
151149
GITHUB_ORG=linux-system-roles;\
152150
PR_NUM=${{ github.event.issue.number }};\
153151
ARTIFACTS_DIR=${{ env.ARTIFACTS_DIR }};\
154-
ARTIFACTS_URL=${{ env.ARTIFACTS_URL }}"
152+
ARTIFACTS_URL=${{ env.ARTIFACTS_URL }};\
153+
TEST_LOCAL_CHANGES=false"
155154
# Note that LINUXSYSTEMROLES_SSH_KEY must be single-line, TF doesn't read multi-line variables fine.
156155
secrets: "LINUXSYSTEMROLES_USER=${{ secrets.LINUXSYSTEMROLES_USER }};\
157156
LINUXSYSTEMROLES_DOMAIN=${{ secrets.LINUXSYSTEMROLES_DOMAIN }};\

plans/README-plans.md

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,10 @@ You can run tests locally with the `tmt try` cli.
2121

2222
### Running Tests Locally
2323

24-
For now, this functionality requires you to push changes to a PR because the plan only runs from the main branch, or from the PR branch.
25-
So this is WIP.
24+
To run tests locally, in the role repository, enter `tmt try -p plans/general <platform>`.
2625

27-
To run tests locally, in the role repository, enter `tmt run plans --name plans/general <platform>`.
28-
Where `<platform>` is the name of the platform you want to run tests against.
26+
This command identifies the plans/general plan and provisions two local VMs, one used as an Ansible control node, and second used as a managed node.
2927

30-
For example, `tmt run plans --name plans/general Fedora-40`.
28+
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.
3129

32-
This command identifies the plans/general plan and provisions two machines, one used as an Ansible control node, and second used as a managed node.
33-
34-
You can also use `tmt try` to get to an interreactive prompt and be able to ssh into test machines.
35-
You must run `tmt try -p plans/general Fedora-40`, and the in the promt type `p` to prepare the machines, then `t` to run the tests.
30+
You can modify environment variables in `plans/general.fmf` to, e.g. run only specified test playbooks by overwriting `SYSTEM_ROLES_ONLY_TESTS`.

plans/general.fmf

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ summary: A general test for a system role
22
provision:
33
- name: control_node
44
role: control_node
5-
# TF uses `how: artemis`, tmt try uses `how: virtual`. No need to define `how`
6-
# `connection: system` is for `how: virtual` to make VMs get a real IP to configure ssh easily
7-
# This setting is ignored on artemis so we can keep it
5+
# TF uses `how: artemis`, tmt try uses `how: virtual`. No need to define `how`.
6+
# `connection: system` is for `how: virtual` to make VMs get a real IP to configure ssh easily.
7+
# This setting is ignored on artemis so we can keep it.
88
connection: system
99
- name: managed_node1
1010
role: managed_node
@@ -13,45 +13,27 @@ environment:
1313
ANSIBLE_VER: 2.17
1414
REPO_NAME: postgresql
1515
PYTHON_VERSION: 3.12
16-
SYSTEM_ROLES_ONLY_TESTS: ""
16+
SYSTEM_ROLES_ONLY_TESTS: "" # e.g. tests_default.yml
1717
PR_NUM: ""
18+
TEST_LOCAL_CHANGES: true
1819
prepare:
1920
- name: Use vault.centos.org repos (CS 7, 8 EOL workaround)
2021
script: |
2122
if grep -q -e 'CentOS Stream release 8' -e 'CentOS Linux release 7.9' /etc/redhat-release; then
2223
sed -i '/^mirror/d;s/#\(baseurl=http:\/\/\)mirror/\1vault/' /etc/yum.repos.d/*.repo
2324
fi
24-
25-
- name: Enable epel to install beakerlib on all platforms except CS10 and Fedora, there it's not available and not needed
25+
- name: Enable epel to install beakerlib on all platforms except CS10 and Fedora, there epel not available and not needed
2626
script: |
2727
if ! grep -q -e 'CentOS Stream release 10' -e 'Fedora release' /etc/redhat-release; then
2828
yum install epel-release -y
2929
fi
30-
where: control_node
31-
32-
- name: Additional steps to enable EPEL on EL 7
33-
script: |
34-
if grep -q 'CentOS Linux release 7.9' /etc/redhat-release; then
35-
yum install yum-utils -y
36-
yum-config-manager --enable epel epel-debuginfo epel-source
37-
fi
38-
where: control_node
39-
40-
- name: Install python on managed node when running CS8 with ansible!=2.9
41-
script: |
42-
if [ "$ANSIBLE_VER" != "2.9" ] && grep -q 'CentOS Stream release 8' /etc/redhat-release; then
43-
dnf install -y python"$PYTHON_VERSION"
44-
fi
45-
where: managed_node
46-
47-
- name: Distribute SSH keys when provisioned with how=virtual
48-
script: |
49-
if [ -f ${TMT_TREE%/*}/provision/control_node/id_ecdsa.pub ]; then
50-
cat ${TMT_TREE%/*}/provision/control_node/id_ecdsa.pub >> ~/.ssh/authorized_keys
51-
fi
52-
where: managed_node
53-
5430
discover:
31+
- name: Prepare managed node
32+
how: fmf
33+
url: https://github.com/linux-system-roles/tft-tests
34+
ref: main
35+
where: managed_node
36+
filter: tag:prep_managed_node
5537
- name: Run test playbooks from control_node
5638
how: fmf
5739
url: https://github.com/linux-system-roles/tft-tests

0 commit comments

Comments
 (0)