Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/CLD-420 #81

Merged
merged 3 commits into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 9 additions & 11 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// This Jenkinsfile defines internal MarkLogic build pipeline.

/* groovylint-disable CatchException, CompileStatic, DuplicateStringLiteral, LineLength, MethodName, MethodParameterTypeRequired, MethodReturnTypeRequired, NoDef, UnnecessaryGetter, UnusedVariable, VariableName, VariableTypeRequired */

//Shared library definitions: https://github.com/marklogic/MarkLogic-Build-Libs/tree/1.0-declarative/vars
@Library('[email protected]')
import groovy.json.JsonSlurperClassic
Expand Down Expand Up @@ -195,9 +193,9 @@ def StructureTests() {
sh """
cd test
#insert current version
sed -i -e 's/VERSION_PLACEHOLDER/${mlVersion}-${env.platformString}-${env.dockerVersion}/' ./structure-test.yml
sed -i -e 's/VERSION_PLACEHOLDER/${mlVersion}-${env.platformString}-${env.dockerVersion}/' ./structure-test.yaml
curl -s -LO https://storage.googleapis.com/container-structure-test/latest/container-structure-test-linux-amd64 && chmod +x container-structure-test-linux-amd64 && mv container-structure-test-linux-amd64 container-structure-test
./container-structure-test test --config ./structure-test.yml --image marklogic-centos/marklogic-server-centos:${mlVersion}-${env.platformString}-${env.dockerVersion} --output junit | tee container-structure-test.xml
./container-structure-test test --config ./structure-test.yaml --image marklogic-centos/marklogic-server-centos:${mlVersion}-${env.platformString}-${env.dockerVersion} --output junit | tee container-structure-test.xml
#fix junit output
sed -i -e 's/<\\/testsuites>//' -e 's/<testsuite>//' -e 's/<testsuites/<testsuite name="container-structure-test"/' ./container-structure-test.xml
"""
Expand Down Expand Up @@ -240,9 +238,9 @@ def DockerRunTests() {
testCases.each { key, value ->

echo "Running "+key+": "+value.description
// if .yml config is provided in params, start compose. otherwise docker run is used
if ( value.params.toString().contains(".yml")) {
//update image label in yml file
// if .yaml config is provided in params, start compose. otherwise docker run is used
if ( value.params.toString().contains(".yaml")) {
//update image label in yaml file
composeFile = readFile(composePath + value.params)
composeFile = composeFile.replaceFirst(/image: .*/, "image: "+testImage)
writeFile( file: composePath + value.params, text: composeFile)
Expand All @@ -257,7 +255,7 @@ def DockerRunTests() {

// TODO find a good way to skip the test on error from invalid params
// TODO: Find a way to check for server status instead of a wait. (log: Database Modules is online)
sleep(60)
sleep(80)

echo "-Unauthenticated requests"
value.expected.unauthenticated.each { test, verify ->
Expand All @@ -267,7 +265,7 @@ def DockerRunTests() {
} catch (e) {
cmdOutput = 'Curl retured error: '+e.message
}
testResults = testResults + '<testcase name="'+value.description+' on '+key+' without credentials"'
testResults = testResults + '<testcase name="'+value.description+' on '+key+' without credentials on port '+test+'"'
totalTests += 1
echo "--Port ${test}: "
if ( cmdOutput.contains(verify) ) {
Expand All @@ -287,7 +285,7 @@ def DockerRunTests() {
} catch (e) {
cmdOutput = 'Curl retured error: '+e.message
}
testResults = testResults + '<testcase name="'+value.description+' on '+key+' with credentials"'
testResults = testResults + '<testcase name="'+value.description+' on '+key+' with credentials on port '+test+'"'
totalTests += 1
echo "--Port ${test}: "
if ( cmdOutput.contains(verify) ) {
Expand All @@ -301,7 +299,7 @@ def DockerRunTests() {
sleep(1)
}
echo "-Deleting resources"
if ( value.params.toString().contains(".yml")) {
if ( value.params.toString().contains(".yaml")) {
sh( returnStdout: true, script: "docker compose -f ${composePath}${value.params} down" )
} else {
sh( returnStdout: true, script: "docker rm -f ${testCont}" )
Expand Down
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ The credentials for the admin user are configured using Docker secrets, and are
## Single node MarkLogic Server on a single VM
Single node configurations are used primarily on a development machine with a single user.

Create these files on your host machine: `marklogic-centos.yml`, `mldb_admin_username.txt`, and `mldb_admin_password.txt`. Run example Docker commands from the same directory where the files created.
Create these files on your host machine: `marklogic-centos.yaml`, `mldb_admin_username.txt`, and `mldb_admin_password.txt`. Run example Docker commands from the same directory where the files created.

**marklogic-centos.yml**
**marklogic-centos.yaml**

```
#Docker compose file sample to setup single node cluster
Expand Down Expand Up @@ -291,7 +291,7 @@ volumes:
Once the files are ready, run this command to start the MarkLogic Server container.

```
$ docker-compose -f marklogic-centos.yml up -d
$ docker-compose -f marklogic-centos.yaml up -d
```
The previous command starts a container running MarkLogic Server named "bootstrap".

Expand All @@ -305,9 +305,9 @@ After the container is initialized, you can access the MarkLogic Query Console o

## Three node cluster on a single VM

The following is an example of a three-node MarkLogic server cluster created using Docker compose. Create these files on your host machine: `marklogic-cluster-centos.yml`, `mldb_admin_username.txt`, and `mldb_admin_password.txt`. Run example Docker commands from the same directory where the files created.
The following is an example of a three-node MarkLogic server cluster created using Docker compose. Create these files on your host machine: `marklogic-cluster-centos.yaml`, `mldb_admin_username.txt`, and `mldb_admin_password.txt`. Run example Docker commands from the same directory where the files created.

**marklogic-cluster-centos.yml**
**marklogic-cluster-centos.yaml**

```
#Docker compose file sample to setup a three node cluster
Expand Down Expand Up @@ -406,7 +406,7 @@ volumes:
Once the files have been created, run the following command to start the MarkLogic Server container:

```
$ docker-compose -f marklogic-cluster-centos.yml up -d
$ docker-compose -f marklogic-cluster-centos.yaml up -d
```

This command will start three Docker containers running MarkLogic Server, named "bootstrap_3n", "node2" and, "node3".
Expand All @@ -423,7 +423,7 @@ As in the previous single-node example, each node of the cluster can be accessed

### Using ENV for admin credentials in Docker compose

In the previous examples, Docker secrets files were used to specify admin credentials for the MarkLogic Server. If your environment prevents the use of Docker secrets, you can use environmental variables. This approach is less secure, but it is commonly used in development environments. This is not recommended for production environments. In order to use these environment variables in the Docker compose files, remove the secrets section at the end of the Docker compose yml file, and remove the secrets section in each node. Then replace the MARKLOGIC_ADMIN_USERNAME_FILE/MARKLOGIC_ADMIN_PASSWORD_FILE variables with MARKLOGIC_ADMIN_USERNAME/MARKLOGIC_ADMIN_PASSWORD and provide the appropriate values.
In the previous examples, Docker secrets files were used to specify admin credentials for the MarkLogic Server. If your environment prevents the use of Docker secrets, you can use environmental variables. This approach is less secure, but it is commonly used in development environments. This is not recommended for production environments. In order to use these environment variables in the Docker compose files, remove the secrets section at the end of the Docker compose yaml file, and remove the secrets section in each node. Then replace the MARKLOGIC_ADMIN_USERNAME_FILE/MARKLOGIC_ADMIN_PASSWORD_FILE variables with MARKLOGIC_ADMIN_USERNAME/MARKLOGIC_ADMIN_PASSWORD and provide the appropriate values.

Using Docker secrets, username and password information are secured when transmitting the sensitive data from Docker host to Docker containers. To prevent any attacks, the login information is not available as an environment variable. However, these values are stored in a text file and persisted in an in-memory file system inside the container. We recommend that you delete the Docker secrets information once the cluster is up and running.

Expand All @@ -443,7 +443,7 @@ Using Docker secrets, username and password information are secured when transmi
```
$docker secret create mldb_admin_password_v1 mldb_admin_password_v1.txt
```
3. Create marklogic-multi-centos.yml using below:
3. Create marklogic-multi-centos.yaml using below:
```
version: '3.6'
services:
Expand Down Expand Up @@ -778,7 +778,7 @@ This section describes the teardown process for clusters set up on a single VM u
Resources such as containers, volumes, and networks that were created with compose command can be removed using this command:

```
$ docker-compose -f marklogic-centos.yml down
$ docker-compose -f marklogic-centos.yaml down
```

### Remove volumes
Expand Down
2 changes: 1 addition & 1 deletion src/centos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ lint:
# test docker images ** TBD **
#***************************************************************************
test:
${container_test_tool} test --image ${REPONAME}/marklogic-server-centos:${version} --config "test/test-marklogic-server-centos:${version}.yml"
${container_test_tool} test --image ${REPONAME}/marklogic-server-centos:${version} --config "test/test-marklogic-server-centos:${version}.yaml"

#***************************************************************************
# push docker images to mlregistry.marklogic.com
Expand Down
4 changes: 2 additions & 2 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
There are two types of tests: Docker structure tests and Docker image tests. Both are started by the pipeline.

## Docker Structure Tests
We use [container-structure-test](https://github.com/GoogleContainerTools/container-structure-testhttps:/) to validate the structure of our Docker images. Configuration file structure-test.yml defines the test cases for validation of image metadata, exposed ports, and essential files.
We use [container-structure-test](https://github.com/GoogleContainerTools/container-structure-testhttps:/) to validate the structure of our Docker images. Configuration file structure-test.yaml defines the test cases for validation of image metadata, exposed ports, and essential files.

Here is an example command to run the test:

`container-structure-test test --config ./structure-test.yml --image ml-docker-dev.marklogic.com/marklogic/marklogic-server-centos:10.0-8.1-centos-1.0.0-ea2`
`container-structure-test test --config ./structure-test.yaml --image ml-docker-dev.marklogic.com/marklogic/marklogic-server-centos:10.0-8.1-centos-1.0.0-ea2`


## Docker Image Tests
Expand Down
8 changes: 4 additions & 4 deletions test/docker-test-cases.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
},
"docker-2": {
"description": "Initialized MarkLogic Server",
"params": "-e MARKLOGIC_INIT=false -e MARKLOGIC_ADMIN_USERNAME=test_admin -e MARKLOGIC_ADMIN_PASSWORD=test_admin_pass",
"params": "-e MARKLOGIC_INIT=true -e MARKLOGIC_ADMIN_USERNAME=test_admin -e MARKLOGIC_ADMIN_PASSWORD=test_admin_pass",
"expected": {
"unauthenticated": {
"8000": "401 Unauthorized",
Expand All @@ -33,7 +33,7 @@
},
"docker-3": {
"description": "Initialized MarkLogic Server with License Key",
"params": "-e MARKLOGIC_INIT=false -e MARKLOGIC_ADMIN_USERNAME=test_admin -e MARKLOGIC_ADMIN_PASSWORD=test_admin_pass -e LICENSE_PLACEHOLDER -e INSTALL_CONVERTERS=false",
"params": "-e MARKLOGIC_INIT=true -e MARKLOGIC_ADMIN_USERNAME=test_admin -e MARKLOGIC_ADMIN_PASSWORD=test_admin_pass -e LICENSE_PLACEHOLDER -e INSTALL_CONVERTERS=false",
"expected": {
"unauthenticated": {
"8000": "401 Unauthorized",
Expand Down Expand Up @@ -65,7 +65,7 @@
},
"compose-1": {
"description": "Compose single node",
"params": "marklogic-centos.yml",
"params": "marklogic-centos.yaml",
"expected": {
"unauthenticated": {
"8000": "401 Unauthorized",
Expand All @@ -81,7 +81,7 @@
},
"compose-2": {
"description": "Compose three node",
"params": "marklogic-cluster-centos.yml",
"params": "marklogic-cluster-centos.yaml",
"expected": {
"unauthenticated": {
"7100": "401 Unauthorized",
Expand Down