-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test deployment locally with tmt (from packit branch) (#581)
Test deployment locally with tmt (from packit branch) To be able to access secrets and test ansible scripts using github secrets in the testing farm github action I need to create a PR from the packit repo itself (and not from a fork). This is the reason why the PR is duplicated at the moment. Should fix #562 #563 #564 #565 Reviewed-by: Laura Barcziová Reviewed-by: Matej Focko Reviewed-by: Maja Massarini
- Loading branch information
Showing
24 changed files
with
1,227 additions
and
10 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1 |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Schedule tests on Testing Farm | ||
on: | ||
pull_request: | ||
|
||
# The concurrency key is used to prevent multiple workflows from running at the same time | ||
concurrency: | ||
group: my-concurrency-group | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Schedule tests on Testing Farm | ||
uses: sclorg/testing-farm-as-github-action@v2 | ||
with: | ||
compose: CentOS-Stream-9 | ||
api_key: ${{ secrets.TF_API_KEY }} | ||
git_url: "https://github.com/packit/deployment" | ||
git_ref: "tf-openshift-tests" | ||
tmt_plan_regex: "deployment/remote" | ||
tmt_hardware: '{"memory": ">= 13 GiB", "disk": [{"size": ">= 100 GB"}], "cpu": {"cores": ">= 6"}, "virtualization": {"is-supported": true}}' | ||
pull_request_status_name: "Deployment" | ||
timeout: 3600 | ||
secrets: CRC_PULL_SECRET=${{ secrets.CRC_PULL_SECRET }} |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
check: | ||
jobs: | ||
- pre-commit | ||
- deployment-tests | ||
# - deployment-tests | ||
gate: | ||
jobs: | ||
- pre-commit | ||
|
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
ANSIBLE_PYTHON ?= $(shell command -v /usr/bin/python3 2> /dev/null || echo /usr/bin/python2) | ||
AP := ansible-playbook -vv -c local -i localhost, -e ansible_python_interpreter=$(ANSIBLE_PYTHON) | ||
VAGRANT_SSH_PORT = "$(shell vagrant ssh-config | awk '/Port/{print $$2}')" | ||
VAGRANT_SSH_USER = "$(shell vagrant ssh-config | awk '/User/{print $$2}')" | ||
VAGRANT_SSH_GUEST = "$(shell vagrant ssh-config | awk '/HostName/{print $$2}')" | ||
VAGRANT_SSH_IDENTITY_FILE = "$(shell vagrant ssh-config | awk '/IdentityFile/{print $$2}')" | ||
VAGRANT_SSH_CONFIG = $(shell vagrant ssh-config | awk 'NR>1 {print " -o "$$1"="$$2}') | ||
VAGRANT_SHARED_DIR = "/vagrant" | ||
|
||
# to be used when the vagrant box link is broken, should be kept in sync with the Vagrant file | ||
#CENTOS_VAGRANT_BOX = CentOS-Stream-Vagrant-8-latest.x86_64.vagrant-libvirt.box | ||
#CENTOS_VAGRANT_URL = https://cloud.centos.org/centos/8-stream/x86_64/images/$(CENTOS_VAGRANT_BOX) | ||
|
||
CRC_PULL_SECRET ?= "$(shell cat secrets/openshift-local-pull-secret.yml)" | ||
|
||
# for this command to work, you may need to: | ||
# sudo systemctl enable --now libvirtd | ||
# sudo systemctl enable --now virtnetworkd | ||
oc-cluster-create: | ||
if [ ! -z "$(CENTOS_VAGRANT_BOX)" ] && [ -f $(CENTOS_VAGRANT_BOX) ]; then wget $(CENTOS_VAGRANT_URL); fi; | ||
vagrant up | ||
|
||
oc-cluster-destroy: | ||
vagrant destroy | ||
|
||
oc-cluster-up: | ||
vagrant up | ||
vagrant ssh -c "cd $(VAGRANT_SHARED_DIR) && $(AP) --extra-vars user=vagrant playbooks/oc-cluster-run.yml" | ||
|
||
oc-cluster-down: | ||
vagrant halt | ||
|
||
oc-cluster-ssh: oc-cluster-up | ||
ssh $(VAGRANT_SSH_CONFIG) localhost | ||
|
||
# Openshift Local pull_secret must exist locally | ||
# or you can also define the CRC_PULL_SECRET var | ||
check-pull-secret: | ||
if [ ! -f ../secrets/openshift-local-pull-secret.yml ] && [ ! -n "$(CRC_PULL_SECRET)" ]; then echo "no pull secret available create secrets/openshift-local-pull-secret.yml file or set CRC_PULL_SECRET variable"; exit 1; else echo "pull secret found"; fi | ||
|
||
# Execute tmt deployment test on a vagrant virtual machine | ||
# The virtual machine has to be already up and running, | ||
# use the target oc-cluster-up | ||
tmt-vagrant-test: check-pull-secret | ||
tmt run --all provision --how connect --user vagrant --guest $(VAGRANT_SSH_GUEST) --port $(VAGRANT_SSH_PORT) --key $(VAGRANT_SSH_IDENTITY_FILE) plan --name deployment/vagrant |
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
VAGRANTFILE_API_VERSION = "2" | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
config.vm.box = "centos/stream9" | ||
config.vm.box_url = "https://cloud.centos.org/centos/9-stream/x86_64/images/CentOS-Stream-Vagrant-9-latest.x86_64.vagrant-libvirt.box" | ||
#config.vm.box_url = "file:///$VagrantProjectHome/../CentOS-Stream-Vagrant-8-latest.x86_64.vagrant-libvirt.box" | ||
|
||
|
||
# Forward traffic on the host to the development server on the guest | ||
config.vm.network "forwarded_port", guest: 5000, host: 5000 | ||
# Forward traffic on the host to Redis on the guest | ||
config.vm.network "forwarded_port", guest: 6379, host: 6379 | ||
# Forward traffic on the host to the SSE server on the guest | ||
config.vm.network "forwarded_port", guest: 8080, host: 8080 | ||
|
||
|
||
if Vagrant.has_plugin?("vagrant-hostmanager") | ||
config.hostmanager.enabled = true | ||
config.hostmanager.manage_host = true | ||
end | ||
|
||
# Vagrant can share the source directory using rsync, NFS, or SSHFS (with the vagrant-sshfs | ||
# plugin). By default it rsyncs the current working directory to /vagrant. | ||
# | ||
# If you would prefer to use NFS to share the directory uncomment this and configure NFS | ||
# config.vm.synced_folder ".", "/vagrant", type: "nfs", nfs_version: 4, nfs_udp: false | ||
config.vm.synced_folder "..", "/vagrant" | ||
# config.vm.synced_folder ".", "/vagrant", disabled: true | ||
# config.vm.synced_folder ".", "/srv/pagure", | ||
# ssh_opts_append: "-o IdentitiesOnly=yes", | ||
# type: "sshfs" | ||
|
||
# To cache update packages (which is helpful if frequently doing `vagrant destroy && vagrant up`) | ||
# you can create a local directory and share it to the guest's DNF cache. The directory needs to | ||
# exist, so create it before you uncomment the line below. | ||
#Dir.mkdir('.dnf-cache') unless File.exists?('.dnf-cache') | ||
#config.vm.synced_folder ".dnf-cache", "/var/cache/dnf", | ||
# type: "sshfs", | ||
# sshfs_opts_append: "-o nonempty" | ||
|
||
# Comment this line if you would like to disable the automatic update during provisioning | ||
# config.vm.provision "shell", inline: "sudo dnf -y --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos" | ||
|
||
# !!!!!!! resize disk image !!!!!!!!! | ||
config.vm.provision "shell", inline: "sudo dnf install -y cloud-utils-growpart" | ||
config.vm.provision "shell", inline: "sudo growpart /dev/vda 1" | ||
config.vm.provision "shell", inline: "sudo resize2fs /dev/vda1" | ||
# config.vm.provision "shell", inline: "sudo xfs_growfs /dev/vda1" # this was for CentOS Stream 8 | ||
|
||
# bootstrap and run with ansible | ||
config.vm.provision "ansible" do |ansible| | ||
# ansible.verbose = "-vvv" | ||
ansible.verbose = true | ||
ansible.playbook = "../playbooks/oc-cluster-setup.yml" | ||
ansible.extra_vars = {"user": "vagrant"} | ||
end | ||
config.vm.provision "ansible" do |ansible| | ||
# ansible.verbose = "-vvv" | ||
ansible.verbose = true | ||
ansible.playbook = "../playbooks/oc-cluster-run.yml" | ||
ansible.raw_arguments = ['--extra-vars', 'user=vagrant', '--extra-vars', '@../secrets/openshift-local-pull-secret.yml'] | ||
end | ||
config.vm.provision "ansible" do |ansible| | ||
# ansible.verbose = "-vvv" | ||
ansible.become = true | ||
ansible.become_user = "root" | ||
ansible.verbose = true | ||
ansible.playbook = "../playbooks/oc-cluster-tests-setup.yml" | ||
end | ||
|
||
# Create the box | ||
config.vm.define "packit-oc-cluster" do |oc| | ||
oc.vm.host_name = "packit-oc-cluster.example.com" | ||
|
||
oc.vm.provider :libvirt do |domain| | ||
# Season to taste | ||
domain.cpus = 6 | ||
domain.graphics_type = "spice" | ||
domain.memory = 14336 | ||
domain.video_type = "qxl" | ||
domain.machine_virtual_size = 100 | ||
|
||
# Uncomment the following line if you would like to enable libvirt's unsafe cache | ||
# mode. It is called unsafe for a reason, as it causes the virtual host to ignore all | ||
# fsync() calls from the guest. Only do this if you are comfortable with the possibility of | ||
# your development guest becoming corrupted (in which case you should only need to do a | ||
# vagrant destroy and vagrant up to get a new one). | ||
# | ||
# domain.volume_cache = "unsafe" | ||
end | ||
end | ||
end |
This file contains 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 characters
This file contains 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 characters
Oops, something went wrong.