From 108ac7c21637cd734dfe8a69ccd73528c85f6f91 Mon Sep 17 00:00:00 2001 From: Felipe Monteiro Date: Thu, 14 Jun 2018 14:16:33 -0400 Subject: [PATCH] Add functional test for validating single source multi dest substitution This patchset fixes a schema bug to allow for single source multi dest substitution to work (it is currently rendering successfully but failing on validation as the base Deckhand validation schema was not updated). This adds a functional test to avoid regression. Also fixes failed_when condition for functional-tests and integration-tests roles to check if 'commands failed' appears in stdout which only happens when pytest runner fails. Change-Id: I9bb0c51b3374bbaf9fd34d5f93f1a1777bb3b1e8 --- deckhand/engine/schemas/base_schema.yaml | 25 ++++-- .../substitution-source-feeds-multi-dest.yaml | 82 +++++++++++++++++++ .../tasks/functional-tests.yaml | 2 +- .../tasks/integration-tests.yaml | 2 +- 4 files changed, 100 insertions(+), 11 deletions(-) create mode 100644 deckhand/tests/functional/gabbits/substitution/substitution-source-feeds-multi-dest.yaml diff --git a/deckhand/engine/schemas/base_schema.yaml b/deckhand/engine/schemas/base_schema.yaml index 93830034..49b3a401 100644 --- a/deckhand/engine/schemas/base_schema.yaml +++ b/deckhand/engine/schemas/base_schema.yaml @@ -35,6 +35,16 @@ data: actions: required: - parentSelector + substitution_dest: + type: object + properties: + path: + type: string + pattern: + type: string + additionalProperties: false + required: + - path properties: schema: @@ -92,15 +102,12 @@ data: type: object properties: dest: - type: object - properties: - path: - type: string - pattern: - type: string - additionalProperties: false - required: - - path + anyOf: + - $ref: "#/definitions/substitution_dest" + - type: array + minItems: 1 + items: + $ref: "#/definitions/substitution_dest" src: type: object properties: diff --git a/deckhand/tests/functional/gabbits/substitution/substitution-source-feeds-multi-dest.yaml b/deckhand/tests/functional/gabbits/substitution/substitution-source-feeds-multi-dest.yaml new file mode 100644 index 00000000..2eddf647 --- /dev/null +++ b/deckhand/tests/functional/gabbits/substitution/substitution-source-feeds-multi-dest.yaml @@ -0,0 +1,82 @@ +# Tests success path for substitutions involving a single substitution source +# feeding multiple destionation paths. +# +# 1. Purges existing data to ensure test isolation +# 2. Creates necessary substitution documents. +# 3. Validates that the destination document has the expected data across all +# expected destination paths. + +defaults: + request_headers: + content-type: application/x-yaml + response_headers: + content-type: application/x-yaml + verbose: true + +tests: + - name: purge + desc: Begin testing from known state. + DELETE: /api/v1.0/revisions + status: 204 + response_headers: null + + - name: add_substitution_source_with_single_source_multi_dest + desc: |- + Create documents to test a single substitution source document feeding + multiple destination paths. + PUT: /api/v1.0/buckets/a/documents + status: 200 + data: |- + --- + schema: deckhand/LayeringPolicy/v1 + metadata: + schema: metadata/Control/v1 + name: layering-policy + data: + layerOrder: + - site + --- + schema: deckhand/Certificate/v1 + metadata: + name: example-cert + schema: metadata/Document/v1 + layeringDefinition: + layer: site + storagePolicy: cleartext + data: | + CERTIFICATE DATA + --- + schema: armada/Chart/v1 + metadata: + name: example-chart-01 + schema: metadata/Document/v1 + layeringDefinition: + layer: site + substitutions: + - dest: + - path: .chart.values.tls.certificate + - path: .chart.values.tls.duplicate_certificate + src: + schema: deckhand/Certificate/v1 + name: example-cert + path: . + data: {} + ... + + - name: verify_substitutions + desc: Check for expected substitutions + GET: /api/v1.0/revisions/$RESPONSE['$.[0].status.revision']/rendered-documents + query_parameters: + schema: armada/Chart/v1 + status: 200 + response_multidoc_jsonpaths: + $.`len`: 1 + $.[*].metadata.name: example-chart-01 + $.[*].data: + chart: + values: + tls: + certificate: | + CERTIFICATE DATA + duplicate_certificate: | + CERTIFICATE DATA diff --git a/tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml b/tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml index f7899774..45ef6e1a 100644 --- a/tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml +++ b/tools/gate/roles/run-functional-tests/tasks/functional-tests.yaml @@ -22,4 +22,4 @@ DECKHAND_TEST_URL: "127.0.0.1:9000" DECKHAND_TEST_DIR: "{{ airship_deckhand_path.stdout }}/deckhand/tests/functional/gabbits" register: result - failed_when: "'Done SUCCESS' not in result.stdout and 'PASSED' not in result.stdout" + failed_when: "'commands failed' in result.stdout" diff --git a/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml b/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml index b055667c..03118b53 100644 --- a/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml +++ b/tools/gate/roles/run-integration-tests/tasks/integration-tests.yaml @@ -27,4 +27,4 @@ DECKHAND_TEST_URL: "127.0.0.1:9000" DECKHAND_TEST_DIR: "{{ airship_deckhand_path.stdout }}/deckhand/tests/integration/gabbits" register: result - failed_when: "'Done SUCCESS' not in result.stdout and 'PASSED' not in result.stdout" + failed_when: "'commands failed' in result.stdout"