Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests/e2e: Migrate e2e test for s390x to GHA #295

Merged
merged 1 commit into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ccruntime-nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: ccruntime e2e test nightly
on:
schedule:
- cron: '0 2 * * *'
workflow_dispatch:

jobs:
e2e-nightly:
uses: ./.github/workflows/ccruntime_e2e.yaml

e2e-ibm-se-nightly:
runs-on: s390x
strategy:
fail-fast: false
matrix:
test_title:
- cc-operator-e2e-tests
steps:
- name: Fetch a test result for {{ matrix.test_title }}
run: |
file_name="${TEST_TITLE}-$(date +%Y-%m-%d).log"
/home/${USER}/script/handle_test_log.sh download $file_name
env:
TEST_TITLE: ${{ matrix.test_title }}
19 changes: 19 additions & 0 deletions .github/workflows/ccruntime-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ccruntime e2e test for PR
on:
pull_request_target:
branches:
- 'main'
types:
- opened
- synchronize
- reopened
- labeled
paths-ignore:
- 'docs/**'

jobs:
e2e-pr:
if: ${{ contains(github.event.pull_request.labels.*.name, 'ok-to-test') }}
uses: ./.github/workflows/ccruntime_e2e.yaml
with:
target-branch: ${{ github.event.pull_request.base.ref }}
48 changes: 42 additions & 6 deletions .github/workflows/ccruntime_e2e.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
name: ccruntime e2e tests
on:
pull_request:
branches:
- main
workflow_call:
inputs:
target-branch:
required: false
type: string
default: ""

permissions:
contents: read
Expand All @@ -13,12 +16,32 @@ jobs:
strategy:
fail-fast: false
matrix:
runtimeclass: ["kata-qemu", "kata-clh"]
instance: ["az-ubuntu-2004", "az-ubuntu-2204"]
runtimeclass:
- "kata-qemu"
- "kata-clh"
instance:
- "az-ubuntu-2004"
- "az-ubuntu-2204"
- "s390x"
exclude:
- runtimeclass: "kata-clh"
instance: "s390x"
runs-on: ${{ matrix.instance }}
steps:
- name: Take a pre-action for self-hosted runner
run: |
if [ -f ${HOME}/script/pre_action.sh ]; then
${HOME}/script/pre_action.sh cc-operator
fi

- uses: actions/checkout@v4

- name: Rebase atop of the latest target branch
run: |
./tests/git-helper.sh "rebase-atop-of-the-latest-target-branch"
env:
TARGET_BRANCH: ${{ inputs.target-branch }}

- name: Install deps
run: |
sudo apt-get update -y
Expand All @@ -29,4 +52,17 @@ jobs:
run: |
cd tests/e2e
export PATH="$PATH:/usr/local/bin"
./run-local.sh -r "${{ matrix.runtimeclass }}" -u
args="-u"
if [ $RUNNING_INSTANCE = "s390x" ]; then
args=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@BbolroC so s390x is not going to run the undo (-u) operations from the e2e framework. Will it be done (undo) by the post-action then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was concluded that the option -u is not suitable for a self-hosted runner context. The functionality of the option is delegated to the {pre,post}-action.

fi
./run-local.sh -r "${{ matrix.runtimeclass }}" "${args}"
env:
RUNNING_INSTANCE: ${{ matrix.instance }}

- name: Take a post-action
if: always()
run: |
if [ -f ${HOME}/script/post_action.sh ]; then
${HOME}/script/post_action.sh cc-operator
fi
37 changes: 37 additions & 0 deletions tests/e2e/ansible/install_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,43 @@
- docker-ce-cli
state: present
when: docker_exist.rc != 0 and ansible_distribution == "CentOS"
#
# In order to prevent "systemd: docker.service Start request repeated too quickly"
#
- name: Set StartLimitBurst to 0 on Ubuntu for s390x
block:
- name: If a fragment path starts with `/lib`, then create /etc/systemd/system/docker.service.d
block:
- name: Get FragmentPath
shell: systemctl show -p FragmentPath docker.service | awk -F'=' '{print $2}'
register: fragment_path
- name: Copy fragment file to /etc/systemd/system/docker.service.d
copy:
src: "{{ fragment_path.stdout }}"
dest: "{{ fragment_path.stdout.replace('/lib', '/etc') }}"
when: fragment_path.stdout.find('/lib') != -1
- name: Configure `StartLimitBurst=0` in /etc/systemd/system/docker.service
block:
- name: Check if /etc/systemd/system/docker.service has StartLimitBurst=0
shell: grep -q 'StartLimitBurst' /etc/systemd/system/docker.service
register: start_limit_burst
ignore_errors: yes
- name: Replace a value of StartLimitBurst to 0
lineinfile:
path: /etc/systemd/system/docker.service
regexp: '^StartLimitBurst='
line: 'StartLimitBurst=0'
when: start_limit_burst.rc == 0
- name: Otherwise, insert `StartLimitBurst=0` just after a service section
lineinfile:
path: /etc/systemd/system/docker.service
insertafter: '\[Service\]'
line: 'StartLimitBurst=0'
when: start_limit_burst.rc != 0
- name: Reload systemd
systemd:
daemon_reload: yes
when: ansible_distribution == "Ubuntu" and ansible_architecture == 's390x'
- name: Start docker service
service:
name: docker
Expand Down
63 changes: 63 additions & 0 deletions tests/git-helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/env bash
#
# Copyright Confidential Containers Contributors
#
# SPDX-License-Identifier: Apache-2.0
#

set -o errexit
set -o nounset
set -o pipefail

function install_jq() {
if [ -n "$(command -v apt-get)" ]; then
sudo apt-get update
sudo apt-get install -y jq
elif [ -n "$(command -v yum)" ]; then
sudo yum install -y epel-release
sudo yum install -y jq
else
>&2 echo "No supported package manager found"
exit 1
fi
}

function configure_github() {
if [ ! command -v jq &> /dev/null ]; then
echo "jq is not installed, installing it"
install_jq
fi
USERNAME=$(jq -r '.pull_request.user.login' "$GITHUB_EVENT_PATH")
EMAIL=$(jq -r '.pull_request.user.email' "$GITHUB_EVENT_PATH")
# if the email is null, stuff with a dummy email
if [ "${EMAIL}" == "null" ]; then
EMAIL="dummy@email.address"
fi
echo "Adding user name ${USERNAME} and email ${EMAIL} to the local git repo"
git config user.name "${USERNAME}"
git config user.email "${EMAIL}"
}

function rebase_atop_of_the_latest_target_branch() {
if [ -n "${TARGET_BRANCH}" ]; then
configure_github
echo "Rebasing atop of the latest ${TARGET_BRANCH}"
# Recover from any previous rebase left halfway
git rebase --abort 2> /dev/null || true
if ! git rebase origin/${TARGET_BRANCH}; then
>&2 echo "Rebase failed, exiting"
Copy link
Member

@stevenhorsman stevenhorsman Jan 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Choi, in the kata-containers version there was a different path for self-hosted runner than deleted the workspace directory to avoid merge conflicts impacting runs IIRC - is that needed here too?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I intentionally removed those lines here, wanting to see if that is also the case for this repo. Even if that is the case again, that could be handled by {pre,post}-action, I guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks for the explanation!

exit 1
fi
fi
}

function main() {
action="${1:-}"

case "${action}" in
rebase-atop-of-the-latest-target-branch) rebase_atop_of_the_latest_target_branch;;
*) >&2 echo "Invalid argument"; exit 2 ;;
esac
}

main "$@"
Loading