PMM-7: run vbox commands as sudo #114
Workflow file for this run
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
name: _runner-pmm3-ovf-tests | |
on: | |
push: | |
branches: | |
- "PMM-7-ovf-tests" | |
workflow_dispatch: | |
inputs: | |
pmm_ui_tests_branch: | |
description: "Branch for PMM-UI tests to checkout" | |
required: false | |
type: string | |
pmm_qa_branch: | |
description: "Branch for PMM-QA to checkout" | |
required: false | |
type: string | |
pmm_ova_server_image: | |
description: 'PMM Server docker image' | |
default: '2.41.2' | |
required: false | |
type: string | |
pmm_client_image: | |
description: 'pmm2-client docker image' | |
default: 'perconalab/pmm-client:dev-latest' | |
required: false | |
type: string | |
pmm_client_version: | |
description: 'PMM Client version (dev-latest|pmm2-latest|pmm2-rc|x.xx.x|https...)' | |
default: 'dev-latest' | |
required: false | |
type: string | |
setup_services: | |
description: "Setup arguments, ex.: --addclient=ps,1 --ps-version=5.7" | |
required: false | |
type: string | |
tags_for_tests: | |
description: "example: @settings-fb" | |
required: true | |
type: string | |
sha: | |
description: "SHA (leave default if running manually)" | |
default: 'null' | |
required: false | |
type: string | |
workflow_call: | |
inputs: | |
pmm_ui_tests_branch: | |
required: false | |
type: string | |
pmm_qa_branch: | |
required: false | |
type: string | |
pmm_ova_server_image: | |
required: false | |
default: '2.41.2' | |
type: string | |
pmm_client_version: | |
required: false | |
type: string | |
pmm_client_image: | |
required: false | |
type: string | |
setup_services: | |
required: false | |
type: string | |
tags_for_tests: | |
required: true | |
type: string | |
sha: | |
required: false | |
type: string | |
jobs: | |
ui-tests-e2e: | |
name: "PMM3 OVF tests with tags: ${{ inputs.tags_for_tests }}" | |
runs-on: ubuntu-20.04 | |
env: | |
SHA: ${{ inputs.sha || 'null' }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
ADMIN_PASSWORD: 'admin' | |
PMM_QA_BRANCH: ${{ inputs.pmm_qa_branch || 'main' }} | |
PMM_QA_GIT_BRANCH: ${{ inputs.pmm_qa_branch || 'main' }} | |
PMM_UI_BRANCH: ${{ inputs.pmm_ui_tests_branch || 'main' }} | |
OVA_VERSION: ${{ inputs.pmm_ova_server_image }} | |
CLIENT_DOCKER_VERSION: ${{ inputs.pmm_client_image || 'perconalab/pmm-client:dev-latest' }} | |
PMM_CLIENT_VERSION: ${{ inputs.pmm_client_version || 'dev-latest' }} | |
WIZARD_ARGS: ${{ inputs.setup_services || '' }} | |
TAGS_FOR_TESTS: ${{ inputs.tags_for_tests || '@settings-fb' }} | |
# Environment variables for tests | |
BACKUP_LOCATION_ACCESS_KEY: ${{ secrets.BACKUP_LOCATION_ACCESS_KEY }} | |
BACKUP_LOCATION_SECRET_KEY: ${{ secrets.BACKUP_LOCATION_SECRET_KEY }} | |
steps: | |
- name: Create status check | |
if: ${{ github.event_name != 'pull_request' }} | |
uses: percona/gh-action-github-status-action@v1 | |
continue-on-error: true | |
with: | |
authToken: ${{ secrets.GITHUB_TOKEN }} | |
context: "${{ env.TAGS_FOR_TESTS }} UI tests" | |
description: "Test execution ${{ job.status }}" | |
state: "pending" | |
repository: ${{ github.repository }} | |
target_url: "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}" | |
sha: ${{ env.SHA }} | |
- name: Checkout PMM UI tests | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.PMM_UI_BRANCH }} | |
repository: percona/pmm-ui-tests | |
path: ./pmm-ui-tests | |
- name: Setup tools | |
run: | | |
sudo apt update | |
sudo apt install virtualbox | |
- name: Get PMM Server OVF Image | |
run: | | |
wget https://downloads.percona.com/downloads/pmm2/${{ env.OVA_VERSION }}/ova/pmm-server-${{ env.OVA_VERSION }}.ova | |
- name: Start PMM Server OVF Image | |
run: | | |
tar xvf pmm-server-${{ env.OVA_VERSION }}.ova | |
export OVF_NAME=$(find -type f -name '*.ovf') | |
sudo vboxmanage import $OVF_NAME --vsys 0 --vmname pmm-server | |
sudo vboxmanage startvm pmm-server --type headless | |
sleep 60 | |
echo "SERVER_IP=$(sudo vboxmanage guestproperty get pmm-server /VirtualBox/GuestInfo/Net/0/V4/IP | awk -F " " '{print $2}')" >> $GITHUB_ENV | |
export SERVER_IP=$(sudo vboxmanage guestproperty get pmm-server /VirtualBox/GuestInfo/Net/0/V4/IP | awk -F " " '{print $2}') | |
echo "Server IP: " | |
echo $SERVER_IP | |
sudo vboxmanage controlvm pmm-server acpipowerbutton | |
sleep 15 | |
sudo vboxmanage modifyvm pmm-server --natpf1 "guestweb,tcp,127.0.0.1,80,$SERVER_IP,80" | |
sudo vboxmanage modifyvm pmm-server --natpf1 "guesthttps,tcp,127.0.01,443,$SERVER_IP,443" | |
sudo vboxmanage startvm pmm-server --type headless | |
- name: Setup npm modules for e2e tests | |
working-directory: ./pmm-ui-tests | |
run: | | |
sudo VBoxManage showvminfo pmm-server | |
npm ci | |
envsubst < env.list > env.generated.list | |
- name: Execute e2e tests for OVF image | |
working-directory: ./pmm-ui-tests | |
env: | |
PMM_UI_URL: "http://${{ env.SERVER_IP }}/" | |
PMM_URL: "http://admin:${{ env.ADMIN_PASSWORD }}@${{ env.SERVER_IP }}" | |
run: | | |
echo ${{ env.PMM_UI_URL }} | |
echo $PMM_UI_URL | |
sudo vboxmanage list runningvms | |
sed -i 's+http://localhost/+${PMM_UI_URL}/+g' pr.codecept.js | |
./node_modules/.bin/codeceptjs run -c pr.codecept.js --grep "@dashboards" | |
sleep 30 | |
ls ./tests/output/ | |
- uses: actions/github-script@v7 | |
if: ${{ always() }} | |
id: artifact_name | |
with: | |
script: | | |
return `artifacts_for_${process.env.TAGS_FOR_TESTS.replaceAll('|', '')}` | |
result-encoding: string | |
- uses: actions/upload-artifact@v4 | |
if: ${{ always() }} | |
with: | |
name: ${{ steps.artifact_name.outputs.result }} | |
path: | | |
pmm-ui-tests/tests/output/*.png |