Skip to content

Commit

Permalink
Modify test so the input is read from a sp file
Browse files Browse the repository at this point in the history
Signed-off-by: Denisa Dan <[email protected]>
  • Loading branch information
Denisa Dan committed Apr 10, 2017
1 parent f780b8c commit 6be8554
Show file tree
Hide file tree
Showing 5 changed files with 157 additions and 136 deletions.
263 changes: 135 additions & 128 deletions circle.yml
Original file line number Diff line number Diff line change
@@ -1,128 +1,135 @@
# (c) Copyright 2014-2017 Hewlett-Packard Enterprise Development Company, L.P.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
#
# The Apache License is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
########################################################################################################################

# ENV VARS SET IN CIRCLE UI:
# - BUILD_MODE: set to a value - e.g. CHANGES_ONLY to activate (this is POC mode)
# - DO_API_TOKEN
# - DO_DROPLET_SSH_PRIVATE_KEY
# - DO_DROPLET_SSH_PUBLIC_KEY_ID
# - DO_REGION

general:
artifacts:
- "./cslang-builder/logs/builder.log"

machine:
environment:
# "${CIRCLE_PR_NUMBER}" = "" denotes that the build is not part of a fork PR
# ignore test suites on node 1 in fork builds
ACTIVE_CI_TEST_SUITES_DROPLETS_NODE_1: $(if [ "${CIRCLE_PR_NUMBER}" = "" ]; then echo '!default,coreos,cadvisor,docker-circleci'; else echo '!default'; fi)
ACTIVE_CI_TEST_SUITES_DROPLETS_NODE_2: $(if [ "${CIRCLE_PR_NUMBER}" = "" ]; then echo '!default,swarm'; else echo '!default'; fi)

COREOS_MACHINE_NAMES_1: "ci-${CIRCLE_BUILD_NUM}-coreos-1 ci-${CIRCLE_BUILD_NUM}-coreos-2 ci-${CIRCLE_BUILD_NUM}-coreos-3"
COREOS_MACHINE_NAMES_2: "ci-${CIRCLE_BUILD_NUM}-coreos-4 ci-${CIRCLE_BUILD_NUM}-coreos-5 ci-${CIRCLE_BUILD_NUM}-coreos-6"
RULE_DROPLET_MACHINE_NOT_FORK_1: '[ "${CIRCLE_PR_NUMBER}" = "" ] && [ "${CIRCLE_NODE_INDEX}" = "1" ]'
RULE_DROPLET_MACHINE_NOT_FORK_2: '[ "${CIRCLE_PR_NUMBER}" = "" ] && [ "${CIRCLE_NODE_INDEX}" = "2" ]'
CLOUD_CONFIG_FILE: 'ci-env/circleci/cloud-config.yaml'
DROPLETS_FILE_1: "droplets_${CIRCLE_BUILD_NUM}_1.txt"
DROPLETS_FILE_2: "droplets_${CIRCLE_BUILD_NUM}_2.txt"
COREOS_PLACEHOLDERS_1: '<coreos_host_1> <coreos_host_2> <coreos_host_3>'
COREOS_PLACEHOLDERS_2: '<coreos_host_4> <coreos_host_5> <coreos_host_6>'
CHANGES_ONLY_BUILD_MODE: '[ "${CIRCLE_BRANCH}" != "master" ] && [ -n $BUILD_MODE ]'

JAVA_OPTS: -Xms400m -Xmx2g -XX:PermSize=128m -XX:MaxPermSize=256m
pre:
- sudo curl -L -o /usr/bin/docker 'http://s3-external-1.amazonaws.com/circle-downloads/docker-1.8.2-circleci'; sudo chmod 0755 /usr/bin/docker; true

services:
- docker

