-
Notifications
You must be signed in to change notification settings - Fork 141
111 lines (87 loc) · 3.11 KB
/
server-upgrade-test.yml
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
name: Server upgrade
on: workflow_call
env:
DS_IMAGE: ${{ vars.DS_IMAGE || 'quay.io/389ds/dirsrv' }}
jobs:
test:
name: Test
runs-on: ubuntu-latest
env:
SHARED: /tmp/workdir/pki
steps:
- name: Clone repository
uses: actions/checkout@v4
- name: Retrieve PKI images
uses: actions/cache@v4
with:
key: pki-images-${{ github.sha }}
path: pki-images.tar
- name: Load PKI images
run: docker load --input pki-images.tar
- name: Create network
run: docker network create example
- name: Set up server container
run: |
tests/bin/runner-init.sh pki
env:
HOSTNAME: pki.example.com
- name: Connect server container to network
run: docker network connect example pki --alias pki.example.com
- name: Add upgrade script
run: |
MAJOR_VERSION=$(sed -n 's/^%global *major_version *\(.*\)$/\1/p' pki.spec)
MINOR_VERSION=$(sed -n 's/^%global *minor_version *\(.*\)$/\1/p' pki.spec)
UPDATE_VERSION=$(sed -n 's/^%global *update_version *\(.*\)$/\1/p' pki.spec)
VERSION=$MAJOR_VERSION.$MINOR_VERSION.$UPDATE_VERSION
echo "VERSION: $VERSION"
UPGRADE_DIR=/usr/share/pki/server/upgrade/$VERSION
echo "UPGRADE_DIR: $UPGRADE_DIR"
docker exec pki mkdir -p $UPGRADE_DIR
docker exec pki ls $UPGRADE_DIR | tee output
LAST_SCRIPT=$(tail -1 output)
echo "LAST_SCRIPT: $LAST_SCRIPT"
LAST_INDEX=$(echo "$LAST_SCRIPT" | sed 's/^\([0-9]*\).*$/\1/')
echo "LAST_INDEX: $LAST_INDEX"
if [ -z "$LAST_INDEX" ];then
INDEX="01"
else
INDEX=$((LAST_INDEX + 1))
if [ "$INDEX" -lt "10" ];then
INDEX="0$INDEX"
fi
fi
echo "INDEX: $INDEX"
docker exec pki cp \
/usr/share/pki/server/examples/upgrade/01-BasicUpgradeScript.py \
$UPGRADE_DIR/$INDEX-BasicUpgradeScript.py
docker exec pki ls $UPGRADE_DIR
- name: Run upgrade without any servers
run: |
docker exec pki pki-server upgrade -v | tee output
# verify that the upgrade script was not executed
grep "BasicUpgradeScript" output | tee actual
[ ! -s actual ]
- name: Create PKI server
run: |
docker exec pki pki-server create -v
- name: Run upgrade with one server
run: |
docker exec pki pki-server upgrade -v | tee output
# verify that the upgrade script was executed
grep "BasicUpgradeScript:" output | tee actual
[ -s actual ]
- name: Remove PKI server
run: |
docker exec pki pki-server remove -v
- name: Gather artifacts
if: always()
run: |
tests/bin/pki-artifacts-save.sh pki
continue-on-error: true
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: server-upgrade-test
path: |
/tmp/artifacts/pki