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
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 Library cluster.cluster.Cluster WITH NAME Cluster
18 Library crl.remotesession.remotesession.RemoteSession
19 ... WITH NAME RemoteSession
21 Test Setup ssh.Setup Connections
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
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}
37 Push Custom Metrics Image
38 [Arguments] ${node}=sudo-default
39 ${cmd}= docker push ${docker_image}
40 ${output}= Ssh.Execute Command ${cmd} ${node}
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}
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}
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}
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}
67 Custom Metrics Teardown
68 Delete Custom Metrics Pod
69 Delete Custom Metrics Image
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
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"