-
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
- Loading branch information
Showing
2 changed files
with
65 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,63 @@ | ||
test_operations_get_all() { | ||
assert_get_all_operations() { | ||
( | ||
set -e | ||
echo "==> get all-projects operations normally" | ||
local 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 -F 'status_code' | wc -l) | ||
test ${result} -eq 1 || false | ||
) | ||
} | ||
|
||
ensure_import_testimage | ||
|
||
# create container | ||
local 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() { | ||
# query param for project name | ||
local project=$1 | ||
( | ||
set -e | ||
echo "==> get ${project} operations normally" | ||
local result=$(lxc query "/1.0/operations?project=${project}" | jq '.success[0]' | wc -l) | ||
test ${result} -eq 1 || echo 1 | ||
|
||
echo "==> get ${project} operations recursively" | ||
result=$(lxc query "/1.0/operations?recursion=1&project=${project}" | jq '.success[0]' | grep -F 'status_code' | wc -l) | ||
test ${result} -eq 1 || echo 2 | ||
) | ||
} | ||
|
||
ensure_import_testimage | ||
|
||
local project="default" | ||
|
||
# create container | ||
local 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} | ||
} |