Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
b6e8e209
Unverified
Commit
b6e8e209
authored
Sep 13, 2017
by
juanvallejo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add tests
parent
e11a1114
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
35 deletions
+57
-35
test-cmd-util.sh
hack/make-rules/test-cmd-util.sh
+57
-35
No files found.
hack/make-rules/test-cmd-util.sh
View file @
b6e8e209
...
...
@@ -4214,35 +4214,57 @@ run_certificates_tests() {
}
run_cluster_management_tests
()
{
set
-o
nounset
set
-o
errexit
kube::log::status
"Testing cluster-management commands"
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
# 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
set
-o
nounset
set
-o
errexit
kube::log::status
"Testing cluster-management commands"
kube::test::get_object_assert nodes
"{{range.items}}{{
$id_field
}}:{{end}}"
'127.0.0.1:'
### kubectl cordon update with --dry-run does not mark node unschedulable
# Pre-condition: node is schedulable
kube::test::get_object_assert
"nodes 127.0.0.1"
"{{.spec.unschedulable}}"
'<no value>'
kubectl cordon
"127.0.0.1"
--dry-run
kube::test::get_object_assert
"nodes 127.0.0.1"
"{{.spec.unschedulable}}"
'<no value>'
### kubectl drain update with --dry-run does not mark node unschedulable
# Pre-condition: node is schedulable
kube::test::get_object_assert
"nodes 127.0.0.1"
"{{.spec.unschedulable}}"
'<no value>'
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 uncordon update with --dry-run is a no-op
# Pre-condition: node is already schedulable
kube::test::get_object_assert
"nodes 127.0.0.1"
"{{.spec.unschedulable}}"
'<no value>'
response
=
$(
kubectl uncordon
"127.0.0.1"
--dry-run
)
kube::test::if_has_string
"
${
response
}
"
'already uncordoned'
# Post-condition: node is still schedulable
kube::test::get_object_assert
"nodes 127.0.0.1"
"{{.spec.unschedulable}}"
'<no value>'
### kubectl drain command fails when both --selector and a node argument are given
# 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
()
{
...
...
@@ -4835,12 +4857,12 @@ runTests() {
record_command run_certificates_tests
fi
######################
# Cluster Management #
######################
if
kube::test::if_supports_resource
"
${
nodes
}
"
;
then
record_command run_cluster_management_tests
fi
######################
# Cluster Management #
######################
if
kube::test::if_supports_resource
"
${
nodes
}
"
;
then
record_command run_cluster_management_tests
fi
###########
# Plugins #
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment