add tests

This commit is contained in:
juanvallejo 2017-09-13 17:33:46 -04:00
parent e11a11140f
commit b6e8e209b3
No known key found for this signature in database
GPG Key ID: 7D2C958002D6448D

View File

@ -4214,35 +4214,57 @@ run_certificates_tests() {
} }
run_cluster_management_tests() { run_cluster_management_tests() {
set -o nounset set -o nounset
set -o errexit set -o errexit
kube::log::status "Testing cluster-management commands" kube::log::status "Testing cluster-management commands"
kube::test::get_object_assert nodes "{{range.items}}{{$id_field}}:{{end}}" '127.0.0.1:' kube::test::get_object_assert nodes "{{range.items}}{{$id_field}}:{{end}}" '127.0.0.1:'
### kubectl drain command fails when both --selector and a node argument are given ### kubectl cordon update with --dry-run does not mark node unschedulable
# Pre-condition: node exists and contains label test=label # Pre-condition: node is schedulable
kubectl label node "127.0.0.1" "test=label" kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
kube::test::get_object_assert "nodes 127.0.0.1" '{{.metadata.labels.test}}' 'label' kubectl cordon "127.0.0.1" --dry-run
response=$(! kubectl drain "127.0.0.1" --selector test=label 2>&1) kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
kube::test::if_has_string "${response}" 'cannot specify both a node name'
### kubectl cordon command fails when no arguments are passed ### kubectl drain update with --dry-run does not mark node unschedulable
# Pre-condition: node exists # Pre-condition: node is schedulable
response=$(! kubectl cordon 2>&1) kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
kube::test::if_has_string "${response}" 'error\: USAGE\: cordon NODE' kubectl drain "127.0.0.1" --dry-run
# Post-condition: node still exists, node is still schedulable
kube::test::get_object_assert nodes "{{range.items}}{{$id_field}}:{{end}}" '127.0.0.1:'
kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
### kubectl cordon selects all nodes with an empty --selector= ### kubectl uncordon update with --dry-run is a no-op
# Pre-condition: node "127.0.0.1" is uncordoned # Pre-condition: node is already schedulable
kubectl uncordon "127.0.0.1" kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
response=$(kubectl cordon --selector=) response=$(kubectl uncordon "127.0.0.1" --dry-run)
kube::test::if_has_string "${response}" 'node "127.0.0.1" cordoned' kube::test::if_has_string "${response}" 'already uncordoned'
# Post-condition: node "127.0.0.1" is cordoned # Post-condition: node is still schedulable
kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" 'true' kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" '<no value>'
set +o nounset ### kubectl drain command fails when both --selector and a node argument are given
set +o errexit # Pre-condition: node exists and contains label test=label
kubectl label node "127.0.0.1" "test=label"
kube::test::get_object_assert "nodes 127.0.0.1" '{{.metadata.labels.test}}' 'label'
response=$(! kubectl drain "127.0.0.1" --selector test=label 2>&1)
kube::test::if_has_string "${response}" 'cannot specify both a node name'
### kubectl cordon command fails when no arguments are passed
# Pre-condition: node exists
response=$(! kubectl cordon 2>&1)
kube::test::if_has_string "${response}" 'error\: USAGE\: cordon NODE'
### kubectl cordon selects all nodes with an empty --selector=
# Pre-condition: node "127.0.0.1" is uncordoned
kubectl uncordon "127.0.0.1"
response=$(kubectl cordon --selector=)
kube::test::if_has_string "${response}" 'node "127.0.0.1" cordoned'
# Post-condition: node "127.0.0.1" is cordoned
kube::test::get_object_assert "nodes 127.0.0.1" "{{.spec.unschedulable}}" 'true'
set +o nounset
set +o errexit
} }
run_plugins_tests() { run_plugins_tests() {
@ -4835,12 +4857,12 @@ runTests() {
record_command run_certificates_tests record_command run_certificates_tests
fi fi
###################### ######################
# Cluster Management # # Cluster Management #
###################### ######################
if kube::test::if_supports_resource "${nodes}" ; then if kube::test::if_supports_resource "${nodes}" ; then
record_command run_cluster_management_tests record_command run_cluster_management_tests
fi fi
########### ###########
# Plugins # # Plugins #