From fd5180a1f3875a392c414c6bd97ba0c261e2552d Mon Sep 17 00:00:00 2001 From: networkException Date: Mon, 23 Dec 2024 00:46:32 +0100 Subject: [PATCH] nixos/tests/nextcloud: fix redis cache non empty tests This patch changes the implementation of the subtests to check for redis' cache being non empty to only run redis-cli and jq in a shell and assert the returned length in python. This fixes jq "len" simply not compiling and makes sure regressions get noticed. --- nixos/tests/nextcloud/with-declarative-redis-and-secrets.nix | 4 +++- nixos/tests/nextcloud/with-postgresql-and-redis.nix | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/nixos/tests/nextcloud/with-declarative-redis-and-secrets.nix b/nixos/tests/nextcloud/with-declarative-redis-and-secrets.nix index ec7fe854ced2e9..76ca7bb1c0126d 100644 --- a/nixos/tests/nextcloud/with-declarative-redis-and-secrets.nix +++ b/nixos/tests/nextcloud/with-declarative-redis-and-secrets.nix @@ -103,7 +103,9 @@ runTest ( test-helpers.extraTests = '' with subtest("non-empty redis cache"): # redis cache should not be empty - nextcloud.fail('test 0 -lt "$(redis-cli --pass secret --json KEYS "*" | jq "len")"') + assert nextcloud.succeed('redis-cli --pass secret --json KEYS "*" | jq length').strip() != "0", """ + redis-cli for keys * returned 0 entries + """ with subtest("notify-push"): client.execute("${lib.getExe pkgs.nextcloud-notify_push.passthru.test_client} http://nextcloud ${config.adminuser} ${config.adminpass} >&2 &") diff --git a/nixos/tests/nextcloud/with-postgresql-and-redis.nix b/nixos/tests/nextcloud/with-postgresql-and-redis.nix index 99708f9a8db40c..520aedf5688f78 100644 --- a/nixos/tests/nextcloud/with-postgresql-and-redis.nix +++ b/nixos/tests/nextcloud/with-postgresql-and-redis.nix @@ -29,6 +29,7 @@ runTest ( ... }: { + environment.systemPackages = [ pkgs.jq ]; services.nextcloud = { caching = { apcu = false; @@ -73,7 +74,9 @@ runTest ( with subtest("Redis is used for caching"): # redis cache should not be empty - nextcloud.fail('test "[]" = "$(redis-cli --json KEYS "*")"') + assert nextcloud.succeed('redis-cli --json KEYS "*" | jq length').strip() != "0", """ + redis-cli for keys * returned 0 entries + """ with subtest("No code is returned when requesting PHP files (regression test)"): nextcloud.fail("curl -f http://nextcloud/nix-apps/notes/lib/AppInfo/Application.php")