Skip to content

Commit 534b1c0

Browse files
MLE-11923 update docker tests (#246)
* Add condition to skip tests that are not applicable to rootless * update params and add image_type * Update pipeline to handle new test parameters * update .gitignore to skip python_env * add ignore yum version req to docker linter * remove sudo requirement for CST install * switch docker ver to ML ver for structure tests * downgrade hadolint warning and add dnf to it * fix ML version for structure test.. again. * fix hadlint rules * Added tests to verify timezone change in the container. change tab zize to 4 for readability. * randomize docker test execution * add image type to build number * remove unused links and add tzdata reinstall * remove extra space * Update steps to verify time zone via REST * add a note about rootless image * add timezone set to ubi image
1 parent b377c11 commit 534b1c0

11 files changed

+594
-488
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ test/test_results/*
2727
test/log.html
2828
test/report.html
2929
test/output.xml
30+
test/python_env/*

Jenkinsfile

+6-11
Original file line numberDiff line numberDiff line change
@@ -157,24 +157,19 @@ void copyRPMs() {
157157

158158
void buildDockerImage() {
159159
sh "make build docker_image_type=${dockerImageType} version=${mlVersion}-${env.dockerImageType}-${env.dockerVersion} build_branch=${env.BRANCH_NAME} package=${RPM} converters=${CONVERTERS}"
160+
currentBuild.displayName = "#${BUILD_NUMBER} ${mlVersion}-${env.dockerImageType}-${env.dockerVersion}"
160161
}
161162

162163
void structureTests() {
163164
sh """
164-
cd test
165-
#insert current version
166-
sed -i -e 's^VERSION_PLACEHOLDER^${mlVersion}-${env.dockerImageType}-${env.dockerVersion}^g' -e 's^BRANCH_PLACEHOLDER^${env.BRANCH_NAME}^g' ./structure-test.yaml
167-
cd ..
168-
#install container-structure-test binary
169-
curl -s -LO https://storage.googleapis.com/container-structure-test/v1.11.0/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && mv container-structure-test-linux-amd64 container-structure-test
170-
make structure-test current_image=marklogic/marklogic-server-${dockerImageType}:${mlVersion}-${env.dockerImageType}-${env.dockerVersion} Jenkins=true
171-
#fix junit output
172-
sed -i -e 's/<\\/testsuites>//' -e 's/<testsuite>//' -e 's/<testsuites/<testsuite name="container-structure-test"/' ./container-structure-test.xml
165+
#install container-structure-test 1.16.0 binary
166+
curl -s -LO https://storage.googleapis.com/container-structure-test/v1.16.0/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && mv container-structure-test-linux-amd64 container-structure-test
167+
make structure-test current_image=marklogic/marklogic-server-${dockerImageType}:${mlVersion}-${env.dockerImageType}-${env.dockerVersion} version=${mlVersion}-${env.dockerImageType}-${env.dockerVersion} build_branch=${env.BRANCH_NAME} docker_image_type=${env.dockerImageType} Jenkins=true
173168
"""
174169
}
175170

176171
void dockerTests() {
177-
sh "make docker-tests current_image=marklogic/marklogic-server-${dockerImageType}:${mlVersion}-${env.dockerImageType}-${env.dockerVersion} version=${mlVersion}-${env.dockerImageType}-${env.dockerVersion} build_branch=${env.BRANCH_NAME}"
172+
sh "make docker-tests current_image=marklogic/marklogic-server-${dockerImageType}:${mlVersion}-${env.dockerImageType}-${env.dockerVersion} version=${mlVersion}-${env.dockerImageType}-${env.dockerVersion} build_branch=${env.BRANCH_NAME} docker_image_type=${dockerImageType}"
178173
}
179174

180175
void lint() {
@@ -232,7 +227,7 @@ void publishToInternalRegistry() {
232227
}
233228
}
234229

235-
currentBuild.description = "Publish ${mlVersion}-${env.dockerImageType}-${env.dockerVersion}"
230+
currentBuild.description = "Published"
236231
}
237232

238233
void publishTestResults() {

Makefile

+10-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ endif
2121
# strcture test docker images
2222
#***************************************************************************
2323
structure-test:
24+
ifeq ($(docker_image_type),ubi-rootless)
25+
@echo type is ${docker_image_type}
26+
sed -i -e 's^DOCKER_PID_PLACEHOLDER^/home/marklogic_user/MarkLogic.pid^g' ./test/structure-test.yaml
27+
else
28+
@echo type is ${docker_image_type}
29+
sed -i -e 's^DOCKER_PID_PLACEHOLDER^/var/run/MarkLogic.pid^g' ./test/structure-test.yaml
30+
endif
31+
sed -i -e 's^VERSION_PLACEHOLDER^${version}^g' ./test/structure-test.yaml
32+
sed -i -e 's^BRANCH_PLACEHOLDER^${build_branch}^g' ./test/structure-test.yaml
2433
container-structure-test test --config ./test/structure-test.yaml --image ${current_image} \
2534
$(if $(Jenkins), --output junit | tee container-structure-test.xml,)
2635

@@ -29,7 +38,7 @@ structure-test:
2938
#***************************************************************************
3039
docker-tests:
3140
cd test; python3 -m venv python_env
32-
cd test; source ./python_env/bin/activate; pip3 install -r requirements.txt; robot -x docker-tests.xml --outputdir test_results --variable TEST_IMAGE:${current_image} --variable MARKLOGIC_VERSION:${version} --variable BUILD_BRANCH:${build_branch} --maxerrorlines 9999 ./docker-tests.robot; deactivate
41+
cd test; source ./python_env/bin/activate; pip3 install -r requirements.txt; robot -x docker-tests.xml --outputdir test_results --randomize all --variable TEST_IMAGE:${current_image} --variable MARKLOGIC_VERSION:${version} --variable BUILD_BRANCH:${build_branch} --variable IMAGE_TYPE:${docker_image_type} --maxerrorlines 9999 ./docker-tests.robot; deactivate
3342
rm -r test/python_env/
3443

3544
#***************************************************************************

dockerFiles/marklogic-server-ubi-rootless:base

+2-2
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ ENV MARKLOGIC_INSTALL_DIR=/opt/MarkLogic \
123123
################################################################
124124
# Set Timezone
125125
################################################################
126-
RUN microdnf reinstall -y tzdata \
127-
&& ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
126+
127+
RUN microdnf -y reinstall tzdata
128128

129129
################################################################
130130
# Set appropriate authorisation to MARKLOGIC_DATA_DIR

dockerFiles/marklogic-server-ubi:base

+5
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ ENV MARKLOGIC_INSTALL_DIR=/opt/MarkLogic \
9898
BUILD_BRANCH=${BUILD_BRANCH} \
9999
MARKLOGIC_JOIN_TLS_ENABLED=false
100100

101+
################################################################
102+
# Set Timezone
103+
################################################################
104+
105+
RUN microdnf -y reinstall tzdata
101106

102107
###############################################################
103108
# expose MarkLogic server ports

hadolint.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
11
failure-threshold: error
2+
ignored:
3+
- DL3033
4+
- DL3041

src/scripts/start-marklogic-rootless.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ fi
6464

6565
[[ "${MARKLOGIC_PID_FILE}" ]] && echo "export MARKLOGIC_PID_FILE=$MARKLOGIC_PID_FILE" >>/etc/marklogic.conf
6666
[[ "${MARKLOGIC_UMASK}" ]] && echo "export MARKLOGIC_UMASK=$MARKLOGIC_UMASK" >>/etc/marklogic.conf
67-
[[ "${TZ}" ]] && echo "export TZ=$TZ " >>/etc/marklogic.conf
67+
[[ "${TZ}" ]] && echo "export TZ=$TZ" >>/etc/marklogic.conf
6868
[[ "${ML_HUGEPAGES_TOTAL}" ]] && echo "export ML_HUGEPAGES_TOTAL=$ML_HUGEPAGES_TOTAL" >>/etc/marklogic.conf
6969
[[ "${MARKLOGIC_DISABLE_JVM}" ]] && echo "export MARKLOGIC_DISABLE_JVM=$MARKLOGIC_DISABLE_JVM" >>/etc/marklogic.conf
7070
[[ "${MARKLOGIC_USER}" ]] && echo "export MARKLOGIC_USER=$MARKLOGIC_USER" >>/etc/marklogic.conf

test/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ In order to run all tests you can use make from root folder with
3434
or by running Robot in test directly with
3535
`robot ./docker-tests.robot`
3636

37+
*Note*
3738
QA_LICENSE_KEY environment variable needs to be set to a valid license key for license test to pass.
39+
If UBI rootless image is used, specify image type for individual tests:
40+
`robot --variable TEST_IMAGE:marklogic/marklogic-server-ubi-rootless:internal --variable IMAGE_TYPE:ubi-rootless --test 'Initialized MarkLogic container with config overrides' docker-tests.robot`
3841

3942
For a quick start guide for Robot framework see https://robotframework.org/#getting-started
4043
Full user guide is available at https://robotframework.org/robotframework/#user-guide

0 commit comments

Comments
 (0)