Skip to content

Commit a18e174

Browse files
committed
Add gitlab ci and functional testing
1 parent 0b9b80b commit a18e174

File tree

4 files changed

+184
-2
lines changed

4 files changed

+184
-2
lines changed

.gitlab-ci.yml

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
stages:
2+
- build
3+
- image
4+
- test
5+
- deploy
6+
- cleanup
7+
8+
before_script:
9+
- export CLUSTER_NAME=cvmfs-validation-$(echo $CI_COMMIT_SHA | head -c 6)
10+
- export OS_AUTH_URL="https://keystone.cern.ch/main/v3"
11+
- export OS_IDENTITY_API_VERSION="3"
12+
- export OS_USERNAME="svcbuild"
13+
- export OS_PASSWORD="$SVCBUILD_PASSWORD"
14+
- export OS_PROJECT_NAME="Cloud CI"
15+
- export OS_REGION_NAME="cern"
16+
- export OS_DEFAULT_DOMAIN_NAME="default"
17+
- export OS_TENANT_ID="ec9ce822-d12f-453e-9f18-110652a85798"
18+
- export OS_TENANT_NAME="Cloud CI"
19+
20+
build:
21+
stage: build
22+
image: gitlab-registry.cern.ch/cloud/ciadm
23+
script:
24+
- rpm --import https://mirror.go-repo.io/centos/RPM-GPG-KEY-GO-REPO
25+
- curl -s https://mirror.go-repo.io/centos/go-repo.repo | tee /etc/yum.repos.d/go-repo.repo
26+
- echo 'priority=1' >> /etc/yum.repos.d/go-repo.repo
27+
- yum install -y gcc git golang make
28+
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.cern.ch
29+
- make
30+
- make test
31+
artifacts:
32+
expire_in: '10 days'
33+
paths:
34+
- _output/csi-cvmfsplugin
35+
except:
36+
- qa
37+
- master
38+
tags:
39+
- docker-privileged
40+
41+
build image:
42+
stage: image
43+
image: gitlab-registry.cern.ch/cloud/ciadm
44+
script:
45+
- cp _output/csi-cvmfsplugin deploy/docker
46+
- yum install -y make
47+
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN gitlab-registry.cern.ch
48+
- docker build -t gitlab-registry.cern.ch/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA deploy/docker
49+
- docker push gitlab-registry.cern.ch/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA
50+
dependencies:
51+
- build
52+
except:
53+
- master
54+
- qa
55+
tags:
56+
- docker-privileged
57+
58+
test k8s:
59+
stage: test
60+
image: gitlab-registry.cern.ch/cloud/ciadm
61+
script:
62+
- openstack coe cluster create $CLUSTER_NAME --cluster-template kubernetes-1.13.3-1 --keypair lxplus --node-count 1 --master-count 1 --flavor m2.small
63+
- sleep 10
64+
- STATUS=$(openstack coe cluster show $CLUSTER_NAME -c status | grep 'status ' | awk '{print $4}')
65+
- while [ "$STATUS" != "CREATE_COMPLETE" ] && [ "$STATUS" != "CREATE_FAILED" ]; do STATUS=$(openstack coe cluster show $CLUSTER_NAME -c status | grep 'status ' | awk '{print $4}'); done
66+
- openstack coe cluster show $CLUSTER_NAME
67+
- openstack coe cluster config $CLUSTER_NAME
68+
- export KUBECONFIG=config
69+
- kubectl create --validate=false -f magnum-cvmfs.yaml
70+
- kubectl rollout status deployment/cvmfs
71+
- POD=$(kubectl get pod | grep cvmfs | awk '{print $1}')
72+
- kubectl exec $POD -c atlas cat /cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase/README.INSTALL
73+
- kubectl exec $POD -c cms cat /cvmfs/cms.cern.ch/README
74+
dependencies:
75+
- build
76+
except:
77+
- master
78+
- qa
79+
80+
cleanup test clusters:
81+
stage: cleanup
82+
image: gitlab-registry.cern.ch/cloud/ciadm
83+
script:
84+
- openstack coe cluster show ${CLUSTER_NAME}; if [ $? -eq 0 ]; then openstack coe cluster delete ${CLUSTER_NAME} || true; fi
85+
- sleep 5
86+
- while openstack coe cluster show ${CLUSTER_NAME}; [ $? -eq 0 ]; do sleep 3; done
87+
when: always
88+
except:
89+
- master
90+
- qa
91+
92+
deploy tag:
93+
stage: deploy
94+
image: gitlab-registry.cern.ch/cloud/ciadm
95+
script:
96+
- docker pull gitlab-registry.cern.ch/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA
97+
- docker tag gitlab-registry.cern.ch/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_SHA gitlab-registry.cern.ch/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_TAG
98+
- docker push gitlab-registry.cern.ch/$CI_PROJECT_NAMESPACE/$CI_PROJECT_NAME:$CI_COMMIT_TAG
99+
only:
100+
- tags
101+
tags:
102+
- docker-privileged

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cvmfsplugin:
1313
go mod tidy
1414
CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' -o _output/$(NAME) ./cvmfs
1515

