upload pm-support
[ta/cloudtaf.git] / testcases / pm-support / pm-suppot.robot
1 # Copyright 2019 Nokia
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          ssh.Setup Connections
22
23 *** Variables ***
24 ${docker_image_name}            registry.kube-system.svc.rec.io:5555/custom_metrics_test
25 ${docker_image_tag}             0.1
26 ${docker_image}                 ${docker_image_name}:${docker_image_tag}
27 ${test_base_dir}                /cloudtaf/testcases/pm-support/misc
28 ${custom_metrics_yaml_name}     custom-metrics-test-dep.yaml
29 ${custom_metrics_pod_name}      custommetrics
30
31 *** Keywords ***
32 Create Custom Metrics Docker Image
33     [Arguments]    ${node}=sudo-default
34     ${cmd}=        cd ${test_base_dir} | docker build --network=host --no-cache --force-rm --tag ${docker_image_name}:${docker_image_tag} .
35     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
36
37 Push Custom Metrics Image
38     [Arguments]    ${node}=sudo-default
39     ${cmd}=        docker push ${docker_image}
40     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
41
42 Delete Custom Metrics Image
43     [Arguments]    ${node}=sudo-default
44     ${cmd}=        docker rmi ${docker_image} ${docker_image}
45     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
46
47 Delete Custom Metrics Pod
48     [Arguments]    ${node}=sudo-default
49     ${cmd}=        kubectl delete pod ${custom_metrics_pod_name}
50     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
51
52 Apply deployment yaml
53     [Arguments]    ${node}=sudo-default
54     ${cmd}=        kubectl apply -f ${test_base_dir}/${custom_metrics_yaml_name}
55     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
56     ${cmd}=        kubectl get po -n kube-system | grep ${custom_metrics_pod_name}
57     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
58     Should not be empty     ${output.stdout}
59
60 Check custom metrics
61     [Arguments]    ${node}=sudo-default
62     ${cmd}=    Set Variable    kubectl get --raw "/apis/custom.metrics.k8s.io/v1beta1
63     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
64     ${cmd}=    Set Variable    kubectl get –raw "/apis/custom.metrics.k8s.io/v1beta1/namespaces/kube-system/pods/*/http_requests
65     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
66
67 Custom Metrics Teardown
68     Delete Custom Metrics Pod
69     Delete Custom Metrics Image
70
71 Check kubectl api
72     [Arguments]    ${node}=sudo-default
73     ${cmd}=    Set Variable    kubectl api-versions | grep metrics
74     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
75     Should Contain   ${output}       custom.metrics.k8s.io/v1beta1
76     Should Contain   ${output}       metrics.k8s.io/v1beta1
77
78 Check Core Metrics
79     [Arguments]    ${node}=sudo-default
80     ${cmd}=    Set Variable    kubectl top node
81     ${output}=     Ssh.Execute Command    ${cmd}      ${node}
82     Should Not Contain   ${output}       " 0m"
83     Should Not Contain   ${output}       " 0Mi"
84
85
86 *** Test Cases ***
87
88 PM001
89     Check Core Metrics
90
91 PM002
92     Check kubectl api
93