ansible/test/integration/targets/gcp_mlengine_version/tasks/main.yml

156 lines
5 KiB
YAML
Raw Normal View History

---
# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file at
# https://www.github.com/GoogleCloudPlatform/magic-modules
#
# ----------------------------------------------------------------------------
# Pre-test setup
- name: create a model
gcp_mlengine_model:
name: model_version
description: My model
regions:
- us-central1
online_prediction_logging: 'true'
online_prediction_console_logging: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: model
- name: delete a version
gcp_mlengine_version:
name: "{{ resource_name | replace('-', '_') }}"
model: "{{ model }}"
runtime_version: 1.13
python_version: 3.5
is_default: 'true'
deployment_uri: gs://ansible-cloudml-bucket/
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
#----------------------------------------------------------
- name: create a version
gcp_mlengine_version:
name: "{{ resource_name | replace('-', '_') }}"
model: "{{ model }}"
runtime_version: 1.13
python_version: 3.5
is_default: 'true'
deployment_uri: gs://ansible-cloudml-bucket/
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: result
- name: assert changed is true
assert:
that:
- result.changed == true
- name: verify that version was created
gcp_mlengine_version_facts:
model: "{{ model }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/cloud-platform
register: results
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 1
# ----------------------------------------------------------------------------
- name: create a version that already exists
gcp_mlengine_version:
name: "{{ resource_name | replace('-', '_') }}"
model: "{{ model }}"
runtime_version: 1.13
python_version: 3.5
is_default: 'true'
deployment_uri: gs://ansible-cloudml-bucket/
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: present
register: result
- name: assert changed is false
assert:
that:
- result.changed == false
#----------------------------------------------------------
- name: delete a version
gcp_mlengine_version:
name: "{{ resource_name | replace('-', '_') }}"
model: "{{ model }}"
runtime_version: 1.13
python_version: 3.5
is_default: 'true'
deployment_uri: gs://ansible-cloudml-bucket/
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: result
- name: assert changed is true
assert:
that:
- result.changed == true
- name: verify that version was deleted
gcp_mlengine_version_facts:
model: "{{ model }}"
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
scopes:
- https://www.googleapis.com/auth/cloud-platform
register: results
- name: verify that command succeeded
assert:
that:
- results['resources'] | map(attribute='name') | select("match", ".*{{ resource_name | replace('-', '_') }}.*") | list | length == 0
# ----------------------------------------------------------------------------
- name: delete a version that does not exist
gcp_mlengine_version:
name: "{{ resource_name | replace('-', '_') }}"
model: "{{ model }}"
runtime_version: 1.13
python_version: 3.5
is_default: 'true'
deployment_uri: gs://ansible-cloudml-bucket/
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: result
- name: assert changed is false
assert:
that:
- result.changed == false
#---------------------------------------------------------
# Post-test teardown
# If errors happen, don't crash the playbook!
- name: delete a model
gcp_mlengine_model:
name: model_version
description: My model
regions:
- us-central1
online_prediction_logging: 'true'
online_prediction_console_logging: 'true'
project: "{{ gcp_project }}"
auth_kind: "{{ gcp_cred_kind }}"
service_account_file: "{{ gcp_cred_file }}"
state: absent
register: model
ignore_errors: true