16-
image: cvmfsplugin
16+
image:
1717
cp _output/$(NAME) deploy/docker
1818
docker build -t $(NAME):$(IMAGE_VERSION) deploy/docker
1919

magnum-cvmfs.yaml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
apiVersion: storage.k8s.io/v1
2+
kind: StorageClass
3+
metadata:
4+
name: csi-cvmfs-atlas
5+
provisioner: csi-cvmfsplugin
6+
parameters:
7+
repository: atlas.cern.ch
8+
---
9+
apiVersion: storage.k8s.io/v1
10+
kind: StorageClass
11+
metadata:
12+
name: csi-cvmfs-cms
13+
provisioner: csi-cvmfsplugin
14+
parameters:
15+
repository: cms.cern.ch
16+
---
17+
apiVersion: v1
18+
kind: PersistentVolumeClaim
19+
metadata:
20+
name: csi-cvmfs-atlas-pvc
21+
spec:
22+
accessModes:
23+
- ReadOnlyMany
24+
resources:
25+
requests:
26+
storage: 1Gi
27+
storageClassName: csi-cvmfs-atlas
28+
---
29+
apiVersion: v1
30+
kind: PersistentVolumeClaim
31+
metadata:
32+
name: csi-cvmfs-cms-pvc
33+
spec:
34+
accessModes:
35+
- ReadOnlyMany
36+
resources:
37+
requests:
38+
storage: 1Gi
39+
storageClassName: csi-cvmfs-cms
40+
---
41+
apiVersion: apps/v1
42+
kind: Deployment
43+
metadata:
44+
name: cvmfs
45+
labels:
46+
app: cvmfs
47+
spec:
48+
replicas: 1
49+
selector:
50+
matchLabels:
51+
app: cvmfs
52+
template:
53+
metadata:
54+
labels:
55+
app: cvmfs
56+
spec:
57+
containers:
58+
- name: atlas
59+
image: busybox
60+
command: ["/bin/sh"]
61+
args: ["-c", "sleep 10000"]
62+
volumeMounts:
63+
- mountPath: /cvmfs/atlas.cern.ch
64+
name: atlas-pvc
65+
- name: cms
66+
image: busybox
67+
command: ["/bin/sh"]
68+
args: ["-c", "sleep 10000"]
69+
volumeMounts:
70+
- mountPath: /cvmfs/cms.cern.ch
71+
name: cms-pvc
72+
volumes:
73+
- name: atlas-pvc
74+
persistentVolumeClaim:
75+
claimName: csi-cvmfs-atlas-pvc
76+
readOnly: true
77+
- name: cms-pvc
78+
persistentVolumeClaim:
79+
claimName: csi-cvmfs-cms-pvc
80+
readOnly: true

pkg/cvmfs/nodeserver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ func (ns *nodeServer) NodeUnpublishVolume(ctx context.Context, req *csi.NodeUnpu
134134
// Unbind the volume
135135

136136
if err := unmountVolume(targetPath); err != nil {
137-
glog.Errorf("failed to unbind volume %s: %v")
137+
glog.Errorf("failed to unbind volume %s: %v", targetPath, err)
138138
return nil, status.Error(codes.Internal, err.Error())
139139
}
140140

0 commit comments

Comments
 (0)