From 0e6785fb6a464aecece12eda95fd218a80e0c257 Mon Sep 17 00:00:00 2001 From: Anoop C S Date: Sat, 27 Apr 2024 11:11:12 +0530 Subject: [PATCH] Add new job configuration for GitLab CI integration --- jobs/gitlab-fs-integration.yml | 75 +++++++++++++++++++ jobs/scripts/gitlab-fs-integration/copy.sh | 4 + .../gitlab-fs-integration.sh | 69 +++++++++++++++++ 3 files changed, 148 insertions(+) create mode 100644 jobs/gitlab-fs-integration.yml create mode 100755 jobs/scripts/gitlab-fs-integration/copy.sh create mode 100755 jobs/scripts/gitlab-fs-integration/gitlab-fs-integration.sh diff --git a/jobs/gitlab-fs-integration.yml b/jobs/gitlab-fs-integration.yml new file mode 100644 index 0000000..586be38 --- /dev/null +++ b/jobs/gitlab-fs-integration.yml @@ -0,0 +1,75 @@ +- project: + name: samba_gitlab-fs-integration + file_system: + - 'cephfs' + - 'cephfs.vfs' + jobs: + - 'samba_gitlab-{filesystem}-integration' + +- job-template: + name: 'samba_gitlab-{file_system}-integration' + node: cico-workspace + description: Run integrations for clustered Samba. + project-type: freestyle + concurrent: true + + parameters: + - string: + name: CENTOS_VERSION + default: '9s' + description: CentOS version to be installed on host node + - string: + name: FILE_SYSTEM + default: '{file_system}' + description: File system to be used as backend for Samba. + + scm: + - git: + url: https://github.com/samba-in-kubernetes/samba-centosci + + properties: + - gitlab: + connection: samba-upstream-gitlab + + - build-discarder: + days-to-keep: 14 + artifacts-days-to-keep: 14 + + triggers: + - gitlab: + trigger-push: false + trigger-merge-request: false + trigger-open-merge-request-push: source + trigger-only-if-new-commits-pushed: true + note-regex: '/(re)?run ((all)|(ci/({file_system})?))' + ci-skip: false + add-note-merge-request: false + add-vote-merge-request: false + merge-request-label-filter-config: + include: ci/{filesystem} + + builders: + - shell: !include-raw-escape: scripts/common/get-node.sh + - shell: | + #!/bin/bash + jobs/scripts/common/bootstrap.sh $WORKSPACE/jobs/scripts/gitlab-fs-integration/gitlab-fs-integration.sh "gitlabMergeRequestIid=$gitlabMergeRequestIid gitlabTargetRepoHttpUrl=$gitlabTargetRepoHttpUrl CENTOS_VERSION=$CENTOS_VERSION FILE_SYSTEM=$FILE_SYSTEM" + + publishers: + - email-ext: + recipients: $gitlabUserEmail + reply-to: $DEFAULT_REPLYTO + subject: $DEFAULT_SUBJECT + content-type: text + body: $DEFAULT_CONTENT + attach-build-log: true + - gitlab-notifier: + name: ci/{filesystem} + - post-tasks: + - matches: + - log-text: Building remotely + script: + !include-raw-escape: + - scripts/gitlab-fs-integration/copy.sh + - scripts/common/return-node.sh + - archive: + artifacts: 'test.out, *.tar.gz' diff --git a/jobs/scripts/gitlab-fs-integration/copy.sh b/jobs/scripts/gitlab-fs-integration/copy.sh new file mode 100755 index 0000000..46a309c --- /dev/null +++ b/jobs/scripts/gitlab-fs-integration/copy.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +set -e +scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "root@$(cat $WORKSPACE/hosts):/tmp/{test.out,*.tar.gz}" . diff --git a/jobs/scripts/gitlab-fs-integration/gitlab-fs-integration.sh b/jobs/scripts/gitlab-fs-integration/gitlab-fs-integration.sh new file mode 100755 index 0000000..0235983 --- /dev/null +++ b/jobs/scripts/gitlab-fs-integration/gitlab-fs-integration.sh @@ -0,0 +1,69 @@ +#!/bin/bash + +# Set up a centos8 machine with the required environment to +# run the tests from https://github.com/samba-in-kubernetes/sit-test-cases.git +# and run the tests. + +BACKEND="${FILE_SYSTEM:-cephfs}" +CENTOS_VERSION="${CENTOS_VERSION//[!0-9]}" +TEST_EXTRA_VARS="" +TEST_TARGET="test" + +set -e + +dnf -y install git + +rm -rf tests +mkdir tests +cd tests +git clone --branch samba-git-install https://github.com/anoopcs9/sit-environment.git +cd sit-environment + +cat << EOF > local.yml +install: + samba: + git: + repo: ${gitlabTargetRepoHttpUrl} + mr: ${gitlabMergeRequestIid} +EOF + +TEST_EXTRA_VARS="backend=${BACKEND}" + +dnf -y install epel-release epel-next-release + +dnf -y install make ansible-core + +if [ "${CENTOS_VERSION}" -eq 8 ]; then + dnf -y install python3.12-pip + dnf -y install ansible-collection-ansible-posix \ + ansible-collection-ansible-utils + pip3.12 install netaddr +else + dnf config-manager --set-enabled crb + dnf -y install python3-pip + ansible-galaxy collection install ansible.posix ansible.utils + pip3 install netaddr +fi + +dnf -y install qemu-kvm qemu-img libvirt libvirt-devel + +dnf -y copr enable pvalena/vagrant +dnf -y install vagrant vagrant-libvirt rsync + +setfacl -m u:qemu:x /root/ + +systemctl start libvirtd + +set +e + +EXTRA_VARS="${TEST_EXTRA_VARS}" make "${TEST_TARGET}" +ret=$? + +EXTRA_VARS="${TEST_EXTRA_VARS}" make statedump + +pushd /tmp +find "sit_statedump" -name test.out -exec cp {} . \; +tar -zcvf "sit_statedump.tar.gz" "sit_statedump" +popd + +exit $ret