Skip to content

Commit

Permalink
fix1
Browse files Browse the repository at this point in the history
  • Loading branch information
lilyLuLiu committed Dec 6, 2024
1 parent daa7a68 commit c4ff2de
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 23 deletions.
84 changes: 69 additions & 15 deletions .github/workflows/linux-qe-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ on:

jobs:
linux-qe:
runs-on: [self-hosted]
runs-on: ubuntu-24.04
permissions:
statuses: write # needed to update commit status (pending/failure/sucess)
checks: write # as documented in https://github.com/mikepenz/action-junit-report?tab=readme-ov-file#pr-run-permissions
Expand All @@ -31,6 +31,11 @@ jobs:

- name: prepare
run: |
# Install Testing farm CLI
curl -LO "https://gitlab.com/testing-farm/cli/-/raw/main/container/testing-farm"
chmod +x testing-farm
mv testing-farm /usr/local/bin/
sudo yum install podman openssh-server -y
# Get origin commit sha for testing
Expand All @@ -49,8 +54,6 @@ jobs:
status_context="${status_context}/Linux-ARM64"
echo "status_context=${status_context}" >> "$GITHUB_ENV"
echo "${PULL_SECRET}" > pull-secret
- name: Download linux binary
uses: actions/download-artifact@v4
with:
Expand Down Expand Up @@ -86,6 +89,8 @@ jobs:
TESTING_FARM_API_TOKEN: ${{ secrets.TESTING_FARM_API_TOKEN }}
PULL_SECRET: ${{ secrets.PULL_SECRET }}
run: |
echo "${PULL_SECRET}" > pull-secret
# the target can only be accessed through a bastion (which can only be accessed from self-hosted runner)
# as so we need to map the ssh-agent from the host to the containers used to access the target host
rm -f id_rsa id_rsa.pub
Expand All @@ -97,7 +102,7 @@ jobs:
# reserve machine from testing farm
export TESTING_FARM_API_TOKEN=${TESTING_FARM_API_TOKEN}
testing-farm reserve --compose Fedora-40 --duration 240 --arch aarch64 --hardware memory='>= 12 GB' --hardware virtualization.is-supported='true' --ssh-public-key id_rsa.pub --no-autoconnect | tee info
testing-farm reserve --compose Fedora-40 --duration 480 --arch aarch64 --hardware memory='>= 16 GB' --hardware cpu.processors='>= 4' --hardware virtualization.is-supported='true' --ssh-public-key id_rsa.pub --no-autoconnect | tee info
machine=`tail -n 1 info`
echo ${machine##*@} > host
echo crctest > username
Expand All @@ -107,16 +112,19 @@ jobs:
echo ${request:1} > requestid
# Create a non-root user for testing on the reserved machine
ssh_cmd="ssh -i id_rsa ${machine##*ssh}"
ssh_cmd="ssh -i id_rsa -o StrictHostKeyChecking=no ${machine##*ssh}"
echo ${machine##*ssh}
echo $ssh_cmd
$ssh_cmd 'useradd crctest' < /dev/null
$ssh_cmd 'echo "crctest:redhat" | chpasswd' < /dev/null
$ssh_cmd 'usermod -aG wheel crctest' < /dev/null
$ssh_cmd 'echo "crctest ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/crctest-users' < /dev/null
$ssh_cmd 'mkdir -p /home/crctest/.ssh' < /dev/null
$ssh_cmd 'cp /root/.ssh/authorized_keys /home/crctest/.ssh/' < /dev/null
$ssh_cmd 'chown crctest /home/crctest/.ssh/authorized_keys' < /dev/null
$ssh_cmd 'chown -R crctest:crctest /home/crctest/.ssh/' < /dev/null
# Install CRC on the reserved machine
echo "Start installing crc on reserved machine"
podman run --rm -d --privileged --name crc-linux-install-${{inputs.qe-type}}-${{inputs.preset}} \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
Expand All @@ -132,25 +140,65 @@ jobs:
-v ${PWD}:/data:z \
-v ${PWD}/crc:/opt/crc-support/crc:z \
quay.io/crc-org/ci-crc-support:v2.0.0-dev-linux crc-support/run.sh \
-targetPath "/root/crc-support" \
-targetPath "/home/crctest/crc-support" \
-install 'true' \
-aName 'crc' \
-freshEnv 'false' \
-download 'false'
podman logs -f crc-linux-install-${{inputs.qe-type}}-${{inputs.preset}}
# Download arm64 bundle in the reserved machine
echo "Start download bundle on reserved machine"
if [[ "${{inputs.preset}}" == "microshift" ]]; then
bundle_url="https://crcqe-asia.s3.ap-south-1.amazonaws.com/bundles/microshift/4.17.7-arm64"
bundle_name="crc_microshift_libvirt_4.17.7_arm64.crcbundle"
else
bundle_url="https://crcqe-asia.s3.ap-south-1.amazonaws.com/bundles/openshift/4.17.7-arm64"
bundle_name="crc_libvirt_4.17.7_arm64.crcbundle"
fi
podman run --rm -d --privileged --name download_bundle \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
-e TARGET_HOST_KEY_PATH=/data/id_rsa \
-e BASTION_HOST_USERNAME=$(cat bastion_username) \
-e BASTION_HOST=$(cat bastion_host) \
-e TARGET_FOLDER=crc-support \
-e TARGET_CLEANUP='false' \
-e OUTPUT_FOLDER=/data \
-e DEBUG='true' \
-e SSH_AUTH_SOCK=$(cat ssh_auth_sock) \
-v "$(cat ssh_auth_sock):$(cat ssh_auth_sock)" \
-v ${PWD}:/data:z \
quay.io/crc-org/ci-crc-support:v2.0.0-dev-linux crc-support/run.sh \
-targetPath "/home/crctest" \
-install 'false' \
-aBaseURL $bundle_url \
-aName $bundle_name \
-freshEnv 'false' \
-download 'true'
podman logs -f download_bundle
# load image
podman load -i crc-${{inputs.qe-type}}-linux-arm64.tar
$ssh_cmd 'chmod +x /usr/local/bin/crc' < /dev/null
# run CRC test
cmd="crc-qe/run.sh -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe"
cmd="crc-qe/run.sh -bundleLocation /home/crctest/$bundle_name -junitFilename crc-${{inputs.qe-type}}-junit.xml -targetFolder crc-qe"
if [[ "${{inputs.qe-type}}" == "e2e" ]]; then
if [[ "${{inputs.preset}}" == "microshift" ]]; then
cmd="${cmd} -e2eTagExpression '@story_microshift'"
else
cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift'"
cmd="${cmd} -e2eTagExpression '~@minimal && ~@story_microshift && ~@cert_rotation'"
fi
else
if [[ "${{inputs.preset}}" == "microshift" ]]; then
cmd="${cmd} -labelFilter 'microshift-preset'"
else
cmd="${cmd} -labelFilter 'openshift-preset'"
fi
fi
echo "Start running test on reserved machine"
podman run --rm -d --privileged --name crc-${{inputs.qe-type}}-${{inputs.preset}} \
-e TARGET_HOST=$(cat host) \
-e TARGET_HOST_USERNAME=$(cat username) \
Expand Down Expand Up @@ -190,6 +238,17 @@ jobs:
**/*.results
**/*.log
- name: Return machine and clear env
env:
TESTING_FARM_API_TOKEN: ${{ secrets.TESTING_FARM_API_TOKEN }}
if: always()
run: |
export TESTING_FARM_API_TOKEN=${TESTING_FARM_API_TOKEN}
testing-farm cancel $(cat requestid)
podman rmi quay.io/crcont/crc-${{inputs.qe-type}}:gh-linux-arm64
rm -r results
kill $(cat ssh_agent_pid)
- name: Update status of the PR check
if: always()
run: |
Expand All @@ -209,12 +268,7 @@ jobs:
https://api.github.com/repos/${{ github.repository }}/statuses/${{ env.commit_sha }} \
-d "${data}"
- name: Return machine and clear env
env:
TESTING_FARM_API_TOKEN: ${{ secrets.TESTING_FARM_API_TOKEN }}
run: |
export TESTING_FARM_API_TOKEN=${TESTING_FARM_API_TOKEN}
testing-farm cancel $(cat requestid)



9 changes: 1 addition & 8 deletions .github/workflows/linux-qe-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,7 @@ jobs:
fail-fast: false
matrix:
qe-type: ['e2e','integration']
preset: ['openshift', 'microshift', 'all']
exclude:
- qe-type: 'e2e'
preset: 'all'
- qe-type: 'integration'
preset: 'openshift'
- qe-type: 'integration'
preset: 'microshift'
preset: ['openshift', 'microshift']
with:
trigger-workflow-run-id: ${{ github.event.workflow_run.id }}
qe-type: ${{matrix.qe-type}}
Expand Down

0 comments on commit c4ff2de

Please sign in to comment.