File tree Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Expand file tree Collapse file tree 3 files changed +88
-0
lines changed Original file line number Diff line number Diff line change
1
+ Some simple test scripts to check the image is built and running the correct version. Used during release
2
+ Run from the project root directory
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ VERSION=$1
4
+ DIRECTORY=$2
5
+
6
+ echo " Building image mysql/mysql-server:$VERSION "
7
+ docker build -t mysql/mysql-server:$VERSION $DIRECTORY
8
+ RES=$?
9
+ if [ $RES -eq 0 ];
10
+ then
11
+ echo " Image built"
12
+ else
13
+ echo " Image build failed"
14
+ exit 0
15
+ fi
16
+
17
+
18
+ IMAGELIST=$( docker images | grep $VERSION )
19
+ docker rmi " mysql/mysql-server:$VERSION " || :
20
+ versionregex=" mysql/mysql-server $VERSION "
21
+ if [[ $IMAGELIST =~ $versionregex ]];
22
+ then
23
+ echo " Test passed"
24
+ exit 0
25
+ else
26
+ echo " Test failed. Image not in list"
27
+ exit 1
28
+ fi
29
+
30
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ VERSION=" $1 "
4
+ SERVERSTART=0
5
+ SERVERCONNECT=0
6
+ SUCCESS=false
7
+ echo " Starting image with MySQL version $VERSION "
8
+ docker run -e MYSQL_ROOT_PASSWORD=rot --name=testserver -p 3306:3306 -d mysql/mysql-server:$VERSION
9
+ RES=$?
10
+ if [ ! $RES = 0 ]; then
11
+ echo " Server start failed with error code $RES "
12
+ else
13
+ SERVERSTART=1
14
+ fi
15
+ echo " Connecting to server..."
16
+ if [ $SERVERSTART ];
17
+ then
18
+ for i in $( seq 30 -1 0) ; do
19
+ OUTPUT=" $( mysql -uroot -prot -h127.0.0.1 -P3306 < ' test/sql_version.sql' ) "
20
+ RES=$?
21
+ if [ $RES -eq 0 ]; then
22
+ SERVERCONNECT=1
23
+ break
24
+ fi
25
+ sleep 1
26
+ done
27
+ if [ $i = 0 ]; then
28
+ echo >&2 " Unable to connect to server."
29
+ fi
30
+ fi
31
+
32
+ if [ $SERVERCONNECT ];
33
+ then
34
+ versionregex=" version $VERSION "
35
+ if [[ $OUTPUT =~ $versionregex ]];
36
+ then
37
+ echo " Version check ok"
38
+ SUCCESS=true
39
+ else
40
+ echo " Expected to see version $VERSION . Actual output: $OUTPUT "
41
+ fi
42
+ fi
43
+
44
+ echo " Running cleanup."
45
+ docker kill testserver
46
+ docker rm testserver
47
+ echo " Cleanup complete."
48
+ if [ $SUCCESS == true ];
49
+ then
50
+ echo " Test passed"
51
+ exit 0
52
+ else
53
+ echo " Test failed"
54
+ exit 1
55
+ fi
56
+
You can’t perform that action at this time.
0 commit comments