From 2e5b31f75cbfadf63ad02e991e190434def48364 Mon Sep 17 00:00:00 2001 From: Will Abson Date: Tue, 10 Nov 2020 19:08:54 +0000 Subject: [PATCH 1/3] Add .travis.yml Refs ACS-129 --- .travis.yml | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..bf03583 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,96 @@ +# Auto-generated .travis.yml file +# Generated 2020-11-10 18:58:29 from Bamboo build plan BENCHMARK-BMMANAGER + +language: java + +jvm: + - oraclejdk8 + +addons: + artifacts: true + +stages: + - name: Default Stage + - name: Release + if: fork = false AND (branch = master OR branch =~ /support\/.*/) AND type != pull_request AND commit_message !~ /\[no-release\]/ + +jobs: + include: + - stage: "Default Stage" + name: "Build and Unit Test" + script: + # Clean up old images + - | + sh -c "$(cat <<'EOF' + #!/bin/bash + + echo + echo docker images + docker images + echo + echo docker ps + docker ps + echo + echo docker ps --all + docker ps --all + + docker_images=$(docker images | grep 'alfresco-bm') + docker_images_list=$(docker images | grep 'alfresco-bm'| awk '{print $3}' | uniq) + echo "Docker images: $docker_images" + + if [ "$docker_images_list" == "" ]; then + echo "No docker images on the agent" + else + echo "Clearing images: $docker_images_list" + docker rmi -f $docker_images_list + fi + EOF + )" + # Extract version from pom file + - export MAVEN_GROUPID=`echo '${project.groupId}' | mvn help:evaluate --non-recursive | grep -v "^\\["` + - export MAVEN_ARTIFACTID=`echo '${project.groupId}' | mvn help:evaluate --non-recursive | grep -v "^\\["` + - export MAVEN_VERSION=`echo '${project.groupId}' | mvn help:evaluate --non-recursive | grep -v "^\\["` + # Create image tag name + - | + sh -c "$(cat <<'EOF' + branch_name=${TRAVIS_BRANCH}; + build_profile='Pinternal' + + mkdir server/target + touch server/target/bamboo-variables.properties; + + echo "The branch is $branch_name" + echo "Project version: ${MAVEN_VERSION}" + if [ $branch_name = "master" ]; + then + tag_name='latest' + build_profile='Pmaster' + else + # substitude all '/' to '-' as Docker doesn't allow it + tag_name=`echo $branch_name | tr / - `; + tag_name=$tag_name-${MAVEN_VERSION} + fi + + echo "Saving tag name as $tag_name" + echo "Saving fabric8 profile as $build_profile" + + # save variable in a text file + echo "tag=$tag_name" > server/target/bamboo-variables.properties + echo "profile=$build_profile" >> server/target/bamboo-variables.properties + EOF + )" + # Inject image tag variable + - cat "server/target/bamboo-variables.properties" | sed -e "s/^/export bamboo.inject./g" -e "s/\\./_/g" > "$TMPDIR/bamboo-inject.properties" + - source "$TMPDIR/bamboo-inject.properties" + # Build packaging and Unit Test + - mvn clean install "-Dimage.tag=${INJECT_TAG}" -${INJECT_PROFILE} + after_script: + - artifacts upload target/README.txt + # Stage: release artifact and image + - stage: "Release" + name: "Release" + script: + # Release Benchmark Manager + - GIT_AUTHOR_NAME=alfresco-build GIT_AUTHOR_EMAIL=build@alfresco.com GIT_COMMITTER_NAME=alfresco-build GIT_COMMITTER_EMAIL=build@alfresco.com mvn --batch-mode -DreleaseVersion=${RELEASE_VERSION} -DdevelopmentVersion=${DEVELOPMENT_VERSION} "-Darguments=-DskipTests" -Prelease release:prepare release:perform + after_script: + - artifacts upload target/README.txt From aeea4b8dbcf21bdad960f0f54637c8dc5e75c3de Mon Sep 17 00:00:00 2001 From: Will Abson Date: Wed, 11 Nov 2020 06:31:04 +0000 Subject: [PATCH 2/3] Update .travis.yml Block indentation and add dist --- .travis.yml | 108 ++++++++++++++++++++++++++-------------------------- 1 file changed, 55 insertions(+), 53 deletions(-) diff --git a/.travis.yml b/.travis.yml index bf03583..396ecac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,13 @@ # Auto-generated .travis.yml file -# Generated 2020-11-10 18:58:29 from Bamboo build plan BENCHMARK-BMMANAGER +# Generated 2020-11-11 06:31:05 from Bamboo build plan BENCHMARK-BMMANAGER language: java jvm: - oraclejdk8 +dist: xenial + addons: artifacts: true @@ -21,64 +23,64 @@ jobs: script: # Clean up old images - | - sh -c "$(cat <<'EOF' - #!/bin/bash - - echo - echo docker images - docker images - echo - echo docker ps - docker ps - echo - echo docker ps --all - docker ps --all - - docker_images=$(docker images | grep 'alfresco-bm') - docker_images_list=$(docker images | grep 'alfresco-bm'| awk '{print $3}' | uniq) - echo "Docker images: $docker_images" - - if [ "$docker_images_list" == "" ]; then - echo "No docker images on the agent" - else - echo "Clearing images: $docker_images_list" - docker rmi -f $docker_images_list - fi - EOF - )" + sh -c "$(cat <<'EOF' + #!/bin/bash + + echo + echo docker images + docker images + echo + echo docker ps + docker ps + echo + echo docker ps --all + docker ps --all + + docker_images=$(docker images | grep 'alfresco-bm') + docker_images_list=$(docker images | grep 'alfresco-bm'| awk '{print $3}' | uniq) + echo "Docker images: $docker_images" + + if [ "$docker_images_list" == "" ]; then + echo "No docker images on the agent" + else + echo "Clearing images: $docker_images_list" + docker rmi -f $docker_images_list + fi + EOF + )" # Extract version from pom file - export MAVEN_GROUPID=`echo '${project.groupId}' | mvn help:evaluate --non-recursive | grep -v "^\\["` - export MAVEN_ARTIFACTID=`echo '${project.groupId}' | mvn help:evaluate --non-recursive | grep -v "^\\["` - export MAVEN_VERSION=`echo '${project.groupId}' | mvn help:evaluate --non-recursive | grep -v "^\\["` # Create image tag name - | - sh -c "$(cat <<'EOF' - branch_name=${TRAVIS_BRANCH}; - build_profile='Pinternal' - - mkdir server/target - touch server/target/bamboo-variables.properties; - - echo "The branch is $branch_name" - echo "Project version: ${MAVEN_VERSION}" - if [ $branch_name = "master" ]; - then - tag_name='latest' - build_profile='Pmaster' - else - # substitude all '/' to '-' as Docker doesn't allow it - tag_name=`echo $branch_name | tr / - `; - tag_name=$tag_name-${MAVEN_VERSION} - fi - - echo "Saving tag name as $tag_name" - echo "Saving fabric8 profile as $build_profile" - - # save variable in a text file - echo "tag=$tag_name" > server/target/bamboo-variables.properties - echo "profile=$build_profile" >> server/target/bamboo-variables.properties - EOF - )" + sh -c "$(cat <<'EOF' + branch_name=${TRAVIS_BRANCH}; + build_profile='Pinternal' + + mkdir server/target + touch server/target/bamboo-variables.properties; + + echo "The branch is $branch_name" + echo "Project version: ${MAVEN_VERSION}" + if [ $branch_name = "master" ]; + then + tag_name='latest' + build_profile='Pmaster' + else + # substitude all '/' to '-' as Docker doesn't allow it + tag_name=`echo $branch_name | tr / - `; + tag_name=$tag_name-${MAVEN_VERSION} + fi + + echo "Saving tag name as $tag_name" + echo "Saving fabric8 profile as $build_profile" + + # save variable in a text file + echo "tag=$tag_name" > server/target/bamboo-variables.properties + echo "profile=$build_profile" >> server/target/bamboo-variables.properties + EOF + )" # Inject image tag variable - cat "server/target/bamboo-variables.properties" | sed -e "s/^/export bamboo.inject./g" -e "s/\\./_/g" > "$TMPDIR/bamboo-inject.properties" - source "$TMPDIR/bamboo-inject.properties" From 8ed46522cc82e360febec901d543455ba735d943 Mon Sep 17 00:00:00 2001 From: Will Abson Date: Wed, 11 Nov 2020 19:46:33 +0000 Subject: [PATCH 3/3] Add integration tests Add additional tests from BENCHMARK-BMINT plan --- .travis.yml | 179 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) diff --git a/.travis.yml b/.travis.yml index 396ecac..a66de68 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,6 +13,7 @@ addons: stages: - name: Default Stage + - name: Integration Tests - name: Release if: fork = false AND (branch = master OR branch =~ /support\/.*/) AND type != pull_request AND commit_message !~ /\[no-release\]/ @@ -88,6 +89,184 @@ jobs: - mvn clean install "-Dimage.tag=${INJECT_TAG}" -${INJECT_PROFILE} after_script: - artifacts upload target/README.txt + - stage: "Integration Tests" + name: "BMF Docker Tests" + before_script: + # Checkout Default Repository + - git clone git@github.com:Alfresco/acs-packaging.git alfresco-packaging + script: + # Clean up old images + - | + sh -c "$(cat <<'EOF' + #!/bin/bash + + echo + echo docker images + docker images + echo + echo docker ps + docker ps + echo + echo docker ps --all + docker ps --all + + echo "Stopping and removing containers" + docker stop $(docker ps -aq) + docker rm $(docker ps -aq) + + docker_images=$(docker images | grep 'alfresco-bm') + docker_images_list=$(docker images | grep 'alfresco-bm'| awk '{print $3}' | uniq) + echo "Docker images: $docker_images" + + if [ "$docker_images_list" == "" ]; then + echo "No docker images on the agent" + else + echo "Clearing images: $docker_images_list" + docker rmi -f $docker_images_list + fi + EOF + )" + # Get agent ip address + - | + sh -c "$(cat <<'EOF' + mkdir alfresco-bm-manager/target + touch alfresco-bm-manager/target/bamboo-variables.properties; + + ip_address=$(hostname -I | awk '{print $1}') + echo "The agent ip address is $ip_address" + + # save variable in a text file + echo "ip_address=$ip_address" > alfresco-bm-manager/target/bamboo-variables.properties + EOF + )" + # Inject bamboo agent ip address + - cat "alfresco-bm-manager/target/bamboo-variables.properties" | sed -e "s/^/export bamboo.inject./g" -e "s/\\./_/g" > "$TMPDIR/bamboo-inject.properties" + - source "$TMPDIR/bamboo-inject.properties" + # Run BM Manager + - | + pushd "alfresco-bm-manager/server/docker-compose" && IP_ADDRESS=${INJECT_IP_ADDRESS} BM_MANAGER_VER=${MANAGER_VERSION} sh -c "$(cat <<'EOF' + #!/bin/bash + docker info + docker-compose --version + export ALFRESCO_BM_MANAGER_TAG=$BM_MANAGER_VER + export MONGO_TAG=latest + export MONGO_HOST=$IP_ADDRESS + export MONGO_PORT=27017 + export REGISTRY="quay.io/" + + echo "Bamboo agent ip is:" + hostname -I | awk '{print $1}' + + docker-compose config + echo "Starting Alfresco BM Manager in Docker container" + docker-compose ps + docker-compose pull + docker-compose -f docker-compose-manager.yml up -d + + WAIT_INTERVAL=1 + COUNTER=0 + TIMEOUT=30 + t0=`date +%s` + + echo "Waiting for BM Manager to start" + until $(curl --output /dev/null --silent --head --fail http://localhost:9080/alfresco-bm-manager) || + [ "$COUNTER" -eq "$TIMEOUT" ]; do + printf '.' + sleep $WAIT_INTERVAL + COUNTER=$(($COUNTER+$WAIT_INTERVAL)) + done + + if (("$COUNTER" < "$TIMEOUT")) ; then + t1=`date +%s` + delta=$((($t1 - $t0)/60)) + echo "Alfresco BM Manager Started in $delta minutes" + else + echo "Waited $COUNTER seconds" + echo "Alfresco BM Manager Could not start in time." + echo "Last 200 lines from logs:" + ALFBMCONTAINER=docker ps -a | grep alfresco-bm-manager | awk '{ print $1 }' + docker logs --tail=200 $ALFBMCONTAINER + exit 1 + fi + EOF + )" && popd + # Run BM Drivers + - | + pushd "alfresco-bm-manager/server/docker-compose" && IP_ADDRESS=${INJECT_IP_ADDRESS} sh -c "$(cat <<'EOF' + #!/bin/bash + docker info + docker-compose --version + export ALFRESCO_BM_LOAD_USERS_TAG=latest + export ALFRESCO_BM_LOAD_DATA_TAG=latest + export ALFRESCO_BM_REST_API_TAG=latest + export MONGO_TAG=latest + export MONGO_HOST=$IP_ADDRESS + export MONGO_PORT=27017 + export REGISTRY="quay.io/" + + echo "Bamboo agent ip is:" + hostname -I | awk '{print $1}' + + docker-compose config + echo "Starting Alfresco BM Drivers in Docker containers" + docker-compose ps + docker-compose pull + docker-compose -f docker-compose-drivers.yml up -d + + TIMEOUT=40 + + echo "Waiting for BM Drivers to start" + sleep $TIMEOUT + EOF + )" && popd + # Start Alfresco + - | + pushd "alfresco-packaging/docker-alfresco/test" && sh -c "$(cat <<'EOF' + #!/bin/bash + docker info + docker-compose --version + export ALFRESCO_TAG=6.1.0 + export REGISTRY="quay.io/" + + docker-compose config + echo "Starting Alfresco in Docker container" + docker-compose ps + docker-compose pull + docker-compose up -d + + WAIT_INTERVAL=1 + COUNTER=0 + TIMEOUT=250 + t0=`date +%s` + + echo "Waiting for alfresco to start" + until $(curl --output /dev/null --silent --head --fail http://localhost:8082/alfresco) || + [ "$COUNTER" -eq "$TIMEOUT" ]; do + printf '.' + sleep $WAIT_INTERVAL + COUNTER=$(($COUNTER+$WAIT_INTERVAL)) + done + + if (("$COUNTER" < "$TIMEOUT")) ; then + t1=`date +%s` + delta=$((($t1 - $t0)/60)) + echo "Alfresco Started in $delta minutes" + else + echo "Waited $COUNTER seconds" + echo "Alfresco Could not start in time." + echo "Last 200 lines from alfresco.log:" + ALFCONTAINER=docker ps -a | grep alfresco-content-repository | awk '{ print $1 }' + docker logs --tail=200 $ALFCONTAINER + exit 1 + fi + EOF + )" && popd + # Run Integration Tests - Load Users + - pushd "alfresco-bm-manager/server" && mvn clean test "-Dalfresco.int.tests.server=${INJECT_IP_ADDRESS}" "-Dalfresco.int.mongo.host=${INJECT_IP_ADDRESS}" "-Dalfresco.int.mongo.port=27017" -Dtest=IntegrationTests#testPopulateWithUsers && popd + # Run Integration Tests - Load Data and Rest-Api + - pushd "alfresco-bm-manager/server" && mvn test "-Dalfresco.int.tests.server=${INJECT_IP_ADDRESS}" "-Dalfresco.int.mongo.host=${INJECT_IP_ADDRESS}" "-Dalfresco.int.mongo.port=27017" -Dtest=IntegrationTests#testPopulateWithData+testRestApiScenario && popd + after_script: + - artifacts upload alfresco-bm-manager/server/target/**/*.xlsx # Stage: release artifact and image - stage: "Release" name: "Release"