Skip to content

Commit

Permalink
Consolidate static cluster fixtures into one
Browse files Browse the repository at this point in the history
  • Loading branch information
dongreenberg committed Jun 17, 2024
1 parent d30c87d commit 37e1b3d
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 73 deletions.
9 changes: 1 addition & 8 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ class TestCluster(tests.test_resources.test_resource.TestResource):
"cluster": [
"ondemand_aws_cluster",
"static_cpu_cluster",
"password_cluster",
]
}
MAXIMAL = {
Expand All @@ -53,7 +52,6 @@ class TestCluster(tests.test_resources.test_resource.TestResource):
"docker_cluster_pwd_ssh_no_auth",
"ondemand_aws_cluster",
"static_cpu_cluster",
"password_cluster",
"multinode_cpu_cluster"
]
}
Expand Down Expand Up @@ -260,10 +258,7 @@ def event_loop():
unnamed_resource, # noqa: F401
)

from tests.fixtures.static_cluster_fixtures import (
password_cluster, # noqa: F401
static_cpu_cluster, # noqa: F401
)
from tests.fixtures.static_cluster_fixtures import static_cpu_cluster # noqa: F401

from tests.test_resources.test_clusters.test_sagemaker_cluster.conftest import (
other_sm_cluster, # noqa: F401
Expand Down Expand Up @@ -390,7 +385,6 @@ def event_loop():
"ondemand_gcp_cluster",
"ondemand_k8s_cluster",
"ondemand_aws_https_cluster_with_auth",
"password_cluster",
"static_cpu_cluster",
]
}
Expand All @@ -403,7 +397,6 @@ def event_loop():
"ondemand_gcp_cluster",
"ondemand_k8s_cluster",
"ondemand_aws_https_cluster_with_auth",
"password_cluster",
"multinode_cpu_cluster",
"static_cpu_cluster",
"multinode_gpu_cluster", # for testing cluster status on multinode gpu.
Expand Down
65 changes: 9 additions & 56 deletions tests/fixtures/static_cluster_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,60 +8,7 @@

@pytest.fixture(scope="session")
def static_cpu_cluster():
# TODO: Spin up a new basic m5.xlarge EC2 instance
# import boto3

# ec2 = boto3.resource("ec2")
# instances = ec2.create_instances(
# ImageId="ami-0a313d6098716f372",
# InstanceType="m5.xlarge",
# MinCount=1,
# MaxCount=1,
# KeyName="sky-key",
# TagSpecifications=[
# {
# "ResourceType": "instance",
# "Tags": [
# {"Key": "Name", "Value": "rh-cpu"},
# ],
# },
# ],
# )
# instance = instances[0]
# instance.wait_until_running()
# instance.load()

# ip = instance.public_ip_address

c = (
rh.ondemand_cluster(
instance_type="m5.xlarge",
provider="aws",
region="us-east-1",
# image_id="ami-0a313d6098716f372", # Upgraded to python 3.11.4 which is not compatible with ray 2.4.0
name="test-byo-cluster",
)
.up_if_not()
.save()
)

args = dict(
name="different-cluster",
host=c.address,
ssh_creds={"ssh_user": "ubuntu", "ssh_private_key": "~/.ssh/sky-key"},
)
c = rh.cluster(**args).save()
c.restart_server(resync_rh=True) # needed to override the cluster's config file
init_args[id(c)] = args

test_env().to(c)

return c


@pytest.fixture(scope="session")
def password_cluster():
sky_cluster = rh.cluster("temp-rh-password", instance_type="CPU:4").save()
sky_cluster = rh.cluster("aws-cpu-password", instance_type="CPU:4").save()
if not sky_cluster.is_up():
sky_cluster.up()

Expand All @@ -83,8 +30,14 @@ def password_cluster():
sky_cluster.run(["rm -rf runhouse/"])

# instantiate byo cluster with password
ssh_creds = {"ssh_user": "ubuntu", "password": "cluster-pass"}
args = dict(name="rh-password", host=[sky_cluster.address], ssh_creds=ssh_creds)
ssh_creds = {
"ssh_user": "ubuntu",
"ssh_private_key": "~/.ssh/sky-key",
"password": "cluster-pass",
}
args = dict(
name="static-cpu-password", host=[sky_cluster.address], ssh_creds=ssh_creds
)
c = rh.cluster(**args).save()
c.restart_server(resync_rh=True)
init_args[id(c)] = args
Expand Down
2 changes: 0 additions & 2 deletions tests/test_obj_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"ondemand_gcp_cluster",
"ondemand_k8s_cluster",
"ondemand_aws_https_cluster_with_auth",
"password_cluster",
"static_cpu_cluster",
]
}
Expand All @@ -42,7 +41,6 @@
"ondemand_gcp_cluster",
"ondemand_k8s_cluster",
"ondemand_aws_https_cluster_with_auth",
"password_cluster",
"multinode_cpu_cluster",
"static_cpu_cluster",
]
Expand Down
2 changes: 0 additions & 2 deletions tests/test_resources/test_clusters/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ class TestCluster(tests.test_resources.test_resource.TestResource):
RELEASE = {
"cluster": [
"static_cpu_cluster",
"password_cluster",
]
}
MAXIMAL = {
Expand All @@ -117,7 +116,6 @@ class TestCluster(tests.test_resources.test_resource.TestResource):
"docker_cluster_pk_ssh_den_auth",
"docker_cluster_pwd_ssh_no_auth",
"static_cpu_cluster",
"password_cluster",
"multinode_cpu_cluster",
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ class TestOnDemandCluster(tests.test_resources.test_clusters.test_cluster.TestCl
"k80_gpu_cluster",
"a10g_gpu_cluster",
"static_cpu_cluster",
"password_cluster",
"multinode_cpu_cluster",
"multinode_gpu_cluster",
]
Expand Down
3 changes: 1 addition & 2 deletions tests/test_resources/test_envs/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class TestEnv(tests.test_resources.test_resource.TestResource):
],
"cluster": [
"ondemand_aws_cluster",
"password_cluster",
"static_cpu_cluster",
],
}
MAXIMAL = {
Expand All @@ -88,7 +88,6 @@ class TestEnv(tests.test_resources.test_resource.TestResource):
"ondemand_k8s_cluster",
"ondemand_aws_https_cluster_with_auth",
"static_cpu_cluster",
"password_cluster",
"multinode_cpu_cluster",
"docker_cluster_pk_ssh_no_auth",
"docker_cluster_pwd_ssh_no_auth",
Expand Down
3 changes: 1 addition & 2 deletions tests/test_resources/test_secrets/test_secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class TestSecret(tests.test_resources.test_resource.TestResource):
"secret": ["test_secret"] + provider_secrets,
"cluster": [
"ondemand_aws_cluster",
"password_cluster",
"static_cpu_cluster",
],
}
MAXIMAL = {
Expand All @@ -95,7 +95,6 @@ class TestSecret(tests.test_resources.test_resource.TestResource):
"ondemand_k8s_cluster",
"ondemand_aws_https_cluster_with_auth",
"static_cpu_cluster",
"password_cluster",
"multinode_cpu_cluster",
"docker_cluster_pk_ssh_no_auth",
"docker_cluster_pwd_ssh_no_auth",
Expand Down

0 comments on commit 37e1b3d

Please sign in to comment.