REC-11 Creating and testing Namespaces
[ta/cloudtaf.git] / testcases / kube-namespace / kube-namespace.robot
1 # Copyright 2019 AT&T
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 *** Settings ***
16 Library             Collections
17 Library             cluster.cluster.Cluster    WITH NAME    Cluster
18 Library             crl.remotesession.remotesession.RemoteSession
19 ...                 WITH NAME    RemoteSession
20 Resource            ssh.robot
21 Test Setup          Run Keywords
22 ...                 ssh.Setup Connections
23 ...                 Create Namespace
24 Test Teardown       Run Keywords
25 ...                 Delete Namespace
26
27 *** Keywords ***
28
29 Create Namespace
30     ${command}=    set variable    kubectl create namespace test-ns
31     ${out}=    ssh.Execute Command    ${command}    controller-1
32     log    ${out}
33     Should contain    ${out}    namespace/test-ns created
34     
35 Create pod in specific namespace
36     ${command}=    set variable    kubectl run --generator=run-pod/v1 my-pod --image=nginx --port=80 --namespace=test-ns
37     ${out}=    ssh.Execute Command    ${command}    controller-1
38     log    ${out}
39     Should contain    ${out}    pod/my-pod created
40
41 Check whether pod was created in specific namespace
42     ${command}=    set variable    kubectl describe pod my-pod -n test-ns
43     ${out}=    ssh.Execute Command    ${command}    controller-1
44     log    ${out}
45     Should contain    ${out}    test-ns
46
47 Delete pod
48     ${command}=    set variable    kubectl delete pod my-pod -n test-ns
49     ${out}=    ssh.Execute Command    ${command}    controller-1
50     log    ${out}
51     Should contain    ${out}    pod "my-pod" deleted
52
53 Delete Namespace
54     ${command}=    set variable    kubectl delete namespace test-ns
55     ${out}=    ssh.Execute Command    ${command}    controller-1
56     log    ${out}
57     Should contain    ${out}    namespace "test-ns" deleted
58
59 *** Test Cases ***
60
61 Verify creating and testing Namespaces
62     Create pod in specific namespace
63     Check whether pod was created in specific namespace
64     Delete pod