dependencies:
override:
- echo ${CIRCLE_BRANCH}
- echo ${BUILD_MODE}
- ? >
if eval "${CHANGES_ONLY_BUILD_MODE}";
then echo 'Build mode: CHANGES_ONLY'
&& chmod +x ci-env/circleci/setup_changes_only_mode.sh
&& ci-env/circleci/setup_changes_only_mode.sh;
else echo 'Build mode: BASIC';
fi
: parallel: true
- docker info
- docker images
- ? > ### machine 1
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_1}";
then chmod +x ci-env/circleci/create_droplets.sh
&& COREOS_MACHINE_NAMES=${COREOS_MACHINE_NAMES_1} DROPLETS_FILE=${DROPLETS_FILE_1}
ci-env/circleci/create_droplets.sh;
fi
: parallel: true
- ? > ### machine 2
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_2}";
then chmod +x ci-env/circleci/create_droplets.sh
&& COREOS_MACHINE_NAMES=${COREOS_MACHINE_NAMES_2} DROPLETS_FILE=${DROPLETS_FILE_2}
ci-env/circleci/create_droplets.sh;
fi
: parallel: true
- ? > ### machine 0
if [ "${CIRCLE_NODE_INDEX}" = "0" ];
then docker run -p 49154:25 -e maildomain=example.com -e smtp_user=user:pwd,otheruser:pwd --name postfix -d catatnight/postfix
&& docker run -d -p 8500:8500 -p 8600:8600/udp gituser173/consul
&& docker run -d -e SWAGGER_HOST=http://localhost -e SWAGGER_BASE_PATH=/v2 -p 3000:8080 swaggerapi/petstore;
fi
: parallel: true
- ? > ### every machine
wget https://github.com/CloudSlang/cloud-slang/releases/download/cloudslang-1.0.3/cslang-builder.zip
&& unzip cslang-builder.zip
&& chmod +x cslang-builder/bin/cslang-builder
&& mkdir cslang-builder/lib/Lib
&& pip install -r python-lib/requirements.txt -t cslang-builder/lib/Lib
: parallel: true
- ? > ### machine 1
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_1}";
then chmod +x ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh
&& DROPLETS_FILE=${DROPLETS_FILE_1} COREOS_PLACEHOLDERS=${COREOS_PLACEHOLDERS_1}
ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh;
fi
: parallel: true
- ? > ### machine 2
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_2}";
then chmod +x ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh
&& DROPLETS_FILE=${DROPLETS_FILE_2} COREOS_PLACEHOLDERS=${COREOS_PLACEHOLDERS_2}
ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh;
fi
: parallel: true

test:
override:
- ? >
if eval "${CHANGES_ONLY_BUILD_MODE}";
then CHANGES_PARAM="--changes-only $(pwd)/changed_items.txt";
else CHANGES_PARAM="";
fi
&& case ${CIRCLE_NODE_INDEX} in
0) ./cslang-builder/bin/cslang-builder -des -cs -rcf $(pwd)/configuration/runconfig/lane_0.properties ${CHANGES_PARAM} ;;
1) ./cslang-builder/bin/cslang-builder -des -cs -rcf $(pwd)/configuration/runconfig/lane_1.properties ${CHANGES_PARAM} ;;
2) ./cslang-builder/bin/cslang-builder -des -cs -rcf $(pwd)/configuration/runconfig/lane_2.properties ${CHANGES_PARAM} ;;
esac
: parallel: true
post:
- ? > ### machine 1
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_1}";
then chmod +x ci-env/circleci/cleanup_env.sh
&& DROPLETS_FILE=${DROPLETS_FILE_1} ci-env/circleci/cleanup_env.sh;
fi
: parallel: true
- ? > ### machine 2
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_2}";
then chmod +x ci-env/circleci/cleanup_env.sh
&& DROPLETS_FILE=${DROPLETS_FILE_2} ci-env/circleci/cleanup_env.sh;
fi
: parallel: true
# (c) Copyright 2014-2017 Hewlett-Packard Enterprise Development Company, L.P.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
#
# The Apache License is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
########################################################################################################################

# ENV VARS SET IN CIRCLE UI:
# - BUILD_MODE: set to a value - e.g. CHANGES_ONLY to activate (this is POC mode)
# - DO_API_TOKEN
# - DO_DROPLET_SSH_PRIVATE_KEY
# - DO_DROPLET_SSH_PUBLIC_KEY_ID
# - DO_REGION

general:
artifacts:
- "./cslang-builder/logs/builder.log"

machine:
environment:
# "${CIRCLE_PR_NUMBER}" = "" denotes that the build is not part of a fork PR
# ignore test suites on node 1 in fork builds
ACTIVE_CI_TEST_SUITES_DROPLETS_NODE_1: $(if [ "${CIRCLE_PR_NUMBER}" = "" ]; then echo '!default,coreos,cadvisor,docker-circleci'; else echo '!default'; fi)
ACTIVE_CI_TEST_SUITES_DROPLETS_NODE_2: $(if [ "${CIRCLE_PR_NUMBER}" = "" ]; then echo '!default,swarm'; else echo '!default'; fi)

