-
Notifications
You must be signed in to change notification settings - Fork 931
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add standalone test cases for operations_get
Signed-off-by: Aurutus <emslhy@hotmail.com>
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
test_operations_get_all() { | ||
assert_get_all_operations() { | ||
( | ||
set -e | ||
echo "==> get all-projects operations normally" | ||
result="$(lxc query "/1.0/operations?all-projects=true" | jq '.success[0]' | wc -l)" | ||
test "${result}" -eq 1 || false | ||
|
||
echo "==> get all-projects operations recursively" | ||
result="$(lxc query "/1.0/operations?recursion=1&all-projects=true" | jq '.success[0]' | grep -c 'status_code')" | ||
test "${result}" -eq 1 || false | ||
) | ||
} | ||
|
||
ensure_import_testimage | ||
|
||
# create container | ||
name=x1 | ||
lxc launch testimage ${name} | ||
lxc list ${name} | grep RUNNING | ||
|
||
# get_all_operations | ||
lxc query -X POST -d '{\"command\":[\"touch\",\"/root/foo1\"],\"record-output\":false}' /1.0/instances/${name}/exec | ||
sleep 1 | ||
assert_get_all_operations | ||
|
||
lxc stop "${name}" --force | ||
lxc delete "${name}" | ||
} | ||
|
||
test_operations_get_by_project() { | ||
assert_get_project_operations() { | ||
# $1: query param for project name | ||
( | ||
set -e | ||
echo "==> get $1 operations normally" | ||
result="$(lxc query "/1.0/operations?project=$1" | jq '.success[0]' | wc -l)" | ||
test "${result}" -eq 1 || false | ||
|
||
echo "==> get $1 operations recursively" | ||
result="$(lxc query "/1.0/operations?recursion=1&project=$1" | jq '.success[0]' | grep -c 'status_code')" | ||
test "${result}" -eq 1 || false | ||
) | ||
} | ||
|
||
ensure_import_testimage | ||
|
||
project="default" | ||
|
||
# create container | ||
name=x1 | ||
lxc launch testimage ${name} --project ${project} | ||
lxc list ${name} --project ${project} | grep RUNNING | ||
|
||
# get opetaions with project name | ||
lxc query -X POST -d '{\"command\":[\"touch\",\"/root/foo1\"],\"record-output\":false}' /1.0/instances/${name}/exec?project=${project} | ||
sleep 1 | ||
assert_get_project_operations ${project} | ||
|
||
lxc stop "${name}" --force --project ${project} | ||
lxc delete "${name}" --project ${project} | ||
} |