-
Notifications
You must be signed in to change notification settings - Fork 16
189 lines (185 loc) · 7.44 KB
/
tests.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
---
name: Integration tests with Kind and DevStack
on: [pull_request]
jobs:
lint:
name: "Linters (go v${{ matrix.go-version }})"
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.20' ]
steps:
- name: Checkout velero-plugin-for-openstack
uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Check formatting
run: |
test -z $(gofmt -l -s ./)
- name: Check go vet
run: |
go vet ./...
- name: Verify dependencies
run: |
go mod verify
- name: Check if plugin can be built
run: |
go build -v .
unit-test:
name: "Unit tests (go v${{ matrix.go-version }})"
needs: lint
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.20' ]
steps:
- name: Checkout velero-plugin-for-openstack
uses: actions/checkout@v4
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Run unit tests
run: |
go test -v ./...
integration-test:
name: "Integration tests (go v${{ matrix.go-version }})"
needs: unit-test
runs-on: ubuntu-22.04
strategy:
matrix:
go-version: [ '1.20' ]
env:
VELERO_CLI_VERSION: 1.11.0
# Contains Velero 1.11.0
VELERO_CHART_VERSION: 4.0.1
VELERO_RESTORE_NAME: my-test-restore-01
VELERO_BACKUP_NAME: my-test-backup-01
# From tag 1.27.x
CINDER_CSI_CHART_VERSION: 2.27.3
MANILA_CSI_CHART_VERSION: 2.27.3
DOCKER_IMAGE_NAME: velero-plugin-for-openstack
SWIFT_CONTAINER_NAME: my-swift-container
TESTS_DIRECTORY: tests/actions/integration-tests
steps:
- name: Checkout velero-plugin-for-openstack
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Setup Go ${{ matrix.go-version }}
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
- name: Build Docker image
run: |
docker buildx build \
--file docker/Dockerfile \
--tag "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" \
--build-arg VERSION=${GITHUB_REF_NAME} \
--build-arg GIT_SHA=${GITHUB_SHA} \
--platform linux/amd64 \
--load \
.
- name: Install Kind
uses: helm/[email protected]
with:
# Kubernetes 1.27.x
version: v0.20.0
cluster_name: kind
wait: 120s
- name: Load new velero-plugin-for-openstack image to kind cluster
run: |
kind load docker-image "${DOCKER_IMAGE_NAME}:${GITHUB_SHA}"
- name: Install Helm
uses: azure/setup-helm@v3
with:
version: 'v3.14.1'
- name: Install Velero CLI
run: |
wget --quiet "https://github.com/vmware-tanzu/velero/releases/download/v${VELERO_CLI_VERSION}/velero-v${VELERO_CLI_VERSION}-linux-amd64.tar.gz"
tar -zxvf "velero-v${VELERO_CLI_VERSION}-linux-amd64.tar.gz"
sudo mv "velero-v${VELERO_CLI_VERSION}-linux-amd64/velero" /usr/local/bin/velero
chmod 750 /usr/local/bin/velero
- name: Deploy DevStack
uses: EmilienM/[email protected]
with:
branch: 'stable/2023.2'
enable_workaround_docker_io: 'false'
conf_overrides: |
SWIFT_ENABLE_TEMPURLS=True
SWIFT_TEMPURL_KEY=secretkey
SWIFT_HASH=12394u39845623984j28hf93d9173
SWIFT_DEFAULT_BIND_PORT=15492
SERVICE_TIMEOUT=200
enable_service key rabbit mysql s-proxy s-object s-container s-account c-bak c-api c-vol c-sch n-api n-crt n-cpu n-cond n-sch n-api-meta n-sproxy placement-api placement-client
CINDER_ISCSI_HELPER=tgtadm
enable_plugin manila https://github.com/openstack/manila stable/2023.2
# LVM Backend config options
MANILA_SERVICE_IMAGE_ENABLED=False
SHARE_DRIVER=manila.share.drivers.lvm.LVMShareDriver
MANILA_ENABLED_BACKENDS=chicago,denver
MANILA_BACKEND1_CONFIG_GROUP_NAME=chicago
MANILA_BACKEND2_CONFIG_GROUP_NAME=denver
MANILA_SHARE_BACKEND1_NAME=CHICAGO
MANILA_SHARE_BACKEND2_NAME=DENVER
MANILA_OPTGROUP_chicago_driver_handles_share_servers=False
MANILA_OPTGROUP_denver_driver_handles_share_servers=False
SHARE_BACKING_FILE_SIZE=32000M
MANILA_DEFAULT_SHARE_TYPE_EXTRA_SPECS='snapshot_support=True create_share_from_snapshot_support=True revert_to_snapshot_support=True mount_snapshot_support=True'
MANILA_CONFIGURE_DEFAULT_TYPES=True
MANILA_INSTALL_TEMPEST_PLUGIN_SYSTEMWIDE=false
- name: Prepare Swift container for velero backups
run: |
source "${{ github.workspace }}/devstack/openrc"
SWIFT_TMP_URL_KEY=$(dd if=/dev/urandom | tr -dc A-Za-z0-9 | head -c 40)
swift post "${SWIFT_CONTAINER_NAME}"
swift post -m "Temp-URL-Key:${SWIFT_TMP_URL_KEY}"
- name: Install Velero helm chart
run: |
export HOST_IP=$(hostname -I | awk '{print $1}')
export OS_AUTH_URL=$(echo -n "http://${HOST_IP}/identity" | base64)
envsubst < "${TESTS_DIRECTORY}/velero-credentials.yaml" > "${TESTS_DIRECTORY}/velero-credentials-templated.yaml"
kubectl create namespace velero
kubectl apply -f "${TESTS_DIRECTORY}/velero-credentials-templated.yaml"
helm repo add vmware-tanzu https://vmware-tanzu.github.io/helm-charts
helm repo update
helm install velero vmware-tanzu/velero \
--namespace velero \
--version "${VELERO_CHART_VERSION}" \
--values "${TESTS_DIRECTORY}/velero-helm-values.yaml" \
--set "initContainers[0].image=${DOCKER_IMAGE_NAME}:${GITHUB_SHA}" \
--timeout 10m \
--wait \
--wait-for-jobs
- name: Create test backup and validate it
run: |
# Create Cinder/Manila PVC
# Checks
velero backup-location get
velero snapshot-location get
# Do backup
velero backup create --storage-location swift "${VELERO_BACKUP_NAME}"
sleep 120
kubectl logs -n velero -l app.kubernetes.io/name=velero
velero describe backups "${VELERO_BACKUP_NAME}"
velero backup logs "${VELERO_BACKUP_NAME}"
if ! velero describe backups "${VELERO_BACKUP_NAME}" | grep -q "^Phase:.*Completed"; then
echo "Backup ${VELERO_BACKUP_NAME} failed";
exit 1
else
echo "Backup ${VELERO_BACKUP_NAME} was successful";
fi
# Do restore
velero restore create "${VELERO_RESTORE_NAME}" --from-backup "${VELERO_BACKUP_NAME}"
sleep 120
kubectl logs -n velero -l app.kubernetes.io/name=velero
velero describe restore "${VELERO_RESTORE_NAME}"
velero restore logs "${VELERO_RESTORE_NAME}"
if ! velero describe restore "${VELERO_RESTORE_NAME}" | grep -q "^Phase:.*Completed"; then
echo "Restore ${VELERO_RESTORE_NAME} failed";
exit 1
else
echo "Restore ${VELERO_RESTORE_NAME} was successful";
fi