forked from IBM-Blockchain/ansible-collection
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First integration test (contributes to IBM-Blockchain#71)
Signed-off-by: Simon Stone <[email protected]>
- Loading branch information
Simon Stone
committed
Jun 17, 2020
1 parent
5ed5b2f
commit fcb8a00
Showing
5 changed files
with
172 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
api_endpoint: https://ibp-console.example.org:32000 | ||
api_authtype: basic | ||
api_key: xxxxxxxx | ||
api_secret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
k8s_namespace: ibp | ||
test_run_id: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx | ||
short_test_run_id: xxxxxxxx |
39 changes: 39 additions & 0 deletions
39
tests/integration/targets/certificate_authority/tasks/assertions.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- assert: | ||
that: | ||
- result is success | ||
- "result is {{ 'changed' if expected_change else 'not changed' }}" | ||
- result.certificate_authority.name == ca_name | ||
|
||
- uri: | ||
url: "{{ result.certificate_authority.api_url }}/cainfo" | ||
validate_certs: no | ||
until: result.status == 200 | ||
retries: 60 | ||
delay: 1 | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result.json.result.CAChain is defined | ||
|
||
- k8s_info: | ||
api_version: ibp.com/v1alpha1 | ||
kind: IBPCA | ||
namespace: "{{ k8s_namespace }}" | ||
name: "{{ k8s_name }}" | ||
register: result | ||
|
||
- assert: | ||
that: | ||
- result is success | ||
- result.resources | ||
- result.resources[0].spec.configoverride.ca.registry.identities[0].name == expected_enrollment_id | ||
- result.resources[0].spec.configoverride.ca.registry.identities[0].pass == expected_enrollment_secret | ||
- result.resources[0].spec.resources.ca.requests.cpu == expected_cpu | ||
- result.resources[0].spec.resources.ca.requests.memory == expected_memory | ||
- result.resources[0].spec.storage.ca.class == expected_storage_class | ||
- result.resources[0].spec.storage.ca.size == expected_storage_size |
103 changes: 103 additions & 0 deletions
103
tests/integration/targets/certificate_authority/tasks/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
# | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
--- | ||
- name: Set test facts | ||
set_fact: | ||
ibp_connection_info: &ibp_connection_info | ||
api_endpoint: "{{ api_endpoint | mandatory }}" | ||
api_authtype: "{{ api_authtype | mandatory }}" | ||
api_key: "{{ api_key | mandatory }}" | ||
api_secret: "{{ api_secret | mandatory }}" | ||
ca_name: "Test CA {{ short_test_run_id }}" | ||
ca_config_override: | ||
ca: | ||
registry: | ||
maxenrollments: -1 | ||
identities: | ||
- name: admin | ||
pass: adminpw | ||
type: client | ||
maxenrollments: -1 | ||
attrs: | ||
hf.Registrar.Roles: "*" | ||
hf.Registrar.DelegateRoles: "*" | ||
hf.Revoker: true | ||
hf.IntermediateCA: true | ||
hf.GenCRL: true | ||
hf.Registrar.Attributes: "*" | ||
hf.AffiliationMgr: true | ||
k8s_namespace: "{{ k8s_namespace | mandatory }}" | ||
k8s_name: "testca{{ short_test_run_id }}" | ||
wait_timeout: 600 | ||
|
||
- name: Run tests | ||
block: | ||
- name: Create certificate authority | ||
ibm.blockchain_platform.certificate_authority: | ||
state: present | ||
<<: *ibp_connection_info | ||
name: "{{ ca_name }}" | ||
config_override: "{{ ca_config_override }}" | ||
wait_timeout: "{{ wait_timeout }}" | ||
register: result | ||
|
||
- include_tasks: assertions.yml | ||
vars: | ||
expected_change: yes | ||
expected_enrollment_id: admin | ||
expected_enrollment_secret: adminpw | ||
expected_cpu: 100m | ||
expected_memory: 200M | ||
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 }}" | ||
wait_timeout: "{{ wait_timeout }}" | ||
register: result | ||
|
||
- include_tasks: assertions.yml | ||
vars: | ||
expected_change: no | ||
expected_enrollment_id: admin | ||
expected_enrollment_secret: adminpw | ||
expected_cpu: 100m | ||
expected_memory: 200M | ||
expected_storage_class: default | ||
expected_storage_size: 20Gi | ||
|
||
- name: Change resources | ||
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: yes | ||
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: | ||
state: absent | ||
<<: *ibp_connection_info | ||
name: "{{ ca_name }}" |