From 01b7e445f9e511bbbcabe94a2e9990c9c15d969f Mon Sep 17 00:00:00 2001 From: Piotr Sarna Date: Tue, 25 May 2021 11:55:57 +0200 Subject: [PATCH] cql-pytest: add basic tests for service level workload types The test cases check whether it's possible to declare workload type for a service level and if its input is validated. --- test/cql-pytest/test_service_levels.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/cql-pytest/test_service_levels.py b/test/cql-pytest/test_service_levels.py index 9b0685d1d2..038fd8ee9b 100644 --- a/test/cql-pytest/test_service_levels.py +++ b/test/cql-pytest/test_service_levels.py @@ -68,3 +68,21 @@ def test_attached_service_level(scylla_only, cql): assert res_one.role == cql.cluster.auth_provider.username and res_one.service_level == sl res_one = cql.execute(f"LIST ALL ATTACHED SERVICE LEVELS").one() assert res_one.role == cql.cluster.auth_provider.username and res_one.service_level == sl + +# Test that declaring service level workload types is possible +def test_set_workload_type(scylla_only, cql): + with new_service_level(cql) as sl: + res = cql.execute(f"LIST SERVICE LEVEL {sl}") + assert res.one().workload_type == 'unspecified' + for wt in ['interactive', 'batch', 'unspecified']: + cql.execute(f"ALTER SERVICE LEVEL {sl} WITH workload_type = '{wt}'") + res = cql.execute(f"LIST SERVICE LEVEL {sl}") + assert res.one().workload_type == wt + + # Test that workload type input is validated +def test_set_invalid_workload_types(scylla_only, cql): + with new_service_level(cql) as sl: + for incorrect in ['', 'null', 'i', 'b', 'dog', 'x'*256]: + print(f"Checking {incorrect}") + with pytest.raises(Exception): + cql.execute(f"ALTER SERVICE LEVEL {sl} WITH workload_type = '{incorrect}'") \ No newline at end of file