Update k8s tests to check cluster creation inside testsuite
[osm/tests.git] / robot-systest / testsuite / k8s_02-k8scluster_creation.robot
1 *** Comments ***
2 # Copyright 2020 Canonical Ltd.
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15
16
17 *** Settings ***
18 Documentation   [K8s-02] K8s cluster addition.
19
20 Library   OperatingSystem
21 Library   String
22 Library   Collections
23 Library   Process
24
25 Resource   ../lib/k8scluster_lib.resource
26 Resource   ../lib/vim_lib.resource
27
28 Variables   ../resources/basic_01-crud_operations_on_vim_targets_data.py
29
30 Test Tags   k8s_02   cluster_k8s   daily   regression   azure
31
32 Suite Teardown   Run Keyword And Ignore Error   Suite Cleanup
33
34
35 *** Variables ***
36 # K8s cluster name and version
37 ${K8SCLUSTER_NAME}   k8s02
38 ${K8SCLUSTER_VERSION}   v1
39
40
41 *** Test Cases ***
42 Create VIM Target Basic
43     [Documentation]   Creates a VIM for the K8s cluster to be anchored against
44     ${rand}=   Generate Random String   6   [NUMBERS]
45     ${VIM_NAME}=   Catenate   SEPARATOR=_   ${vim_name_prefix}   ${rand}
46     Set Suite Variable   ${VIM_NAME}
47     ${CREATED_VIM_ACCOUNT_ID}=   Create VIM Target   ${VIM_NAME}   ${VIM_USER}   ${VIM_PASSWORD}   ${VIM_AUTH_URL}   ${VIM_TENANT}   ${VIM_ACCOUNT_TYPE}
48     Set Suite Variable   ${CREATED_VIM_ACCOUNT_ID}
49
50 Add K8s Cluster To OSM
51     [Documentation]   Creates a VIM for the K8s cluster to be anchored against
52     Create K8s Cluster   %{K8S_CREDENTIALS}   ${K8SCLUSTER_VERSION}   ${VIM_NAME}   %{VIM_MGMT_NET}   ${K8SCLUSTER_NAME}
53     Check For K8s Cluster To Be Ready   ${K8SCLUSTER_NAME}
54
55 Remove K8s Cluster from OSM
56     [Documentation]   Delete K8s cluster.
57     [Tags]   cleanup
58     Delete K8s Cluster   ${K8SCLUSTER_NAME}
59
60 Delete VIM Target By ID
61     [Documentation]   Delete the VIM Target created in previous test-case by its ID.
62     ...               Checks whether the VIM Target was created or not before perform the deletion.
63     [Tags]   cleanup
64
65     ${vim_account_id}=   Get VIM Target ID   ${VIM_NAME}
66     Should Be Equal As Strings   ${vim_account_id}   ${CREATED_VIM_ACCOUNT_ID}
67     Delete VIM Target   ${vim_account_id}
68
69
70 *** Keywords ***
71 Suite Cleanup
72     [Documentation]   Test Suit Cleanup: Deleting K8s Cluster
73
74     Run Keyword If Any Tests Failed   Delete K8s Cluster   ${K8SCLUSTER_NAME}