Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Improve usage of lxd sql in tests #14674

Merged
merged 11 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test/suites/auth.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ test_authorization() {
# Test permission is removed automatically when instance is removed.
lxc auth group permission add test-group instance c1 can_exec project=default # Valid
lxc rm c1 --force
! lxd sql global "SELECT * FROM auth_groups_permissions WHERE entitlement = 'can_exec'" | grep c1 || false # Permission should be removed when instance is removed.
[ "$(lxd sql global --format csv "SELECT count(*) FROM auth_groups_permissions WHERE entitlement = 'can_exec'")" = 0 ] # Permission should be removed when instance is removed.

# Network permissions
! lxc auth group permission add test-group network n1 can_view project=default || false # Not found
Expand Down
4 changes: 2 additions & 2 deletions test/suites/backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ EOF
lxc exec c1 --project test -- hostname

# Test recover after pool DB config deletion too.
poolConfigBefore=$(lxd sql global "SELECT key,value FROM storage_pools_config JOIN storage_pools ON storage_pools.id = storage_pools_config.storage_pool_id WHERE storage_pools.name = '${poolName}' ORDER BY key")
poolConfigBefore=$(lxd sql global --format csv "SELECT key,value FROM storage_pools_config JOIN storage_pools ON storage_pools.id = storage_pools_config.storage_pool_id WHERE storage_pools.name = '${poolName}' ORDER BY key")
poolSource=$(lxc storage get "${poolName}" source)
poolExtraConfig=""

Expand Down Expand Up @@ -259,7 +259,7 @@ EOF

# Check recovered pool config (from instance backup file) matches what originally was there.
lxc storage show "${poolName}"
poolConfigAfter=$(lxd sql global "SELECT key,value FROM storage_pools_config JOIN storage_pools ON storage_pools.id = storage_pools_config.storage_pool_id WHERE storage_pools.name = '${poolName}' ORDER BY key")
poolConfigAfter=$(lxd sql global --format csv "SELECT key,value FROM storage_pools_config JOIN storage_pools ON storage_pools.id = storage_pools_config.storage_pool_id WHERE storage_pools.name = '${poolName}' ORDER BY key")
echo "Before:"
echo "${poolConfigBefore}"

Expand Down
Loading
Loading