COREOS_MACHINE_NAMES_1: "ci-${CIRCLE_BUILD_NUM}-coreos-1 ci-${CIRCLE_BUILD_NUM}-coreos-2 ci-${CIRCLE_BUILD_NUM}-coreos-3"
COREOS_MACHINE_NAMES_2: "ci-${CIRCLE_BUILD_NUM}-coreos-4 ci-${CIRCLE_BUILD_NUM}-coreos-5 ci-${CIRCLE_BUILD_NUM}-coreos-6"
RULE_DROPLET_MACHINE_NOT_FORK_1: '[ "${CIRCLE_PR_NUMBER}" = "" ] && [ "${CIRCLE_NODE_INDEX}" = "1" ]'
RULE_DROPLET_MACHINE_NOT_FORK_2: '[ "${CIRCLE_PR_NUMBER}" = "" ] && [ "${CIRCLE_NODE_INDEX}" = "2" ]'
CLOUD_CONFIG_FILE: 'ci-env/circleci/cloud-config.yaml'
DROPLETS_FILE_1: "droplets_${CIRCLE_BUILD_NUM}_1.txt"
DROPLETS_FILE_2: "droplets_${CIRCLE_BUILD_NUM}_2.txt"
COREOS_PLACEHOLDERS_1: '<coreos_host_1> <coreos_host_2> <coreos_host_3>'
COREOS_PLACEHOLDERS_2: '<coreos_host_4> <coreos_host_5> <coreos_host_6>'
CHANGES_ONLY_BUILD_MODE: '[ "${CIRCLE_BRANCH}" != "master" ] && [ -n $BUILD_MODE ]'
YODA_FILE_PATH: $(pwd)/resources/base/examples/yoda/yoda_quotes.txt

JAVA_OPTS: -Xms400m -Xmx2g -XX:PermSize=128m -XX:MaxPermSize=256m
pre:
- sudo curl -L -o /usr/bin/docker 'http://s3-external-1.amazonaws.com/circle-downloads/docker-1.8.2-circleci'; sudo chmod 0755 /usr/bin/docker; true

services:
- docker

dependencies:
override:
# - echo ${CIRCLE_BRANCH}
# - echo ${BUILD_MODE}
# - ? >
# if eval "${CHANGES_ONLY_BUILD_MODE}";
# then echo 'Build mode: CHANGES_ONLY'
# && chmod +x ci-env/circleci/setup_changes_only_mode.sh
# && ci-env/circleci/setup_changes_only_mode.sh;
# else echo 'Build mode: BASIC';
# fi
# : parallel: true
# - docker info
# - docker images
# - ? > ### machine 1
# if eval "${RULE_DROPLET_MACHINE_NOT_FORK_1}";
# then chmod +x ci-env/circleci/create_droplets.sh
# && COREOS_MACHINE_NAMES=${COREOS_MACHINE_NAMES_1} DROPLETS_FILE=${DROPLETS_FILE_1}
# ci-env/circleci/create_droplets.sh;
# fi
# : parallel: true
# - ? > ### machine 2
# if eval "${RULE_DROPLET_MACHINE_NOT_FORK_2}";
# then chmod +x ci-env/circleci/create_droplets.sh
# && COREOS_MACHINE_NAMES=${COREOS_MACHINE_NAMES_2} DROPLETS_FILE=${DROPLETS_FILE_2}
# ci-env/circleci/create_droplets.sh;
# fi
# : parallel: true
# - ? > ### machine 0
# if [ "${CIRCLE_NODE_INDEX}" = "0" ];
# then docker run -p 49154:25 -e maildomain=example.com -e smtp_user=user:pwd,otheruser:pwd --name postfix -d catatnight/postfix
# && docker run -d -p 8500:8500 -p 8600:8600/udp gituser173/consul
# && docker run -d -e SWAGGER_HOST=http://localhost -e SWAGGER_BASE_PATH=/v2 -p 3000:8080 swaggerapi/petstore;
# fi
# : parallel: true
# - ? > ### every machine
# wget https://github.com/CloudSlang/cloud-slang/releases/download/cloudslang-1.0.3/cslang-builder.zip
# && unzip cslang-builder.zip
# && chmod +x cslang-builder/bin/cslang-builder
# && mkdir cslang-builder/lib/Lib
# && pip install -r python-lib/requirements.txt -t cslang-builder/lib/Lib
# : parallel: true
# - ? > ### machine 1
# if eval "${RULE_DROPLET_MACHINE_NOT_FORK_1}";
# then chmod +x ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh
# && DROPLETS_FILE=${DROPLETS_FILE_1} COREOS_PLACEHOLDERS=${COREOS_PLACEHOLDERS_1}
# ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh;
# fi
# : parallel: true
# - ? > ### machine 2
# if eval "${RULE_DROPLET_MACHINE_NOT_FORK_2}";
# then chmod +x ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh
# && DROPLETS_FILE=${DROPLETS_FILE_2} COREOS_PLACEHOLDERS=${COREOS_PLACEHOLDERS_2}
# ci-env/circleci/wait_for_droplets_and_update_test_inputs.sh;
# fi
# : parallel: true
- echo ${YODA_FILE_PATH}
- ? > ### machine 0
if [ "${CIRCLE_NODE_INDEX}" = "0" ];
then find configuration -type f -exec sed -i "s/<yoda_file_path>/${YODA_FILE_PATH}/g" {} +;
fi
: parallel: true

