Commit 1b5b5412 authored by Jean Meurice's avatar Jean Meurice

Docker fix

parent b31ca4c7
......@@ -53,17 +53,7 @@ docker_branch_linux:
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
# clean up
# ignore error in case image not exists
- docker rmi montisim-server-builder || true
- docker rmi rpc-server || true
- docker rmi restful-server || true
# pull the latest RMIServer image
- docker pull registry.git.rwth-aachen.de/monticore/embeddedmontiarc/simulators/rmimodelserver:latest
- cd scripts/linux/docker
- ./build_server.sh
- ./run_test.sh
- ./run_integration_test.sh
- ./scripts/linux/docker/docker_ci.sh
# build, test and publish docker images
docker_master_linux:
......@@ -77,17 +67,7 @@ docker_master_linux:
before_script:
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
script:
# clean up
# ignore error in case image not exists
- docker rmi montisim-server-builder || true
- docker rmi rpc-server || true
- docker rmi restful-server || true
# pull the latest RMIServer image
- docker pull registry.git.rwth-aachen.de/monticore/embeddedmontiarc/simulators/rmimodelserver:latest
- cd scripts/linux/docker
- ./build_server.sh
- ./run_test.sh
- ./run_integration_test.sh
- ./scripts/linux/docker/docker_ci.sh
- docker tag rpc-server:latest $CI_REGISTRY_IMAGE:rpc
- docker tag restful-server:latest $CI_REGISTRY_IMAGE:restful
- docker push $CI_REGISTRY_IMAGE:rpc
......
......@@ -9,5 +9,5 @@ RUN apt-get update && \
COPY . .
RUN mvn install -s settings.xml -DskipTests && \
RUN mvn install -s settings.xml -DskipTests -ntp && \
mv rpc/target/rpc-jar-with-dependencies.jar rpc/target/rpc.jar
......@@ -21,7 +21,6 @@
<maven.compiler.target>1.8</maven.compiler.target>
<!-- .. Plugins ....................................................... -->
<assembly.plugin>2.5.4</assembly.plugin>
<compiler.plugin>3.3</compiler.plugin>
<source.plugin>2.4</source.plugin>
<shade.plugin>2.4.3</shade.plugin>
......
......@@ -241,6 +241,7 @@
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<archive>
<manifest>
......
......@@ -7,7 +7,10 @@
#
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$SCRIPTS_DIR/../../..
#Import print()
. $SCRIPTS_DIR/../print.sh
pushd $ROOT_DIR/restful
print "Building RESTful docker image..."
docker build -f "${ROOT_DIR}/docker/Dockerfile_restful" -t restful-server .
popd
\ No newline at end of file
......@@ -7,8 +7,11 @@
#
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$SCRIPTS_DIR/../../..
#Import print()
. $SCRIPTS_DIR/../print.sh
pushd $ROOT_DIR/rpc
print "Building RPC docker image..."
docker build -f "${ROOT_DIR}/docker/Dockerfile_rpc" -t rpc-server .
popd
......@@ -2,8 +2,11 @@
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$SCRIPTS_DIR/../../..
#Import print()
. $SCRIPTS_DIR/../print.sh
pushd $ROOT_DIR
print "Building montisim_server_builder docker image..."
docker build -f "${ROOT_DIR}/docker/Dockerfile_montisim_server_builder" -t montisim-server-builder .
popd
......
#!/usr/bin/env bash
[ -z "$(docker container ls | grep zookeeper)" ] && docker rm -f zookeeper
[ -z "$(docker container ls | grep autopilot)" ] && docker rm -f autopilot
[ -z "$(docker container ls | grep rpc-server)" ] && docker rm -f rpc-server
[ -z "$(docker network ls | grep $NETWORK_NAME)" ] && docker network rm $NETWORK_NAME
\ No newline at end of file
CLEANUP_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
. $CLEANUP_SCRIPT_DIR/../print.sh
print "Cleaning up containers and network"
if docker container ls -a | grep -q zookeeper; then docker rm -f zookeeper; fi
if docker container ls -a | grep -q autopilot; then docker rm -f autopilot; fi
if docker container ls -a | grep -q rpc-server; then docker rm -f rpc-server; fi
if docker network ls | grep -q $NETWORK_NAME; then docker network rm $NETWORK_NAME; fi
\ No newline at end of file
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$SCRIPTS_DIR/../../..
#Import print()
. $SCRIPTS_DIR/../print.sh
print "Docker CI script"
$SCRIPTS_DIR/full_cleanup.sh
docker pull registry.git.rwth-aachen.de/monticore/embeddedmontiarc/simulators/rmimodelserver:latest
$SCRIPTS_DIR/build_server.sh
$SCRIPTS_DIR/run_test.sh
$SCRIPTS_DIR/run_integration_test.sh
\ No newline at end of file
#!/usr/bin/env bash
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
#Import print()
. $SCRIPTS_DIR/../print.sh
NETWORK_NAME="simulation-network"
. $SCRIPTS_DIR/cleanup.sh
print "Full Cleanup"
print "Cleaning up images"
if docker image ls | grep -q montisim-server-builder; then docker rmi montisim-server-builder; fi
if docker image ls | grep -q rpc-server; then docker rmi rpc-server; fi
if docker image ls | grep -q restful-server; then docker rmi restful-server; fi
print "Stopping all docker containers"
docker stop $(docker ps -a -q)
print "Removing all docker images"
docker rm $(docker ps -a -q)
print "Pruning docker"
docker system prune -f
\ No newline at end of file
......@@ -7,9 +7,12 @@
#
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$SCRIPTS_DIR/../../..
#Import print()
. $SCRIPTS_DIR/../print.sh
NETWORK_NAME="simulation-network"
$SCRIPTS_DIR/cleanup.sh
. $SCRIPTS_DIR/cleanup.sh
# this script serves the purpose of running integration test in gitlab-runner.
# It starts all dependent services needed before starting the tests.
......@@ -18,10 +21,10 @@ $SCRIPTS_DIR/cleanup.sh
# - an autopilot at autopilot:10101
# - a zookeeper server at zookeeper:2181
# create network
print "Creating docker network"
docker network create $NETWORK_NAME
# start zookeeper
print "Starting zookeeper"
docker run \
--network="$NETWORK_NAME" \
-d \
......@@ -30,11 +33,11 @@ docker run \
zookeeper:latest
echo "waiting for zookeeper to start..."
print "Waiting for zookeeper to start..."
sleep 10
# start autopilot server(RMIServer)
print "Starting autopilot server (RMIServer)"
docker run \
--network="$NETWORK_NAME" \
--name=autopilot \
......@@ -43,6 +46,7 @@ docker run \
registry.git.rwth-aachen.de/monticore/embeddedmontiarc/simulators/rmimodelserver:latest \
bash -c "source ~/.bashrc && java -Djava.rmi.server.useLocalHostname -jar rmi-model-server.jar port=10101 softwares_folder=softwares"
print "Starting RPC-server"
docker run \
--network="$NETWORK_NAME" \
-d \
......@@ -57,15 +61,34 @@ sleep 5
pushd ${ROOT_DIR}
#docker build -t server-test-runner -f ./docker/TestDockerfile .
print "Running Integration Tests"
docker run \
--network="$NETWORK_NAME" \
-e "ZOO_SERVERS=zookeeper" \
montisim-server-builder \
bash -c "cd restful && mvn test -Dtest=IntegrationTest -s ../settings.xml"
bash -c "cd restful && mvn test -ntp -Dtest=IntegrationTest -s ../settings.xml"
code=$?
$SCRIPTS_DIR/cleanup.sh
if [ "$code" = "0" ]; then
print "Integration Test Successful"
else
print "Error Performing Integration Tests (code: $code)"
print "Zookeeper Log"
docker logs -t zookeeper
print "Autopilot Log"
docker logs -t autopilot
print "RPC-server Log"
docker logs -t rpc-server
fi
print "Stopping rpc-server"
docker stop rpc-server
print "Stopping autopilot"
docker stop autopilot
print "Stopping zookeeper"
docker stop zookeeper
. $SCRIPTS_DIR/cleanup.sh
echo Test Status: $code
exit $code
......@@ -7,6 +7,9 @@
#
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
ROOT_DIR=$SCRIPTS_DIR/../../..
#Import print()
. $SCRIPTS_DIR/../print.sh
NETWORK_NAME="simulation-network"
# this script serves the purpose of running unitetests in gitlab-runner.
......@@ -14,12 +17,13 @@ NETWORK_NAME="simulation-network"
# Including:
# - a zookeeper server at localhost:2181
$SCRIPTS_DIR/cleanup.sh
# create network
. $SCRIPTS_DIR/cleanup.sh
print "Creating docker network"
docker network create $NETWORK_NAME
# start zookeeper
print "Starting zookeeper"
docker run \
--network="$NETWORK_NAME" \
-d \
......@@ -27,19 +31,30 @@ docker run \
-e "ZOO_MAX_CLIENT_CNXNS=1024" \
zookeeper:latest
echo "waiting for zookeeper to start..."
print "Waiting for zookeeper to start..."
sleep 5
#docker build -t server-test-runner -f ./docker/TestDockerfile .
print "Running Unit Tests"
docker run \
--rm --network="$NETWORK_NAME" \
-e "ZOO_SERVERS=zookeeper" \
montisim-server-builder \
bash -c "source ~/.bashrc && pushd rpc && mvn test -s ../settings.xml && popd && cd restful && mvn test -Dtest=\!IntegrationTest* -s ../settings.xml"
bash -c "source ~/.bashrc && pushd rpc && mvn test -s ../settings.xml && popd && cd restful && mvn test -ntp -Dtest=\!IntegrationTest* -s ../settings.xml"
code=$?
$SCRIPTS_DIR/cleanup.sh
if [ "$code" = "0" ]; then
print "Unit Tests successful"
else
print "Error Performing Unit Tests (code: $code)"
print "Zookeeper Log"
docker logs -t zookeeper
fi
print "Stopping zookeeper"
docker stop zookeeper
. $SCRIPTS_DIR/cleanup.sh
echo Test Status: $code
exit $code
#!/bin/bash
#
# (c) https://github.com/MontiCore/monticore
#
# The license generally applicable for this project
# can be found under https://github.com/MontiCore/monticore.
#
# Use colors to identify scripts messages better:
CYAN='\033[1;36m'
NC='\033[0m' # No Color
function print {
echo -e "${CYAN}[SCRIPT] $@${NC}"
}
......@@ -5,7 +5,7 @@ set ROOT_DIR=%SCRIPTS_DIR%\..\..\..
set NETWORK_NAME="simulation-network"
::call %SCRIPTS_DIR%\cleanup.bat
call %SCRIPTS_DIR%\cleanup.bat
docker network create %NETWORK_NAME%
......@@ -27,5 +27,5 @@ set FAILURE=%errorlevel%
if %errorlevel% neq 0 (
echo Error Unit Testing
)
::call %SCRIPTS_DIR%\cleanup.bat
call %SCRIPTS_DIR%\cleanup.bat
exit /b %FAILURE%
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment