def test_pool_mba_mba_bw_enabled(self): data = { "rdt_iface": { "interface": "os" }, "mba_ctrl": { "enabled": True }, "pools": [{ "cbm": 0xf, "mba": 50, "cores": [1, 3], "id": 1, "name": "pool 1" }, { "cbm": 0xf, "mba": 70, "cores": [2], "id": 2, "name": "pool 2" }] } with pytest.raises( ValueError, match="MBA % is not enabled. Disable MBA BW and try again"): ConfigStore.validate(data)
def test_app_invalid_core(self): def check_core(core): return core != 3 data = { "auth": { "password": "******", "username": "******" }, "pools": [{ "apps": [1], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }], "apps": [{ "cores": [3], "id": 1, "name": "app 1", "pids": [1] }] } with mock.patch('common.PQOS_API.check_core', new=check_core): with pytest.raises(ValueError, match="Invalid core 3"): ConfigStore.validate(data)
def test_app_without_pool(self): data = { "pools": [{ "apps": [1], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }, { "cbm": 0xf0, "cores": [2], "id": 2, "name": "pool 2" }], "apps": [{ "cores": [1], "id": 1, "name": "app 1", "pids": [1] }, { "cores": [1], "id": 2, "name": "app 2", "pids": [2] }] } with pytest.raises(ValueError, match="not assigned to any pool"): ConfigStore.validate(data)
def test_app_invalid_pid(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [ { "apps": [1, 2], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }, ], "apps": [{ "cores": [1], "id": 1, "name": "app 1", "pids": [1] }, { "cores": [1], "id": 2, "name": "app 2", "pids": [99999] }] } with pytest.raises(ValueError, match="App 2, PID 99999 is not valid"): ConfigStore.validate(data)
def test_app_without_pool(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [{ "apps": [1], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }, { "apps": [1, 2], "cbm": 0xf0, "cores": [2], "id": 2, "name": "pool 2" }], "apps": [{ "cores": [1], "id": 1, "name": "app 1", "pids": [1] }, { "cores": [2], "id": 2, "name": "app 2", "pids": [2] }] } with pytest.raises(ValueError, match="App 1, Assigned to more than one pool"): ConfigStore.validate(data)
def test_rdt_iface_invalid(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [], "apps": [], "rdt_iface": "os" } with pytest.raises(jsonschema.exceptions.ValidationError, match="'os' is not of type 'object'"): ConfigStore.validate(data) data['rdt_iface'] = {} with pytest.raises(jsonschema.exceptions.ValidationError, match="'interface' is a required property"): ConfigStore.validate(data) data['rdt_iface']['interface'] = None with pytest.raises(jsonschema.exceptions.ValidationError, match="None is not of type 'string'"): ConfigStore.validate(data) data['rdt_iface']['interface'] = 2 with pytest.raises(jsonschema.exceptions.ValidationError, match="2 is not of type 'string'"): ConfigStore.validate(data) data['rdt_iface']['interface'] = "test_string" with pytest.raises( jsonschema.exceptions.ValidationError, match="'test_string' is not one of \\['msr', 'os'\\]"): ConfigStore.validate(data)
def test_app_same_ids(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [ { "apps": [1], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }, ], "apps": [{ "cores": [1], "id": 1, "name": "app 1", "pids": [1] }, { "cores": [1], "id": 1, "name": "app 2", "pids": [1] }] } with pytest.raises(ValueError, match="App 1, multiple apps with same id"): ConfigStore.validate(data)
def test_app_same_pid(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [ { "apps": [1, 2], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }, ], "apps": [{ "cores": [1], "id": 1, "name": "app 1", "pids": [1] }, { "cores": [1], "id": 2, "name": "app 2", "pids": [1] }] } with pytest.raises( ValueError, match=r"App 2, PIDs \{1} already assigned to another App."): ConfigStore.validate(data)
def test_app_core_does_not_match_pool(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [{ "apps": [1], "cbm": 0xf0, "cores": [1], "id": 1, "name": "pool 1" }], "apps": [{ "cores": [3, 4, 5], "id": 1, "name": "app 1", "pids": [1] }] } with pytest.raises( ValueError, match="App 1, cores {3, 4, 5} does not match Pool 1"): ConfigStore.validate(data)
def test_pool_mba_not_supported(self): data = { "pools": [{ "mba": 50, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(ValueError, match="MBA is not supported"): ConfigStore.validate(data)
def test_pool_cat_not_supported(self): data = { "pools": [{ "apps": [], "cbm": 0x4, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(ValueError, match="CAT is not supported"): ConfigStore.validate(data)
def test_pool_mba_bw_not_supported_cat(self): data = { "pools": [{ "cbm": 0xf, "mba_bw": 5000, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(ValueError, match="MBA BW is not enabled/supported"): ConfigStore.validate(data)
def test_pool_mba_not_supported_cat(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [{ "cbm": 0xf, "mba": 50, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(ValueError, match="MBA is not supported"): ConfigStore.validate(data)
def test_pool_mba_bw_not_supported(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [{ "mba_bw": 5000, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(ValueError, match="MBA BW is not enabled/supported"): ConfigStore.validate(data)
def test_pool_invalid_cbm(self): data = { "pools": [{ "apps": [], "cbm": 0x5, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(ValueError, match="not contiguous"): ConfigStore.validate(data) data['pools'][0]['cbm'] = 0 with pytest.raises(ValueError, match="not contiguous"): ConfigStore.validate(data)
def test_pool_same_ids(self): data = { "pools": [{ "cbm": 0xf0, "cores": [1, 3], "id": 1, "name": "pool 1" }, { "cbm": 0xf, "id": 1, "cores": [3], "name": "pool 2" }] } with pytest.raises(ValueError, match="Pool 1, multiple pools with same id"): ConfigStore.validate(data)
def test_pool_duplicate_core(self): data = { "pools": [{ "cbm": 0xf0, "cores": [1, 3], "id": 1, "name": "pool 1" }, { "cbm": 0xf, "id": 10, "cores": [3], "name": "pool 1" }] } with pytest.raises(ValueError, match="already assigned to another pool"): ConfigStore.validate(data)
def test_pool_invalid_mba(self): data = { "pools": [{ "mba": 101, "cores": [1, 3], "id": 1, "name": "pool 1" }] } with pytest.raises(jsonschema.exceptions.ValidationError, match="Failed validating 'maximum' in schema"): ConfigStore.validate(data) data['pools'][0]['mba'] = 0 with pytest.raises(jsonschema.exceptions.ValidationError, match="Failed validating 'minimum' in schema"): ConfigStore.validate(data)
def test_pool_invalid_app(self): data = { "pools": [{ "apps": [1, 3], "cbm": 0xf0, "cores": [1, 3], "id": 1, "name": "pool 1" }], "apps": [{ "cores": [3], "id": 1, "name": "app 1", "pids": [1] }] } with pytest.raises(KeyError, match="does not exist"): ConfigStore.validate(data)
def test_pool_invalid_core(self): def check_core(core): return core != 3 data = { "pools": [{ "cbm": 0xf0, "cores": [1], "id": 1, "name": "valid" }, { "cbm": 0xf, "cores": [3], "id": 8, "name": "invalid" }] } with mock.patch('common.PQOS_API.check_core', new=check_core): with pytest.raises(ValueError, match="Invalid core 3"): ConfigStore.validate(data)
def test_pool_mba_and_mba_bw_mix(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [{ "cbm": 0xf, "mba_bw": 5000, "cores": [1, 3], "id": 1, "name": "pool 1" }, { "cbm": 0xf, "mba": 50, "cores": [2], "id": 2, "name": "pool 2" }] } with pytest.raises(ValueError, match="It is not allowed to mix MBA"): ConfigStore.validate(data)
def test_power_profile_expert_mode_invalid(self): data = {"pools": [], "apps": [], "power_profiles_expert_mode": None} with pytest.raises(jsonschema.exceptions.ValidationError, match="None is not of type 'boolean'"): ConfigStore.validate(data) data['power_profiles_expert_mode'] = 1 with pytest.raises(jsonschema.exceptions.ValidationError, match="1 is not of type 'boolean'"): ConfigStore.validate(data) data['power_profiles_expert_mode'] = [] with pytest.raises(jsonschema.exceptions.ValidationError, match="\\[\\] is not of type 'boolean'"): ConfigStore.validate(data)
def test_power_profile_verify_invalid(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [], "apps": [], "power_profiles_verify": None } with pytest.raises(jsonschema.exceptions.ValidationError, match="None is not of type 'boolean'"): ConfigStore.validate(data) data['power_profiles_verify'] = 1 with pytest.raises(jsonschema.exceptions.ValidationError, match="1 is not of type 'boolean'"): ConfigStore.validate(data) data['power_profiles_verify'] = [] with pytest.raises(jsonschema.exceptions.ValidationError, match="\\[\\] is not of type 'boolean'"): ConfigStore.validate(data)
def test_mba_ctrl_invalid(self): data = { "auth": { "password": "******", "username": "******" }, "pools": [], "apps": [], "mba_ctrl": True } with pytest.raises(jsonschema.exceptions.ValidationError, match="True is not of type 'object'"): ConfigStore.validate(data) data['mba_ctrl'] = {} with pytest.raises(jsonschema.exceptions.ValidationError, match="'enabled' is a required property"): ConfigStore.validate(data) data['mba_ctrl']['enabled'] = None with pytest.raises(jsonschema.exceptions.ValidationError, match="None is not of type 'boolean'"): ConfigStore.validate(data) data['mba_ctrl']['enabled'] = 2 with pytest.raises(jsonschema.exceptions.ValidationError, match="2 is not of type 'boolean'"): ConfigStore.validate(data) data['mba_ctrl']['enabled'] = "test_string" with pytest.raises(jsonschema.exceptions.ValidationError, match="'test_string' is not of type 'boolean'"): ConfigStore.validate(data) data['mba_ctrl']['enabled'] = True with pytest.raises(ValueError, match="MBA CTRL requires RDT OS interface"): ConfigStore.validate(data) data['rdt_iface'] = {"interface": "msr"} with pytest.raises(ValueError, match="MBA CTRL requires RDT OS interface"): ConfigStore.validate(data)