test:
override:
- ? >
if eval "${CHANGES_ONLY_BUILD_MODE}";
then CHANGES_PARAM="--changes-only $(pwd)/changed_items.txt";
else CHANGES_PARAM="";
fi
&& case ${CIRCLE_NODE_INDEX} in
0) ./cslang-builder/bin/cslang-builder -des -cs -rcf $(pwd)/configuration/runconfig/lane_0.properties ${CHANGES_PARAM} ;;
1) ./cslang-builder/bin/cslang-builder -des -cs -rcf $(pwd)/configuration/runconfig/lane_1.properties ${CHANGES_PARAM} ;;
2) ./cslang-builder/bin/cslang-builder -des -cs -rcf $(pwd)/configuration/runconfig/lane_2.properties ${CHANGES_PARAM} ;;
esac
: parallel: true
post:
- ? > ### machine 1
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_1}";
then chmod +x ci-env/circleci/cleanup_env.sh
&& DROPLETS_FILE=${DROPLETS_FILE_1} ci-env/circleci/cleanup_env.sh;
fi
: parallel: true
- ? > ### machine 2
if eval "${RULE_DROPLET_MACHINE_NOT_FORK_2}";
then chmod +x ci-env/circleci/cleanup_env.sh
&& DROPLETS_FILE=${DROPLETS_FILE_2} ci-env/circleci/cleanup_env.sh;
fi
: parallel: true
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ namespace: io.cloudslang.base.examples.yoda

properties:
- default_quote: 'false'
- file_path: '<yoda_file_path>'
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# (c) Copyright 2017 Hewlett-Packard Enterprise Development Company, L.P.
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Apache License v2.0 which accompany this distribution.
#
# The Apache License is available at
# http://www.apache.org/licenses/LICENSE-2.0
#
########################################################################################################################
# System property file for base.examples.yoda operations.
#
# io.cloudslang.base.examples.properties.default_quote: value of default quote
#
########################################################################################################################

namespace: io.cloudslang.base.examples.yoda

properties:
- file_path: '<yoda_file_path>'
9 changes: 2 additions & 7 deletions test/io/cloudslang/base/examples/quote_check.inputs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,18 @@ test_quote_check_sp_true:
testSuites: [default, yoda]
testFlowPath: test.io.cloudslang.base.examples.test_quote_check
systemPropertiesFile: ${project_path}/configuration/properties/io/cloudslang/base/examples/yoda/samples_true.prop.sl
inputs:
- file_path: ${project_path}/resources/base/examples/yoda/yoda_quotes.txt
result: SUCCESS_PRINTING_DEFAULT

test_quote_check_sp_false:
description: Tests that quote_check returns a random quote when the properties file is set on false
testSuites: [default, yoda]
testFlowPath: test.io.cloudslang.base.examples.test_quote_check
systemPropertiesFile: ${project_path}/configuration/properties/io/cloudslang/base/examples/yoda/samples_false.prop.sl
inputs:
- file_path: /resources/base/examples/yoda/yoda_quotes.txt
result: QUOTE_EXISTS

test_quote_check_sp_not_specified:
description: Tests that quote_check returns a random quote when the properties file is not specified
description: Tests that quote_check returns a random quote when the properties file for the default quote is not specified
testSuites: [default, yoda]
testFlowPath: test.io.cloudslang.base.examples.test_quote_check
inputs:
- file_path: /resources/base/examples/yoda/yoda_quotes.txt
systemPropertiesFile: ${project_path}/configuration/properties/io/cloudslang/base/examples/yoda/samples_none.prop.sl
result: QUOTE_EXISTS
2 changes: 1 addition & 1 deletion test/io/cloudslang/base/examples/test_quote_check.sl
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ flow:
- default_quote:
default: "Do or do not, there is no try!"
private: true
- file_path
- file_path : ${str(get_sp('io.cloudslang.base.examples.yoda.file_path'))}

workflow:
- check_system_property:
Expand Down

0 comments on commit 6be8554

Please sign in to comment.