Browse Source

fix #28: smoketests are optional

pull/38/head
Nicolas Massé 7 years ago
parent
commit
a50a648e84
  1. 2
      .travis.yml
  2. 2
      defaults/main.yml
  3. 6
      tasks/main.yml
  4. 16
      tests/3scale-saas-with-hosted-apicast-with-smoketest-in-extra-vars.yaml
  5. 16
      tests/3scale-saas-with-hosted-apicast-without-smoketest.yaml
  6. 33
      tests/api/echo-api-bare.yaml

2
.travis.yml

@ -13,6 +13,8 @@ script:
- ansible-playbook -v -i tests/inventory tests/3scale-saas-with-hosted-apicast-oidc.yml
- ansible-playbook -v -i tests/inventory tests/3scale-saas-with-hosted-apicast-with-basePath.yml
- ansible-playbook -v -i tests/inventory tests/3scale-saas-with-hosted-apicast-multi-environment.yml
- ansible-playbook -v -i tests/inventory tests/3scale-saas-with-hosted-apicast-with-smoketest-in-extra-vars.yml
- ansible-playbook -v -i tests/inventory tests/3scale-saas-with-hosted-apicast-without-smoketest.yml
env:
global:
# travis encrypt "THREESCALE_INVENTORY=$(yaml2json tests/3scale-inventory.yaml|base64)"

2
defaults/main.yml

@ -48,7 +48,7 @@ threescale_cicd_default_application_appid: '{{ (threescale_cicd_default_applicat
threescale_cicd_default_application_appsecret: '{{ (''secret'' ~ threescale_cicd_default_application_name ~ threescale_cicd_api_system_name ~ threescale_cicd_access_token)|hash(''sha1'') }}'
# The OpenAPI Operation to use for the smoketest
threescale_cicd_openapi_smoketest_operation: '{{ threescale_cicd_openapi_file_content|json_query(''paths.*.get[? "x-threescale-smoketests-operation" ].operationId|[0]'')|default("")|regex_replace(''[^0-9a-zA-Z_]+'', ''_'') }}'
threescale_cicd_openapi_smoketest_operation: '{{ threescale_cicd_openapi_file_content|json_query(''paths.*.get[? "x-threescale-smoketests-operation" ].operationId'')|first|default("")|regex_replace(''[^0-9a-zA-Z_]+'', ''_'') }}'
##
## OpenAPI Specification File parsing

6
tasks/main.yml

@ -36,13 +36,13 @@
# Create or update the default application if smoke tests are needed
- include_tasks: steps/default_application.yml
when: 'threescale_cicd_openapi_smoketest_path is defined and threescale_cicd_application_plans is defined'
when: 'threescale_cicd_openapi_smoketest_operation|length > 0 and threescale_cicd_application_plans is defined'
# Run smoke tests on the staging gateway
- include_tasks: steps/smoke_test.yml
vars:
threescale_cicd_smoke_test_env: staging
when: 'threescale_cicd_openapi_smoketest_path is defined and threescale_cicd_application_plans is defined'
when: 'threescale_cicd_openapi_smoketest_operation|length > 0 and threescale_cicd_application_plans is defined'
# Promote to production
- import_tasks: steps/promote.yml
@ -51,7 +51,7 @@
- include_tasks: steps/smoke_test.yml
vars:
threescale_cicd_smoke_test_env: production
when: 'threescale_cicd_openapi_smoketest_path is defined and threescale_cicd_application_plans is defined'
when: 'threescale_cicd_openapi_smoketest_operation|length > 0 and threescale_cicd_application_plans is defined'
# Delete the metrics that are not needed anymore
- import_tasks: steps/cleanup_metrics.yml

16
tests/3scale-saas-with-hosted-apicast-with-smoketest-in-extra-vars.yaml

@ -0,0 +1,16 @@
---
- name: Deploy the Echo API to a 3scale SaaS instance, with hosted APIcasts and no smoketests
hosts: threescale
gather_facts: no
vars:
threescale_cicd_openapi_smoketest_operation: Echo
threescale_cicd_openapi_file: '{{ playbook_dir }}/api/echo-api-bare.yaml'
tasks:
# Deploy the service
- import_role:
name: 'nmasse-itix.threescale-cicd'
# Delete the service
- import_role:
name: 'nmasse-itix.threescale-cicd'
tasks_from: 'cleanup'

16
tests/3scale-saas-with-hosted-apicast-without-smoketest.yaml

@ -0,0 +1,16 @@
---
- name: Deploy the Echo API to a 3scale SaaS instance, with hosted APIcasts and no smoketests
hosts: threescale
gather_facts: no
vars:
# There is no "threescale_cicd_openapi_smoketest_operation" variable
threescale_cicd_openapi_file: '{{ playbook_dir }}/api/echo-api-bare.yaml'
tasks:
# Deploy the service
- import_role:
name: 'nmasse-itix.threescale-cicd'
# Delete the service
- import_role:
name: 'nmasse-itix.threescale-cicd'
tasks_from: 'cleanup'

33
tests/api/echo-api-bare.yaml

@ -0,0 +1,33 @@
swagger: '2.0'
info:
title: 'Echo API'
description: 'A very simple API.'
contact:
name: 'Nicolas MASSE'
url: 'http://github.com/nmasse-itix'
email: nmasse@redhat.com
license:
name: 'MIT License'
url: 'https://opensource.org/licenses/MIT'
version: '1.0'
host: 'echo-api.3scale.net'
schemes:
- http
paths:
/:
get:
operationId: Echo
tags:
- echo
summary: 'Get an echo'
description: 'Get an echo from the server'
responses:
200:
description: 'An Echo from the server'
security:
- apikey: []
securityDefinitions:
apikey:
name: api-key
in: header
type: apiKey
Loading…
Cancel
Save