diff --git a/dask_cloudprovider/openstack/instances.py b/dask_cloudprovider/openstack/instances.py index 6605b6d6..22ec73b8 100644 --- a/dask_cloudprovider/openstack/instances.py +++ b/dask_cloudprovider/openstack/instances.py @@ -20,6 +20,7 @@ ) raise ImportError(msg) from e + class OpenStackInstance(VMInterface): def __init__( self, @@ -175,6 +176,7 @@ async def stop_vm(self): # Code to stop the instance pass # Placeholder to ensure correct indentation + class OpenStackScheduler(SchedulerMixin, OpenStackInstance): """Scheduler running on an OpenStack Instance.""" @@ -212,9 +214,11 @@ async def start_scheduler(self): self.cluster.scheduler_external_ip = self.external_ip self.cluster.scheduler_port = self.port + class OpenStackWorker(WorkerMixin, OpenStackInstance): """Worker running on a OpenStack Instance.""" + class OpenStackCluster(VMCluster): """Cluster running on Openstack VM Instances @@ -316,8 +320,8 @@ class OpenStackCluster(VMCluster): Security Group: all-open Creating scheduler instance dask-9b85a5f8-scheduler - Internal IP: 10.0.30.148 - External IP: None + Internal IP: 10.0.30.148 + External IP: None Waiting for scheduler to run at 10.0.30.148:8786 Scheduler is running Creating worker instance diff --git a/dask_cloudprovider/openstack/tests/test_instances.py b/dask_cloudprovider/openstack/tests/test_instances.py index 466b08fa..5485811d 100644 --- a/dask_cloudprovider/openstack/tests/test_instances.py +++ b/dask_cloudprovider/openstack/tests/test_instances.py @@ -5,6 +5,8 @@ from distributed.core import Status # Optional: Skips tests if OpenStack credentials are not set + + async def skip_without_credentials(config): if ( config.get("auth_url") is None @@ -25,22 +27,28 @@ async def skip_without_credentials(config): """ ) + @pytest.fixture async def config(): + return dask.config.get("cloudprovider.openstack", {}) + @pytest.fixture @pytest.mark.external async def cluster(config): await skip_without_credentials(config) + async with OpenStackCluster(asynchronous=True) as cluster: yield cluster + @pytest.mark.asyncio async def test_init(): cluster = OpenStackCluster(asynchronous=True) assert cluster.status == Status.created + @pytest.mark.asyncio @pytest.mark.timeout(600) async def test_create_cluster(cluster): @@ -52,10 +60,12 @@ async def test_create_cluster(cluster): async with Client(cluster, asynchronous=True) as client: def inc(x): + return x + 1 assert await client.submit(inc, 10).result() == 11 + @pytest.mark.asyncio async def test_get_cloud_init(): cloud_init = OpenStackCluster.get_cloud_init(