Skip to content

Commit

Permalink
test #4
Browse files Browse the repository at this point in the history
  • Loading branch information
IkaDemisto committed Apr 30, 2020
1 parent f1d3965 commit 38a3f08
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 339 deletions.
338 changes: 0 additions & 338 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -96,77 +96,6 @@ jobs:
exit 0
fi
demisto-sdk create-id-set -o ./Tests/id_set.json
- run:
name: Infrastructure testing
when: always
command: |
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build or unit-tests container"
exit 0
fi
python3 -m pytest ./Tests/scripts/infrastructure_tests/mock_unit_test.py -v
python3 -m pytest ./Tests/scripts/infrastructure_tests/release_notes_test.py -v
python3 -m pytest ./Tests/scripts/infrastructure_tests/test_configure_tests.py -v
python3 -m pytest ./Tests/Marketplace/Tests/marketplace_services_test.py -v
python3 -m pytest ./Tests/Marketplace/Tests/upload_packs_test.py -v
python3 -m pytest ./Tests/Marketplace/Tests/search_and_install_packs_test.py -v
- run:
name: Validate Files and Yaml
when: always
command: |
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build or unit-tests container"
exit 0
fi
# Run flake8 on all excluding Integraions and Scripts (they will be handled in linting)
./Tests/scripts/pyflake.sh *.py
find . -maxdepth 1 -type d -not \( -path . -o -path ./Integrations -o -path ./Scripts -o -path ./Beta_Integrations -o -path ./venv \) | xargs ./Tests/scripts/pyflake.sh
[ -n "${BACKWARD_COMPATIBILITY}" ] && CHECK_BACKWARD="false" || CHECK_BACKWARD="true"
if [ "${CHECK_BACKWARD}" = "true" ] ;
then
demisto-sdk validate -g --post-commit
else
demisto-sdk validate -g --post-commit --no-backward-comp
fi
- run:
name: Secrets
when: always
command: |
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build or unit-tests container"
exit 0
fi
demisto-sdk secrets --post-commit --ignore-entropy
- run:
name: Configure Test Filter
when: always
command: |
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build or unit-tests container"
exit 0
fi
[ -n "${NIGHTLY}" ] && IS_NIGHTLY=true || IS_NIGHTLY=false
python3 ./Tests/scripts/configure_tests.py -n $IS_NIGHTLY
- run:
name: Spell Checks
command: |
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build or unit-tests container"
exit 0
fi
python3 ./Tests/scripts/circleci_spell_checker.py $CIRCLE_BRANCH
- run:
name: Build Content Descriptor
when: always
Expand Down Expand Up @@ -298,277 +227,10 @@ jobs:
else
./Tests/lastest_server_build_scripts/download_demisto_conf.sh
fi
- run:
name: Create Instance
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo 'Skipping - running only in container number 0.'
exit 0;
fi
if ./Tests/scripts/is_ami.sh ;
then
if [ -n "${NIGHTLY}" ] ;
then
export IFRA_ENV_TYPE=Nightly # disable-secrets-detection
elif [ -n "${INSTANCE_TESTS}" ] ;
then
export IFRA_ENV_TYPE="Demisto PreGA" # disable-secrets-detection
else
export IFRA_ENV_TYPE=Content-Env # disable-secrets-detection
fi
python3 ./Tests/scripts/awsinstancetool/aws_instance_tool.py -envType "$IFRA_ENV_TYPE" -outfile ./env_results.json
else
python3 ./Tests/scripts/awsinstancetool/aws_instance_tool.py -envType CustomBuild -outfile ./env_results.json
fi
- run:
name: Setup Instance
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo 'Skipping - running only in container number 0.'
exit 0;
fi
if ./Tests/scripts/is_ami.sh ;
then
python3 ./Tests/scripts/run_content_installation.py
else
./Tests/lastest_server_build_scripts/run_installer_on_instance.sh
fi
python3 ./Tests/scripts/wait_until_server_ready.py
- run:
name: Run Tests - Latest GA
shell: /bin/bash
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] || [ -n "${NIGHTLY}" ];
then
echo "Skipping - not running in INSTANCE_TESTS build, unit-tests container or Nightly run"
exit 0
fi
export TEMP=$(cat ./Tests/filter_envs.json | jq '."Demisto GA"')
echo "Demisto GA filter=$TEMP"
if [[ "$TEMP" == "false" ]];
then
echo "Skipping - instance was not setup"
exit 0
fi
if ./Tests/scripts/is_ami.sh ;
then
./Tests/scripts/run_tests.sh "Demisto GA"
else
./Tests/lastest_server_build_scripts/run_tests.sh
fi
- run:
name: Run Tests - One Before GA
shell: /bin/bash
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] || [ -n "${NIGHTLY}" ];
then
echo "Skipping - not running in INSTANCE_TESTS build, unit-tests container or Nightly run"
exit 0
fi
export TEMP=$(cat ./Tests/filter_envs.json | jq '."Demisto one before GA"')
echo "Demisto one before GA filter=$TEMP"
if [[ "$TEMP" == "false" ]];
then
echo "Skipping - instance was not setup"
exit 0
fi
if ./Tests/scripts/is_ami.sh ;
then
./Tests/scripts/run_tests.sh "Demisto one before GA"
else
echo "Not AMI run, can't run on this version"
fi
- run:
name: Run Tests - Two Before GA
shell: /bin/bash
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] || [ -n "${NIGHTLY}" ];
then
echo "Skipping - not running in INSTANCE_TESTS build, unit-tests container or Nightly run"
exit 0
fi
export TEMP=$(cat ./Tests/filter_envs.json | jq '."Demisto two before GA"')
echo "Demisto two before GA filter=$TEMP"
if [[ "$TEMP" == "false" ]];
then
echo "Skipping - instance was not setup"
exit 0
fi
if ./Tests/scripts/is_ami.sh ;
then
./Tests/scripts/run_tests.sh "Demisto two before GA"
else
echo "Not AMI run, can't run on this version"
fi
- run:
name: Run Tests - Server Master
shell: /bin/bash
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] || [ -n "${NIGHTLY}" ];
then
echo "Skipping - not running in INSTANCE_TESTS build, unit-tests container or Nightly run"
exit 0
fi
export TEMP=$(cat ./Tests/filter_envs.json | jq '."Server Master"')
echo "Server Master filter=$TEMP"
if [[ "$TEMP" == "false" ]];
then
echo "Skipping - instance was not setup"
exit 0
fi
if ./Tests/scripts/is_ami.sh ;
then
./Tests/scripts/run_tests.sh "Server Master"
else
echo "Not AMI run, can't run on this version"
fi
- run:
name: Run Tests - Demisto PreGA
shell: /bin/bash
when: always
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ -n "${INSTANCE_TESTS}" ] || [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build or unit-tests container"
exit 0
fi
export TEMP=$(cat ./Tests/filter_envs.json | jq '."Demisto PreGA"')
echo "Demisto PreGA filter=$TEMP"
if [[ "$TEMP" == "false" ]];
then
echo "Skipping - instance was not setup"
exit 0
fi
if ./Tests/scripts/is_ami.sh ;
then
./Tests/scripts/run_tests.sh "Demisto PreGA"
export RETVAL=$?
cp ./Tests/failed_tests.txt $CIRCLE_ARTIFACTS/failed_tests.txt
exit $RETVAL
else
echo "Not AMI run, can't run on this version"
fi
- store_artifacts:
path: artifacts
destination: artifacts
when: always
- run:
name: Slack Notifier
shell: /bin/bash
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ -n "${INSTANCE_TESTS}" ] ;
then
echo "Skipping - not running in INSTANCE_TESTS build"
exit 0
fi
./Tests/scripts/slack_notifier.sh $CIRCLE_NODE_INDEX ./env_results.json
when: always
- run:
name: Instance Test
command: |
if [ -n "${INSTANCE_TESTS}" ] && [ $CIRCLE_NODE_INDEX -ne 1 ] ;
then
./Tests/scripts/instance_test.sh
else
echo "Skipping instance tests"
exit 0
fi
when: always
- run:
name: Destroy Instances
command: |
if [[ $CIRCLE_BRANCH =~ pull/[0-9]+ ]]; then
echo "Skipping instance tests for forked PRs"
exit 0
fi
if [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo 'Skipping - running only in container number 0.'
exit 0;
else
python3 ./Tests/scripts/destroy_instances.py $CIRCLE_ARTIFACTS ./env_results.json
export PSWD=$(jq .serverLogsZipPassword < $(cat secret_conf_path) | cut -d \" -f 2)
zip -P $PSWD $CIRCLE_ARTIFACTS/ServerLogs.zip $CIRCLE_ARTIFACTS/server*.log
rm -f $CIRCLE_ARTIFACTS/server*.log
fi
when: always
- run:
name: Upload Packs To Marketplace Storage
command: |
if [[ $CIRCLE_BRANCH != master ]]; then
echo "Skipping packs uploading on non master branch"
exit 0
fi
if [ $CIRCLE_NODE_INDEX -ne 0 ] ;
then
echo 'Skipping - running only in container number 0.'
exit 0;
fi
EXTRACT_FOLDER=$(mktemp -d)
PACK_ARTIFACTS=$CIRCLE_ARTIFACTS/content_packs.zip
GCS_PATH=$(mktemp)
echo $GCS_MARKET_KEY > $GCS_PATH
python3 ./Tests/Marketplace/upload_packs.py -a $PACK_ARTIFACTS -e $EXTRACT_FOLDER -b 'marketplace-dist' -s $GCS_PATH -n $CIRCLE_BUILD_NUM -k $PACK_SIGNING_KEY -p 'All' -pb 'marketplace-dist-private' -o
rm $GCS_PATH
when: on_success
- store_artifacts:
path: artifacts
destination: artifacts
when: always
- run:
name: Store Artifacts to GCS
command: ./Tests/scripts/upload_artifacts.sh
when: always

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion dev-requirements-py3.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
flake8==3.7.9
bandit==1.6.2
demisto-py==2.0.9
demisto-sdk==0.5.4
git+https://github.com/demisto/demisto-sdk@common_docs_packs
pytest==5.2.1
pytest-mock==1.11.1
requests-mock==1.7.0
Expand Down

0 comments on commit 38a3f08

Please sign in to comment.