Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

Commit

Permalink
feat: add tmt support
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Shi <[email protected]>
  • Loading branch information
shi2wei3 authored and henrywang committed Jan 30, 2024
1 parent 86b1d18 commit 24af094
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 7 deletions.
1 change: 1 addition & 0 deletions .fmf/version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
1
5 changes: 4 additions & 1 deletion os-replace.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ function redprint {
}

TEMPDIR=$(mktemp -d)
trap 'rm -rf -- "$TEMPDIR"' EXIT

[[ -n "${GCP_SERVICE_ACCOUNT_FILE_B64+x}" ]] && echo "$GCP_SERVICE_ACCOUNT_FILE_B64" | base64 -d > "${TEMPDIR}"/gcp_auth.json && export GCP_SERVICE_ACCOUNT_FILE=${TEMPDIR}/gcp_auth.json

# SSH configurations
SSH_KEY=${TEMPDIR}/id_rsa
Expand Down Expand Up @@ -72,7 +75,7 @@ case "$TEST_OS" in
esac

TEST_IMAGE_NAME="${IMAGE_NAME}-os_replace"
TEST_IMAGE_URL="quay.io/xiaofwan/${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}"
TEST_IMAGE_URL="quay.io/${QUAY_USERNAME}/${TEST_IMAGE_NAME}:${QUAY_REPO_TAG}"

greenprint "Create $TEST_OS installation Containerfile"
tee "$INSTALL_CONTAINERFILE" > /dev/null << EOF
Expand Down
6 changes: 4 additions & 2 deletions playbooks/deploy-gcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
vars:
test_os: "{{ lookup('env', 'TEST_OS') | default('centos-stream-9', true) }}"
arch: "{{ lookup('env', 'ARCH') | default('x86_64', true) }}"
flavor:
x86_64: "n2-standard-2"
aarch64: "t2a-standard-1"
ssh_key_pub: ""
inventory_file: ""
download_node: "{{ lookup('env', 'DOWNLOAD_NODE') | default('', true) }}"
Expand Down Expand Up @@ -38,10 +41,9 @@
command:
"/usr/bin/gcloud compute instances create {{ instance_name }} \
--zone=us-central1-a \
--machine-type=n2-standard-2 \
--machine-type={{ flavor[arch] }} \
--boot-disk-auto-delete \
--boot-disk-size=80GB \
--boot-disk-type=pd-ssd \
--metadata-from-file=ssh-keys={{ ssh_key_pub }}.gcp_key \
--metadata=block-project-ssh-keys=TRUE \
--provisioning-model=SPOT \
Expand Down
1 change: 0 additions & 1 deletion playbooks/deploy-openstack.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
ssh_key_pub: ""
inventory_file: ""
download_node: "{{ lookup('env', 'DOWNLOAD_NODE') | default('', true) }}"
cloud_profile: "rhos-01"
images:
rhel-9-4: RHEL-9.4.0-x86_64-nightly-latest
centos-stream-9: edge-centos-stream-9
Expand Down
69 changes: 69 additions & 0 deletions tmt/plans/all.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
discover:
how: fmf
prepare:
- how: install
package:
- ansible-core
- beaker-client
- gcc
- podman
- skopeo
- python3-devel
- unzip
- how: shell
script: |
pip install boto3 botocore openstacksdk
ansible-galaxy collection install openstack.cloud community.general amazon.aws ansible.posix
- how: shell
script: curl "https://awscli.amazonaws.com/awscli-exe-linux-${ARCH}.zip" -o "awscliv2.zip" && unzip awscliv2.zip && sudo ./aws/install
execute:
how: tmt

/openstack:
summary: Run os-replace test on openstack
tag: openstack
environment+:
PLATFORM: openstack
adjust:
- when: arch == x86_64
discover+:
test: os-replace
- when: arch != x86_64
discover+:
test: N/A

/gcp:
summary: Run os-replace test on gcp
tag: gcp
environment+:
PLATFORM: gcp
prepare+:
- how: shell
script: cp tools/google-cloud-sdk.repo /etc/yum.repos.d/
- how: install
package:
- google-cloud-cli
discover+:
test: os-replace
adjust:
- when: arch == x86_64 or arch == aarch64
discover+:
test: os-replace
- when: arch != x86_64 and arch != aarch64
discover+:
test: N/A

/aws:
summary: Run os-replace test on aws
tag: aws
environment+:
PLATFORM: aws
discover+:
test: os-replace
adjust:
- when: arch == x86_64 or arch == aarch64
discover+:
test: os-replace
- when: arch != x86_64 and arch != aarch64
discover+:
test: N/A
4 changes: 4 additions & 0 deletions tmt/tests/os-replace.fmf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
test: ./test.sh
duration: 20m
environment:
TEST_CASE: os-replace
10 changes: 10 additions & 0 deletions tmt/tests/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh

cd ../../

if [ "$TEST_CASE" = "os-replace" ]; then
./os-replace.sh
else
echo "Error: Test case $TEST_CASE not found!"
exit 1
fi
5 changes: 2 additions & 3 deletions tools/google-cloud-sdk.repo
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[google-cloud-cli]
name=Google Cloud CLI
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el8-x86_64
baseurl=https://packages.cloud.google.com/yum/repos/cloud-sdk-el9-$basearch
enabled=1
gpgcheck=1
repo_gpgcheck=0
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg
https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
gpgkey=https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

0 comments on commit 24af094

Please sign in to comment.