Skip to content

Commit

Permalink
clean up resources used in tests from den (#776)
Browse files Browse the repository at this point in the history
  • Loading branch information
jlewitt1 committed May 5, 2024
1 parent bfe1b56 commit d478966
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
9 changes: 9 additions & 0 deletions runhouse/resources/hardware/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,15 @@ def save(self, name: str = None, overwrite: bool = True, folder: str = None):

return self

def delete_configs(self):
if self._creds:
logger.debug(
f"Attempting to delete creds associated with cluster {self.name}"
)
rns_client.delete_configs(self._creds)

super().delete_configs()

def _save_sub_resources(self, folder: str = None):
from runhouse.resources.envs import Env
from runhouse.resources.secrets import Secret
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/docker_cluster_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,8 @@ def docker_cluster_pk_tls_exposed(request, test_rns_folder):
# If we are running in detached mode, leave the container running, else clean it up
if not detached:
cleanup()
else:
local_cluster.delete_configs()


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -406,6 +408,8 @@ def docker_cluster_pk_ssh(request, test_org_rns_folder):
# If we are running in detached mode, leave the container running, else clean it up
if not detached:
cleanup()
else:
local_cluster.delete_configs()


# These two clusters cannot be used in the same test together, they are are technically
Expand Down Expand Up @@ -502,6 +506,8 @@ def docker_cluster_pk_http_exposed(request, test_rns_folder):
# If we are running in detached mode, leave the container running, else clean it up
if not detached:
cleanup()
else:
local_cluster.delete_configs()


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -550,6 +556,8 @@ def docker_cluster_pwd_ssh_no_auth(request, test_rns_folder):
# If we are running in detached mode, leave the container running, else clean it up
if not detached:
cleanup()
else:
local_cluster.delete_configs()


@pytest.fixture(scope="session")
Expand Down Expand Up @@ -598,6 +606,8 @@ def friend_account_logged_in_docker_cluster_pk_ssh(request, test_rns_folder):
# If we are running in detached mode, leave the container running, else clean it up
if not detached:
cleanup()
else:
local_cluster.delete_configs()


@pytest.fixture(scope="session")
Expand Down
8 changes: 6 additions & 2 deletions tests/fixtures/resource_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ def saved_resource_pool():

@pytest.fixture(scope="session")
def test_rns_folder():
return f"testing-{uuid.uuid4()}-{datetime.now().strftime('%Y%m%d-%H%M%S')}"
folder_path = f"testing-{uuid.uuid4()}-{datetime.now().strftime('%Y%m%d-%H%M%S')}"
yield folder_path
rns_client.delete_configs(folder_path)


@pytest.fixture(scope="session")
def test_org_rns_folder(test_rns_folder):
return f"/{TEST_ORG}/{test_rns_folder}"
folder_path = f"/{TEST_ORG}/{test_rns_folder}"
yield folder_path
rns_client.delete_configs(folder_path)


@pytest.fixture(scope="function")
Expand Down

0 comments on commit d478966

Please sign in to comment.