From 9dde926417f80d93f4159be8164ed5b3d8790a75 Mon Sep 17 00:00:00 2001 From: Yuli Shlosberg Date: Tue, 12 Sep 2017 14:11:48 +0300 Subject: Build sanity docker execute automation Change-Id: Iab282ea167d12fba4a3f425a5d300397ab435b44 Issue-Id: SDC-315 Signed-off-by: Michael Lando --- sdc-os-chef/pom.xml | 561 +++++++++++---------- sdc-os-chef/scripts/docker_run.sh | 16 +- .../cassandra-actions/attributes/default.rb | 3 +- sdc-os-chef/sdc-sanity/Dockerfile | 7 + .../sdc-sanity/files/default/Files/VNFs/infra.zip | Bin 0 -> 4155 bytes .../sdc-sanity/files/default/Files/VNFs/vbng.zip | Bin 0 -> 3704 bytes .../files/default/Files/VNFs/vbrgemu.zip | Bin 0 -> 3325 bytes .../sdc-sanity/files/default/Files/VNFs/vgmux.zip | Bin 0 -> 3536 bytes .../sdc-sanity/files/default/Files/VNFs/vgw.zip | Bin 0 -> 3469 bytes .../files/default/conf/attsdc-packages.yaml | 12 + .../sdc-sanity/files/default/conf/credentials.yaml | 48 ++ .../sdc-sanity/files/default/conf/log4j.properties | 34 ++ .../sdc-sanity/files/default/startTest.sh | 129 +++++ .../sdc-sanity/recipes/SDC_Simulator_3_logback.rb | 10 + .../recipes/SDC_Simulator_4_locate_keystore.rb | 16 + .../SDC_Simulator_5_create_jetty_modules.rb | 14 + .../recipes/sanityTests_1_cleanup_jettydir.rb | 49 ++ .../recipes/sanityTests_2_setup_configuration.rb | 43 ++ .../recipes/sanityTests_3_sanity_execution.rb | 13 + .../templates/default/BE-titan.properties.erb | 1 + .../sdc-sanity/chef-solo/roles/sanityTests.json | 23 + sdc-os-chef/sdc-sanity/chef-solo/solo.json | 4 +- sdc-os-chef/sdc-sanity/startup.sh | 18 +- 23 files changed, 733 insertions(+), 268 deletions(-) create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/infra.zip create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbng.zip create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbrgemu.zip create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgmux.zip create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgw.zip create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/attsdc-packages.yaml create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/credentials.yaml create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/log4j.properties create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_3_logback.rb create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_4_locate_keystore.rb create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_5_create_jetty_modules.rb create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_1_cleanup_jettydir.rb create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_2_setup_configuration.rb create mode 100644 sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb create mode 100644 sdc-os-chef/sdc-sanity/chef-solo/roles/sanityTests.json (limited to 'sdc-os-chef') diff --git a/sdc-os-chef/pom.xml b/sdc-os-chef/pom.xml index f7e1eaca78..1e24e26d72 100644 --- a/sdc-os-chef/pom.xml +++ b/sdc-os-chef/pom.xml @@ -1,43 +1,45 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> - 4.0.0 + 4.0.0 - sdc-os-chef + sdc-os-chef - - org.openecomp.sdc - sdc-main + + org.openecomp.sdc + sdc-main 1.2.0-SNAPSHOT - + - - ${project.version}-${maven.build.timestamp} - ${project.version}-latest - + + ${project.version}-${maven.build.timestamp} + ${project.version}-latest + - - - - maven-clean-plugin - 3.0.0 - - - clean.tosca.chef.os.folder - clean - - clean - - - - - ${project.basedir}\sdc-cassandra\chef-repo\cookbooks\cassandra-actions\attributes\ - false - - **/default.rb - - + + + + maven-clean-plugin + 3.0.0 + + + clean.tosca.chef.os.folder + clean + + clean + + + + + + ${project.basedir}\sdc-cassandra\chef-repo\cookbooks\cassandra-actions\attributes\ + + false + + **/default.rb + + ${project.parent.basedir}/sdc-os-chef/sdc-backend/chef-repo/cookbooks/sdc-catalog-be/files/default @@ -48,77 +50,83 @@ logback.xml - - - - - - - ru.yaal.maven - write-text-files-maven-plugin - 1.1 - - UTF-8 - - - ${project.basedir}\sdc-cassandra\chef-repo\cookbooks\cassandra-actions\attributes\default.rb - - normal['version'] = "${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" - - - - - - - write-text-files - prepare-package - - write-text-files - - - - - - + + + + + + + ru.yaal.maven + write-text-files-maven-plugin + 1.1 + + UTF-8 + + + + ${project.basedir}\sdc-cassandra\chef-repo\cookbooks\cassandra-actions\attributes\default.rb + + + normal['version'] = + "${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}" + + + + + + + + write-text-files + prepare-package + + write-text-files + + + + + + - - - docker-staging - - ${project.version}-STAGING-${maven.build.timestamp} - ${project.version}-STAGING-latest - - + + + docker-staging + + ${project.version}-STAGING-${maven.build.timestamp} + ${project.version}-STAGING-latest + + - - docker - - false - - - - - maven-resources-plugin - 3.0.2 - - - copy-resources-apidocs - validate - - copy-resources - - - ${basedir}/sdc-backend - - - ${project.parent.basedir}/openecomp-be/tools/swagger-ui/api-docs - - api-docs.war - - - - - + + docker + + false + + + + + maven-resources-plugin + 3.0.2 + + + copy-resources-apidocs + validate + + copy-resources + + + ${basedir}/sdc-backend + + + + ${project.parent.basedir}/openecomp-be/tools/swagger-ui/api-docs + + + api-docs.war + + + + + copy-static-configuration-files @@ -142,185 +150,224 @@ - - copy-resources-be - validate - - copy-resources - - - ${basedir}/sdc-backend - - - ${project.parent.basedir}/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/target - - onboarding-be-${project.version}.war - - - - - - - copy-resources-fe - validate - - copy-resources - - - ${basedir}/sdc-frontend - - - ${project.parent.basedir}/openecomp-ui/target - - onboarding-fe-${project.version}.war - - - - - - - - + + copy-resources-be + validate + + copy-resources + + + ${basedir}/sdc-backend + + + + ${project.parent.basedir}/openecomp-be/api/openecomp-sdc-rest-webapp/onboarding-rest-war/target + + + onboarding-be-${project.version}.war + + + + + + + copy-resources-fe + validate + + copy-resources + + + ${basedir}/sdc-frontend + + + ${project.parent.basedir}/openecomp-ui/target + + onboarding-fe-${project.version}.war + + + + + + + copy-tests-suites + validate + + copy-resources + + + sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/testSuites + + + ${project.parent.basedir}/test-apis-ci/src/main/resources/ci/testSuites + + * + + + + + + + copy-resources-test-apis-ci + validate + + copy-resources + + + ${basedir}/sdc-sanity + + + ${project.parent.basedir}/test-apis-ci/target + + test-apis-ci-${project.version}-jar-with-dependencies.jar + + + + + + + - - io.fabric8 - docker-maven-plugin - 0.22.1 + + io.fabric8 + docker-maven-plugin + 0.19.1 - - false - 1.23 + + true + 1.23 - + - - - openecomp/sdc-backend - sdc-backend - - try - ${project.basedir}/sdc-backend - - ${docker.tag} - ${docker.latest.tag} - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - + + + openecomp/sdc-backend + sdc-backend + + try + ${project.basedir}/sdc-backend + + ${docker.tag} + ${docker.latest.tag}$sedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + - - - openecomp/sdc-frontend - sdc-frontend - - try - ${project.basedir}/sdc-frontend - - ${docker.tag} - ${docker.latest.tag} - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - + + + openecomp/sdc-frontend + sdc-frontend + + try + ${project.basedir}/sdc-frontend + + ${docker.tag} + ${docker.latest.tag} + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + - - - openecomp/sdc-elasticsearch - sdc-elasticsearch - - try - ${project.basedir}/sdc-elasticsearch - - ${docker.tag} - ${docker.latest.tag} - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - + + + openecomp/sdc-elasticsearch + sdc-elasticsearch + + try + ${project.basedir}/sdc-elasticsearch + + ${docker.tag} + ${docker.latest.tag} + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + - - - openecomp/sdc-kibana - sdc-kibana - - try - ${project.basedir}/sdc-kibana - - ${docker.tag} - ${docker.latest.tag} - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - + + + openecomp/sdc-kibana + sdc-kibana + + try + ${project.basedir}/sdc-kibana + + ${docker.tag} + ${docker.latest.tag} + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + - - - openecomp/sdc-cassandra - sdc-cassandra - - try - ${project.basedir}/sdc-cassandra - - ${docker.tag} - ${docker.latest.tag} - ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest - - - + + + openecomp/sdc-cassandra + sdc-cassandra + + try + ${project.basedir}/sdc-cassandra + + ${docker.tag} + ${docker.latest.tag} + ${parsedVersion.majorVersion}.${parsedVersion.minorVersion}-STAGING-latest + + + - - + + + openecomp/sdc-sanity + sdc-sanity + + try + ${project.basedir}/sdc-sanity + + ${docker.tag} + ${docker.latest.tag} + 1.1-STAGING-latest + + + - - - - + + + + clean-images pre-clean - remove + remove - true + true + openecomp/sdc-backend,openecomp/sdc-frontend,openecomp/sdc-elasticsearch,openecomp/sdc-kibana,openecomp/sdc-sanity - + - - generate-images - package - - build - - + + generate-images + package + + build + + - + push-images deploy - build - push + build + push - openecomp/sdc-backend,openecomp/sdc-frontend,openecomp/sdc-elasticsearch,openecomp/sdc-kibana,openecomp/sdc-cassandra + + openecomp/sdc-backend,openecomp/sdc-frontend,openecomp/sdc-elasticsearch,openecomp/sdc-kibana,openecomp/sdc-sanity - - - - - - - + + + + + + + diff --git a/sdc-os-chef/scripts/docker_run.sh b/sdc-os-chef/scripts/docker_run.sh index c79dad2d56..d645f94b93 100755 --- a/sdc-os-chef/scripts/docker_run.sh +++ b/sdc-os-chef/scripts/docker_run.sh @@ -2,7 +2,7 @@ function usage { - echo "usage: docker_run.sh [ -r|--release ] [ -e|--environment ] [ -p|--port ] [ -l|--local ] [ -h|--help ]" + echo "usage: docker_run.sh [ -r|--release ] [ -e|--environment ] [ -p|--port ] [ -l|--local ] [ -s|--skipTests ] [ -h|--help ]" } @@ -25,6 +25,7 @@ function dir_perms { RELEASE=latest LOCAL=false +SKIPTESTS=false [ -f /opt/config/env_name.txt ] && DEP_ENV=$(cat /opt/config/env_name.txt) || DEP_ENV=__ENV-NAME__ [ -f /opt/config/nexus_username.txt ] && NEXUS_USERNAME=$(cat /opt/config/nexus_username.txt) || NEXUS_USERNAME=release [ -f /opt/config/nexus_password.txt ] && NEXUS_PASSWD=$(cat /opt/config/nexus_password.txt) || NEXUS_PASSWD=sfWU3DFVdBr7GVxB85mTYgAW @@ -48,6 +49,10 @@ while [ "$1" != "" ]; do shift LOCAL=true ;; + -s | --skipTests ) + shift + SKIPTESTS=true + ;; -h | --help ) usage exit @@ -157,3 +162,12 @@ if [ $? -ne 0 ]; then exit 1 fi +# sanityDocker +echo "docker run sdc-frontend..." +if [ ${SKIPTESTS} = false ]; then +echo "Triger sanity docker, please wait..." + if [ ${LOCAL} = false ]; then + docker pull ${PREFIX}/sdc-sanity:${RELEASE} + fi + docker run --detach --name sdc-sanity --env HOST_IP=${IP} --env ENVNAME="${DEP_ENV}" --env http_proxy=${http_proxy} --env https_proxy=${https_proxy} --env no_proxy=${no_proxy} --log-driver=json-file --log-opt max-size=100m --log-opt max-file=10 --ulimit memlock=-1:-1 --memory 512m --memory-swap=512m --ulimit nofile=4096:100000 --volume /etc/localtime:/etc/localtime:ro --volume /data/logs/sdc-sanity/target:/var/lib/tests/target --volume /data/logs/sdc-sanity/ExtentReport:/var/lib/tests/ExtentReport --volume /data/environments:/root/chef-solo/environments --publish 9560:9560 ${PREFIX}/sdc-sanity:${RELEASE} +fi diff --git a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb index c7f408f294..dac5853353 100644 --- a/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb +++ b/sdc-os-chef/sdc-cassandra/chef-repo/cookbooks/cassandra-actions/attributes/default.rb @@ -1 +1,2 @@ -normal['version'] = "1.1.0" +normal['version'] = + "1.1.0" diff --git a/sdc-os-chef/sdc-sanity/Dockerfile b/sdc-os-chef/sdc-sanity/Dockerfile index ea137b401b..38bf26641e 100644 --- a/sdc-os-chef/sdc-sanity/Dockerfile +++ b/sdc-os-chef/sdc-sanity/Dockerfile @@ -4,6 +4,13 @@ COPY chef-solo /root/chef-solo/ COPY chef-repo/cookbooks/. /root/chef-solo/cookbooks/ + +ENV TESTS_BASE /var/lib/tests +RUN mkdir -p "$TESTS_BASE" +WORKDIR $TESTS_BASE + +ADD test-apis-ci-*.jar ${TESTS_BASE}/ + COPY startup.sh /root/ RUN chmod 770 /root/startup.sh diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/infra.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/infra.zip new file mode 100644 index 0000000000..09eb9cd648 Binary files /dev/null and b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/infra.zip differ diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbng.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbng.zip new file mode 100644 index 0000000000..ab5163d9ed Binary files /dev/null and b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbng.zip differ diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbrgemu.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbrgemu.zip new file mode 100644 index 0000000000..28c69a570f Binary files /dev/null and b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vbrgemu.zip differ diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgmux.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgmux.zip new file mode 100644 index 0000000000..56de952150 Binary files /dev/null and b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgmux.zip differ diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgw.zip b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgw.zip new file mode 100644 index 0000000000..7a14718c2c Binary files /dev/null and b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/Files/VNFs/vgw.zip differ diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/attsdc-packages.yaml b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/attsdc-packages.yaml new file mode 100644 index 0000000000..5d1a3e1537 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/attsdc-packages.yaml @@ -0,0 +1,12 @@ +packages: + - org.openecomp.sdc.ci.tests.execute.general + - org.openecomp.sdc.ci.tests.execute.user + - org.openecomp.sdc.ci.tests.execute.property + - org.openecomp.sdc.ci.tests.execute.lifecycle + - org.openecomp.sdc.ci.tests.execute.resource + - org.openecomp.sdc.ci.tests.execute.service + - org.openecomp.sdc.ci.tests.execute.artifacts + - org.openecomp.sdc.ci.tests.execute.imports + - org.openecomp.sdc.ci.tests.execute.category + - org.openecomp.sdc.ci.tests.execute.distribution + - org.openecomp.sdc.ci.tests.execute.product \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/credentials.yaml b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/credentials.yaml new file mode 100644 index 0000000000..ab37f7bee8 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/credentials.yaml @@ -0,0 +1,48 @@ + designer: { + username: cs0008, + password: 123123a, + firstname: ASDC, + lastname: KASPIN + } + admin: { + username: jh0003, + password: 123123a, + firstname: ASDC, + lastname: KASPIN + } + ops: { + username: af0006, + password: 123123a, + firstname: ASDC, + lastname: KASPIN + } + tester: { + username: kb0004, + password: 123123a, + firstname: ASDC, + lastname: KASPIN + } + governor: { + username: ah0002, + password: 123123a, + firstname: ASDC, + lastname: KASPIN + } + product_strategist: { + username: m99126, + password: 1910-FruitGum, + firstname: ASDC, + lastname: KASPIN + } + product_manager: { + username: m99127, + password: 747-Airplane, + firstname: ASDC, + lastname: KASPIN + } + product_local: { + username: pm0001, + password: 123123a, + firstname: ASDC, + lastname: KASPIN + } \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/log4j.properties b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/log4j.properties new file mode 100644 index 0000000000..d313e92b55 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/conf/log4j.properties @@ -0,0 +1,34 @@ +# Define the root logger with appender file +log4j.rootLogger = INFO, FILE, stdout + +# Define the file appender +log4j.appender.FILE=org.apache.log4j.RollingFileAppender +log4j.appender.FILE.File=${targetlog}logs/ci-log.out + +# Define the layout for file appender +log4j.appender.FILE.layout=org.apache.log4j.PatternLayout +log4j.appender.FILE.layout.conversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p [%10c] : %m%n + +# Set the maximum file size before rollover +log4j.appender.FILE.maxFileSize=5MB + +# Set the the backup index +log4j.appender.FILE.maxBackupIndex=10 + + +############################################################# + +# Direct log messages to stdout +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +#log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n +log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %5p %10c:%L - %m%n + +log4j.logger.org.apache.cassandra.service.StorageProxy=INFO +log4j.logger.com.thinkaurelius.titan.diskstorage.cassandra.CassandraTransaction=INFO, FILE, stdout + +log4j.logger.org.openecomp.sdc.ci.tests.utils=INFO, FILE, stdout +log4j.additivity.org.openecomp.sdc.ci.tests.utils=false + + diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh new file mode 100644 index 0000000000..933f9af6e4 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/files/default/startTest.sh @@ -0,0 +1,129 @@ +#!/bin/bash +REMOTE_DEBUG=false +RERUN=false +JAVA_OPTION="" +debug_port=8000 +TEST_SUITES=testSuites +fileName=testng-failed.xml + +function help_usage () +{ + echo + echo "$0 ( ) [-r/rerun -d/debug ]" + echo "nohup ./startTest.sh ui-ci-1707.0.5-SNAPSHOT-jar-with-dependencies.jar extendedSanity.xml -r false -d true &" + echo "by default rerun is true and remote debug is false." + echo + exit 2 +} + +function isBoolean () +{ + PARAM_NAME=$1 + VALUE=$2 + if [[ ${VALUE} != "true" ]] && [[ ${VALUE} != "false" ]]; then + echo "Valid parameter" ${PARAM_NAME} "values are: true/false" + help_usage + fi +} + +function prepareFailedXmlFile () +{ + echo "1="$1 "2="$2 "fileName="${fileName} + PATTERN=`grep -w "test name=" ${FULL_PATH}/${TEST_SUITES}/$2 | awk -F'"' '{print $2}'` + sed '/ ${FULL_PATH}/${TEST_SUITES}/${fileName} + sed -i 's/thread-count="[0-9]\+"/thread-count="1"/g' ${FULL_PATH}/${TEST_SUITES}/${fileName} +} + +#main +[ $# -lt 2 ] && help_usage + +JAR_FILE=$1 +SUITE_FILE=$2 + +while [ $# -ne 0 ]; do + case $1 in + -r|rerun) + RERUN=$2 + isBoolean $1 ${RERUN} + shift 1 + shift 1 + ;; + -d|debug) + REMOTE_DEBUG=$2 + isBoolean $1 ${REMOTE_DEBUG} + shift 1 + shift 1 + ;; + *) + shift 1 + ;; + esac +done + +CURRENT_DIR=`pwd` +BASEDIR=$(dirname $0) + +if [ ${BASEDIR:0:1} = "/" ] +then + FULL_PATH=$BASEDIR +else + FULL_PATH=$CURRENT_DIR/$BASEDIR +fi +LOGS_PROP_FILE=file:${FULL_PATH}/conf/log4j.properties +############################################# +TARGET_DIR=${FULL_PATH}/target +CONF_FILE=${FULL_PATH}/conf/sdc.yaml + +DEBUG=true +MainClass=org.openecomp.sdc.ci.tests.run.StartTest + +TESTS_DIR=/opt/app/sdc/ci/resources/tests +COMPONENTS_DIR=/opt/app/sdc/ci/resources/components + + +TARGET_LOG_DIR="${TARGET_DIR}/" + +######ADD USERS################ + +BE_IP=`cat conf/attsdc.yaml | grep catalogBeHost| awk '{print $2}'` + + +if [ ${REMOTE_DEBUG} == "true" ]; then + echo "Debug mode, Listen on port $debug_port"; + JAVA_OPTION="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=${debug_port}" ; +fi + +cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE &" + + +if [ $DEBUG == "true" ] +then + $cmd +else + $cmd >> /dev/null +fi + +if [ ${RERUN} == "true" ]; then + if [ -f ${TARGET_DIR}/${fileName} ]; then + echo "Prepare" ${TARGET_DIR}/${fileName} "file to rerun all failed tests ..."; + prepareFailedXmlFile ${TARGET_DIR}/${fileName} $SUITE_FILE; + SUITE_FILE=${fileName}; + cmd="java $JAVA_OPTION -DdisplayException=true -Dtargetlog=${TARGET_LOG_DIR} -Dfilepath=${FILES_TEST} -Dconfig.resource=${CONF_FILE} -Ddebug=${DEBUG} -Dlog4j.configuration=${LOGS_PROP_FILE} -cp $JAR_FILE ${MainClass} $SUITE_FILE &" + $cmd; + fi +fi + +status=`echo $?` + +source ExtentReport/versions.info +now=$(date +'%Y-%m-%d_%H_%M') +REPORT_NAME=${now} +VERSION=${osVersion} + + + +echo "##################################################" +echo "################# status is ${status} #################" +echo "##################################################" + +exit $status \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_3_logback.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_3_logback.rb new file mode 100644 index 0000000000..0d9282b28a --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_3_logback.rb @@ -0,0 +1,10 @@ +jetty_base="/var/lib/jetty" + + +cookbook_file "logback.xml" do + path "#{jetty_base}/config/sdc-simulator/logback.xml" + source "logback.xml" + owner "jetty" + group "jetty" + mode "0755" +end \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_4_locate_keystore.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_4_locate_keystore.rb new file mode 100644 index 0000000000..3bb482d89a --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_4_locate_keystore.rb @@ -0,0 +1,16 @@ +jetty_base="/var/lib/jetty" + +directory "Jetty_etcdir_creation" do + path "/#{jetty_base}/etc" + owner 'jetty' + group 'jetty' + mode '0755' + action :create +end + +cookbook_file "/#{jetty_base}/etc/keystore" do + source "keystore" + owner "jetty" + group "jetty" + mode 0755 +end \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_5_create_jetty_modules.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_5_create_jetty_modules.rb new file mode 100644 index 0000000000..38b87fa65d --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/SDC_Simulator_5_create_jetty_modules.rb @@ -0,0 +1,14 @@ +jetty_base="/var/lib/jetty" +jetty_home="/usr/local/jetty" + +###### create Jetty modules +bash "create-jetty-modules" do +cwd "#{jetty_base}" +code <<-EOH + cd "#{jetty_base}" + java -jar "/#{jetty_home}"/start.jar --add-to-start=deploy + java -jar "/#{jetty_home}"/start.jar --add-to-startd=http,https,logging,setuid +EOH +not_if "ls /#{jetty_base}/start.d/https.ini" +end + diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_1_cleanup_jettydir.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_1_cleanup_jettydir.rb new file mode 100644 index 0000000000..112cc4c2e7 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_1_cleanup_jettydir.rb @@ -0,0 +1,49 @@ +tests_base="/var/lib/tests" + + remote_directory '/var/lib/tests/testSuites' do + source 'testSuites' + owner 'root' + group 'root' + mode '0755' + action :create + end + + remote_directory '/var/lib/tests/Files' do + source 'Files' + owner 'root' + group 'root' + mode '0755' + action :create + end + + remote_directory '/var/lib/tests/conf' do + source 'conf' + owner 'root' + group 'root' + mode '0755' + action :create + end + + directory "create_target_dir" do + path "/var/lib/tests/target" + owner 'root' + group 'root' + mode '0755' + action :create + end + + directory "create_ExtentReport_dir" do + path "/var/lib/tests/ExtentReport" + owner 'root' + group 'root' + mode '0755' + action :create + end + + cookbook_file '/var/lib/tests/startTest.sh' do + source 'startTest.sh' + owner 'root' + group 'root' + mode '0755' + action :create + end \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_2_setup_configuration.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_2_setup_configuration.rb new file mode 100644 index 0000000000..cf6875746e --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_2_setup_configuration.rb @@ -0,0 +1,43 @@ +tests_base="/var/lib/tests" + +template "sdc-yaml-config" do + path "#{tests_base}/conf/sdc.yaml" + source "sdc-sanity.yaml.erb" + owner "root" + group "root" + mode "0755" + variables ({ + :target_path => "#{tests_base}/target", + :catalogBE_ip => node['Nodes']['BE'], + :catalogBE_port => node['BE'][:http_port], + :webportal_ip => node['Nodes']['FE'], + :webportal_port => node['FE'][:http_port], + :titan_file => "#{tests_base}/conf/titan.properties", + :tests_base_ci => "#{tests_base}/CI/tests", + :components_path => "#{tests_base}/CI/components", + :importResourceConfigDir => "#{tests_base}/CI/importResource", + :importTypesDir => "#{tests_base}/CI/importTypesTest", + :importResourceTestsConfigDir => "#{tests_base}/CI/importResourceTests", + :ConfigurationFile => "#{tests_base}/conf/configuration.yaml", + :errorConfigurationFile => "#{tests_base}/conf/error-configuration.yaml", + :CASSANDRA_IP => node['Nodes']['CS'], + :CASSANDRA_PWD => node['cassandra'][:cassandra_password], + :CASSANDRA_USR => node['cassandra'][:cassandra_user] + }) +end + +replication_factor=1 +template "titan.properties" do + path "/#{tests_base}/conf/titan.properties" + source "BE-titan.properties.erb" + owner "root" + group "root" + mode "0755" + variables({ + :CASSANDRA_IP => node['Nodes']['CS'], + :CASSANDRA_PWD => node['cassandra'][:cassandra_password], + :CASSANDRA_USR => node['cassandra'][:cassandra_user], + :rep_factor => replication_factor, + :DC_NAME => node['cassandra'][:cluster_name]+node.chef_environment + }) +end \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb new file mode 100644 index 0000000000..6f10a33dd6 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/recipes/sanityTests_3_sanity_execution.rb @@ -0,0 +1,13 @@ +tests_base="/var/lib/tests" +ci_test_suite="onap.xml" + +bash "run asdc ci sanity tests" do +cwd "#{tests_base}" +code <<-EOH + cd "#{tests_base}" + jar_file=`ls test-apis*-jar-with-dependencies.jar` + ./startTest.sh $jar_file #{ci_test_suite} + echo "return code from startTest.sh = [$?]" +EOH +timeout 72000 +end \ No newline at end of file diff --git a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/templates/default/BE-titan.properties.erb b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/templates/default/BE-titan.properties.erb index 27386d47ef..a42c7bf206 100644 --- a/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/templates/default/BE-titan.properties.erb +++ b/sdc-os-chef/sdc-sanity/chef-repo/cookbooks/sdc-sanity/templates/default/BE-titan.properties.erb @@ -4,6 +4,7 @@ storage.port=9160 storage.username=<%= @CASSANDRA_USR %> storage.password=<%= @CASSANDRA_PWD %> storage.connection-timeout=10000 +storage.cassandra.keyspace=sdctitan storage.cassandra.ssl.enabled=false storage.cassandra.ssl.truststore.location=/var/lib/jetty/config/.truststore diff --git a/sdc-os-chef/sdc-sanity/chef-solo/roles/sanityTests.json b/sdc-os-chef/sdc-sanity/chef-solo/roles/sanityTests.json new file mode 100644 index 0000000000..74f12c7cc6 --- /dev/null +++ b/sdc-os-chef/sdc-sanity/chef-solo/roles/sanityTests.json @@ -0,0 +1,23 @@ +{ + "name": "sanityTests", + "description": "Execute sanity tests", + "json_class": "Chef::Role", + "default_attributes": { + + }, + "override_attributes": { + + }, + "chef_type": "role", + "run_list": [ + "recipe[sdc-sanity::sanityTests_1_cleanup_jettydir]", + "recipe[sdc-sanity::sanityTests_2_setup_configuration]", + "recipe[sdc-sanity::sanityTests_3_sanity_execution]" +// "recipe[sdc-simulator::SDC_Simulator_3_logback]", +// "recipe[sdc-simulator::SDC_Simulator_4_locate_keystore]", +// "recipe[sdc-simulator::SDC_Simulator_5_create_jetty_modules]" + ], + "env_run_lists": { + } +} + diff --git a/sdc-os-chef/sdc-sanity/chef-solo/solo.json b/sdc-os-chef/sdc-sanity/chef-solo/solo.json index 5bd228127d..6487d4cc4e 100644 --- a/sdc-os-chef/sdc-sanity/chef-solo/solo.json +++ b/sdc-os-chef/sdc-sanity/chef-solo/solo.json @@ -1,4 +1,6 @@ { - "run_list": [ "recipe[sdc-sanity::setup_sanity]" ] + "run_list": [ + "role[sanityTests]" + ] } diff --git a/sdc-os-chef/sdc-sanity/startup.sh b/sdc-os-chef/sdc-sanity/startup.sh index 374a0e8c34..d4316c383f 100644 --- a/sdc-os-chef/sdc-sanity/startup.sh +++ b/sdc-os-chef/sdc-sanity/startup.sh @@ -6,13 +6,15 @@ chef-solo -c solo.rb -E ${CHEFNAME} rc=$? -if [[ $rc != 0 ]]; then - echo "Sanity failed !!!" - exit $rc -else - echo "completed successfully :-)" - exit 0 -fi +#if [[ $rc != 0 ]]; then +# echo "Sanity failed !!!" +# exit $rc +#else +# echo "completed successfully :-)" +# exit 0 +#fi -#/docker-entrypoint.sh +while true; do sleep 2; done + +##/docker-entrypoint.sh -- cgit 1.2.3-korg