Skip to content

Commit

Permalink
Add new job configuration for GitLab CI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
anoopcs9 committed Apr 30, 2024
1 parent 82f05b4 commit dfa9c4b
Show file tree
Hide file tree
Showing 3 changed files with 148 additions and 0 deletions.
75 changes: 75 additions & 0 deletions jobs/gitlab-fs-integration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
- project:
name: samba_gitlab-fs-integration
file_system:
- 'cephfs'
- 'cephfs.vfs'
jobs:
- 'samba_gitlab-{file_system}-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/{file_system}

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/{file_system}
- 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'
4 changes: 4 additions & 0 deletions jobs/scripts/gitlab-fs-integration/copy.sh
Original file line number Diff line number Diff line change
@@ -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}" .
69 changes: 69 additions & 0 deletions jobs/scripts/gitlab-fs-integration/gitlab-fs-integration.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dfa9c4b

Please sign in to comment.