From bd5a8b9f7628105dc80434f382ee1e0011fb74a9 Mon Sep 17 00:00:00 2001 From: Simon Stone Date: Thu, 18 Jun 2020 13:15:19 +0100 Subject: [PATCH] More fixes for automated integration test (contributes to #71) (#316) * Add missing Python dependencies (contributes to #71) Signed-off-by: Simon Stone * Add missing Fabric CLI dependency (contributes to #71) Signed-off-by: Simon Stone * Separate out timeouts into CI configuration (contributes to #71) Signed-off-by: Simon Stone * Rearrange pipeline configuration (contributes to #71) Signed-off-by: Simon Stone --- azure-pipelines.yml | 18 ++++++------- tests/integration/integration_config.yml | 2 ++ .../certificate_authority/tasks/main.yml | 27 ++++++++++++++++++- 3 files changed, 36 insertions(+), 11 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b4af88c9..916d3a1d 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -20,8 +20,10 @@ steps: inputs: versionSpec: "3.x" displayName: Use Python 3.x - - script: pip install ansible ansible-doc-extractor ansible-lint flake8 sphinx sphinx-rtd-theme yamllint yq + - script: pip install ansible ansible-doc-extractor ansible-lint flake8 fabric-sdk-py openshift python-pkcs11 sphinx sphinx-rtd-theme yamllint yq displayName: Install Python dependencies + - script: curl -sSL https://github.com/hyperledger/fabric/releases/download/v1.4.7/hyperledger-fabric-linux-amd64-1.4.7.tar.gz | sudo tar xzf - -C /usr/local + displayName: Install Fabric CLI - script: | set -ex curl -sL https://ibm.biz/idt-installer | bash @@ -32,7 +34,11 @@ steps: displayName: Install IBM Cloud and OpenShift CLI - script: | set -ex - ansible-galaxy collection build + ibmcloud login --apikey $(IBM Cloud API Key) -c $(IBM Cloud Account) -r $(IBM Cloud Region) + ibmcloud oc cluster config -c $(IBM Cloud OpenShift Cluster ID) + oc login -u apikey -p $(IBM Cloud API Key) + displayName: Log in to IBM Cloud + - script: ansible-galaxy collection build displayName: Build collection artifact - script: | set -ex @@ -53,13 +59,6 @@ steps: shellcheck tutorial/*.sh yamllint . displayName: Lint collection - - script: | - set -ex - ibmcloud login --apikey $(IBM Cloud API Key) -c $(IBM Cloud Account) -r $(IBM Cloud Region) - ibmcloud oc cluster config -c $(IBM Cloud OpenShift Cluster ID) - oc login -u apikey -p $(IBM Cloud API Key) - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) - displayName: Log in to IBM Cloud - script: | set -ex cd ~/.ansible/collections/ansible_collections/ibm/blockchain_platform @@ -73,7 +72,6 @@ steps: yq -yi .test_run_id=\"${TEST_RUN_ID}\" tests/integration/integration_config.yml yq -yi .short_test_run_id=\"${SHORT_TEST_RUN_ID}\" tests/integration/integration_config.yml ansible-test integration - condition: and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/master')) displayName: Run tests - script: | set -ex diff --git a/tests/integration/integration_config.yml b/tests/integration/integration_config.yml index 6e610044..a0ee420d 100644 --- a/tests/integration/integration_config.yml +++ b/tests/integration/integration_config.yml @@ -6,6 +6,8 @@ api_endpoint: https://ibp-console.example.org:32000 api_authtype: basic api_key: xxxxxxxx api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +api_timeout: 60 k8s_namespace: ibp test_run_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx short_test_run_id: xxxxxxxx +wait_timeout: 600 diff --git a/tests/integration/targets/certificate_authority/tasks/main.yml b/tests/integration/targets/certificate_authority/tasks/main.yml index a34545a8..ed917dc1 100644 --- a/tests/integration/targets/certificate_authority/tasks/main.yml +++ b/tests/integration/targets/certificate_authority/tasks/main.yml @@ -9,6 +9,7 @@ api_authtype: "{{ api_authtype | mandatory }}" api_key: "{{ api_key | mandatory }}" api_secret: "{{ api_secret | mandatory }}" + api_timeout: "{{ api_timeout | mandatory }}" ca_name: "Test CA {{ short_test_run_id }}" ca_config_override: ca: @@ -29,7 +30,7 @@ hf.AffiliationMgr: true k8s_namespace: "{{ k8s_namespace | mandatory }}" k8s_name: "testca{{ short_test_run_id }}" - wait_timeout: 600 + wait_timeout: "{{ wait_timeout | mandatory }}" - name: Run tests block: @@ -95,6 +96,30 @@ expected_storage_class: default expected_storage_size: 20Gi + - name: Ensure idempotency + ibm.blockchain_platform.certificate_authority: + state: present + <<: *ibp_connection_info + name: "{{ ca_name }}" + config_override: "{{ ca_config_override }}" + resources: + ca: + requests: + cpu: 200m + memory: 400M + wait_timeout: "{{ wait_timeout }}" + register: result + + - include_tasks: assertions.yml + vars: + expected_change: no + expected_enrollment_id: admin + expected_enrollment_secret: adminpw + expected_cpu: 200m + expected_memory: 400M + expected_storage_class: default + expected_storage_size: 20Gi + always: - name: Delete certificate authority ibm.blockchain_platform.certificate_authority: