kubectl describe <kind> work with no arguments
Add describe_resource_assert to test describe <kind> with no object arg
This commit is contained in:
@@ -79,3 +79,31 @@ kube::test::describe_object_assert() {
|
||||
echo -n ${reset}
|
||||
return 0
|
||||
}
|
||||
|
||||
kube::test::describe_resource_assert() {
|
||||
local resource=$1
|
||||
local matches=${@:2}
|
||||
|
||||
result=$(eval kubectl describe "${kube_flags[@]}" $resource)
|
||||
|
||||
for match in ${matches}; do
|
||||
if [[ ! $(echo "$result" | grep ${match}) ]]; then
|
||||
echo ${bold}${red}
|
||||
echo "FAIL!"
|
||||
echo "Describe $resource"
|
||||
echo " Expected Match: $match"
|
||||
echo " Not found in:"
|
||||
echo "$result"
|
||||
echo ${reset}${red}
|
||||
caller
|
||||
echo ${reset}
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
|
||||
echo -n ${green}
|
||||
echo "Successful describe $resource:"
|
||||
echo "$result"
|
||||
echo -n ${reset}
|
||||
return 0
|
||||
}
|
||||
|
@@ -236,6 +236,8 @@ runTests() {
|
||||
kube::test::get_object_assert 'pods/valid-pod' "{{$id_field}}" 'valid-pod'
|
||||
# Describe command should print detailed information
|
||||
kube::test::describe_object_assert pods 'valid-pod' "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Replication Controllers"
|
||||
# Describe command (resource only) should print detailed information
|
||||
kube::test::describe_resource_assert pods "Name:" "Image(s):" "Node:" "Labels:" "Status:" "Replication Controllers"
|
||||
|
||||
### Dump current valid-pod POD
|
||||
output_pod=$(kubectl get pod valid-pod -o yaml --output-version=v1 "${kube_flags[@]}")
|
||||
@@ -493,6 +495,8 @@ runTests() {
|
||||
kube::test::get_object_assert services "{{range.items}}{{$id_field}}:{{end}}" 'kubernetes:redis-master:'
|
||||
# Describe command should print detailed information
|
||||
kube::test::describe_object_assert services 'redis-master' "Name:" "Labels:" "Selector:" "IP:" "Port:" "Endpoints:" "Session Affinity:"
|
||||
# Describe command (resource only) should print detailed information
|
||||
kube::test::describe_resource_assert services "Name:" "Labels:" "Selector:" "IP:" "Port:" "Endpoints:" "Session Affinity:"
|
||||
|
||||
### Dump current redis-master service
|
||||
output_service=$(kubectl get service redis-master -o json --output-version=v1 "${kube_flags[@]}")
|
||||
@@ -592,6 +596,8 @@ __EOF__
|
||||
kube::test::get_object_assert rc "{{range.items}}{{$id_field}}:{{end}}" 'frontend:'
|
||||
# Describe command should print detailed information
|
||||
kube::test::describe_object_assert rc 'frontend' "Name:" "Image(s):" "Labels:" "Selector:" "Replicas:" "Pods Status:"
|
||||
# Describe command (resource only) should print detailed information
|
||||
kube::test::describe_resource_assert rc "Name:" "Name:" "Image(s):" "Labels:" "Selector:" "Replicas:" "Pods Status:"
|
||||
|
||||
### Scale replication controller frontend with current-replicas and replicas
|
||||
# Pre-condition: 3 replicas
|
||||
@@ -740,6 +746,8 @@ __EOF__
|
||||
kube::test::get_object_assert nodes "{{range.items}}{{$id_field}}:{{end}}" '127.0.0.1:'
|
||||
|
||||
kube::test::describe_object_assert nodes "127.0.0.1" "Name:" "Labels:" "CreationTimestamp:" "Conditions:" "Addresses:" "Capacity:" "Pods:"
|
||||
# Describe command (resource only) should print detailed information
|
||||
kube::test::describe_resource_assert nodes "Name:" "Labels:" "CreationTimestamp:" "Conditions:" "Addresses:" "Capacity:" "Pods:"
|
||||
|
||||
### kubectl patch update can mark node unschedulable
|
||||
# Pre-condition: node is schedulable
|
||||
|
Reference in New Issue
Block a user