diff --git a/tests/test_cli.py b/tests/test_cli.py index ae305963..2c3a2e27 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -8,6 +8,7 @@ from control.proto import gateway_pb2 as pb2 from control.proto import gateway_pb2_grpc as pb2_grpc import os +import subprocess image = "mytestdevimage" image2 = "mytestdevimage2" @@ -37,6 +38,25 @@ listener_list_wrong_gw = [["-g", "WRONG", "-a", addr, "-s", "5015", "-f", "ipv4"]] config = "ceph-nvmeof.conf" +def create_nvme_gateway(name): + # Formulate the command + command = [ + "docker-compose", + "exec", + "-T", + "ceph", + "ceph", + "nvme-gw", + "create", + name, + "rbd", + "" + ] + + # Execute the command + subprocess.run(command, check=True) + print(f"NVMe gateway {name} created successfully.") + @pytest.fixture(scope="module") def gateway(config): """Sets up and tears down Gateway""" @@ -47,6 +67,7 @@ def gateway(config): with GatewayServer(config) as gateway: # Start gateway + create_nvme_gateway(gateway.name) gateway.serve() # Bind the client and Gateway diff --git a/tests/test_grpc.py b/tests/test_grpc.py index 428965d7..39ca7a6c 100644 --- a/tests/test_grpc.py +++ b/tests/test_grpc.py @@ -32,6 +32,7 @@ def check_resource_by_index(i, caplog): def test_create_get_subsys(caplog, config): with GatewayServer(config) as gateway: gateway.serve() + gateway.set_group_id(0) for i in range(created_resource_count): create_resource_by_index(i) @@ -67,6 +68,7 @@ def test_create_get_subsys(caplog, config): # restart the gateway here with GatewayServer(config) as gateway: gateway.serve() + gateway.set_group_id(0) for i in range(subsys_list_count): cli(["--format", "plain", "subsystem", "list"]) diff --git a/tests/test_log_files.py b/tests/test_log_files.py index b8420499..a6a5669c 100644 --- a/tests/test_log_files.py +++ b/tests/test_log_files.py @@ -48,6 +48,7 @@ def gateway(config, request): # Start gateway gateway.serve() + gateway.set_group_id(0) # Bind the client and Gateway channel = grpc.insecure_channel(f"{addr}:{port}") diff --git a/tests/test_old_omap.py b/tests/test_old_omap.py index 8d21bf3c..f6e1c748 100644 --- a/tests/test_old_omap.py +++ b/tests/test_old_omap.py @@ -6,10 +6,12 @@ def test_old_omap(caplog, config): with GatewayServer(config) as gateway: gateway.serve() + gateway.set_group_id(0) gateway.gateway_rpc.gateway_state.omap._add_key("bdev_dummy", "dummy") caplog.clear() with GatewayServer(config) as gateway: with pytest.raises(Exception) as ex: gateway.serve() + gateway.set_group_id(0) assert f"Old OMAP file format, still contains bdevs, please remove file and try again" in str(ex.value) diff --git a/tests/test_server.py b/tests/test_server.py index cd199749..91f1efd3 100644 --- a/tests/test_server.py +++ b/tests/test_server.py @@ -35,12 +35,14 @@ def test_spdk_exception(self): with self.assertRaises(SystemExit) as cm: with GatewayServer(config_spdk_exception) as gateway: gateway.serve() + gateway.set_group_id(0) self.validate_exception(cm.exception) def test_spdk_abort(self): """Tests spdk sub process dumps core on during normal shutdown.""" with GatewayServer(copy.deepcopy(self.config)) as gateway: gateway.serve() + gateway.set_group_id(0) time.sleep(10) # exited context, spdk process should be aborted here by __exit__() time.sleep(10) # let it dump @@ -65,7 +67,9 @@ def test_spdk_multi_gateway_exception(self): GatewayServer(configB) as gatewayB, ): gatewayA.serve() + gatewayA.set_group_id(0) gatewayB.serve() + gatewayB.set_group_id(1) self.validate_exception(cm.exception) if __name__ == '__main__':