forked from ray-project/ray
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[autoscaler v2] add unit tests for NodeProviderConfig (ray-project#35590
) Why are these changes needed? add tests and fix bugs for NodeProviderConfig Signed-off-by: e428265 <[email protected]>
- Loading branch information
1 parent
2ea7580
commit e70a7a3
Showing
5 changed files
with
185 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# coding: utf-8 | ||
import os | ||
import sys | ||
|
||
import pytest # noqa | ||
|
||
from ray._private.test_utils import load_test_config | ||
from ray.autoscaler.v2.instance_manager.config import NodeProviderConfig | ||
|
||
|
||
def test_simple(): | ||
raw_config = load_test_config("test_multi_node.yaml") | ||
config = NodeProviderConfig(raw_config) | ||
assert config.get_node_config("head_node") == {"InstanceType": "m5.large"} | ||
assert config.get_docker_config("head_node") == { | ||
"image": "anyscale/ray-ml:latest", | ||
"container_name": "ray_container", | ||
"pull_before_run": True, | ||
} | ||
assert config.get_worker_start_ray_commands | ||
|
||
|
||
def test_complex(): | ||
raw_config = load_test_config("test_ray_complex.yaml") | ||
config = NodeProviderConfig(raw_config) | ||
assert config.get_head_setup_commands() == [ | ||
"echo a", | ||
"echo b", | ||
"echo ${echo hi}", | ||
"echo head", | ||
] | ||
assert config.get_head_start_ray_commands() == [ | ||
"ray stop", | ||
"ray start --head --autoscaling-config=~/ray_bootstrap_config.yaml", | ||
] | ||
assert config.get_worker_setup_commands("worker_nodes") == [ | ||
"echo a", | ||
"echo b", | ||
"echo ${echo hi}", | ||
"echo worker", | ||
] | ||
assert config.get_worker_start_ray_commands() == [ | ||
"ray stop", | ||
"ray start --address=$RAY_HEAD_IP", | ||
] | ||
assert config.get_worker_setup_commands("worker_nodes1") == [ | ||
"echo worker1", | ||
] | ||
|
||
assert config.get_docker_config("head_node") == { | ||
"image": "anyscale/ray-ml:latest", | ||
"container_name": "ray_container", | ||
"pull_before_run": True, | ||
} | ||
|
||
assert config.get_docker_config("worker_nodes") == { | ||
"image": "anyscale/ray-ml:latest", | ||
"container_name": "ray_container", | ||
"pull_before_run": True, | ||
} | ||
|
||
assert config.get_docker_config("worker_nodes1") == { | ||
"image": "anyscale/ray-ml:nightly", | ||
"container_name": "ray_container", | ||
"pull_before_run": True, | ||
} | ||
|
||
assert config.get_node_type_specific_config( | ||
"worker_nodes", "initialization_commands" | ||
) == ["echo what"] | ||
|
||
assert config.get_node_type_specific_config( | ||
"worker_nodes1", "initialization_commands" | ||
) == ["echo init"] | ||
|
||
|
||
if __name__ == "__main__": | ||
if os.environ.get("PARALLEL_CI"): | ||
sys.exit(pytest.main(["-n", "auto", "--boxed", "-vs", __file__])) | ||
else: | ||
sys.exit(pytest.main(["-sv", __file__])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
auth: | ||
ssh_user: ubuntu | ||
cluster_name: test-cli | ||
docker: | ||
image: anyscale/ray-ml:latest | ||
container_name: ray_container | ||
pull_before_run: true | ||
file_mounts: | ||
~/tests: . | ||
available_node_types: | ||
head_node: | ||
resources: {} | ||
max_workers: 0 | ||
node_config: | ||
ImageId: latest_dlami | ||
InstanceType: t1.micro | ||
worker_nodes: | ||
resources: {} | ||
max_workers: 2 | ||
min_workers: 1 | ||
node_config: | ||
ImageId: latest_dlami | ||
InstanceType: t1.micro | ||
initialization_commands: | ||
- echo what | ||
worker_nodes1: | ||
resources: {} | ||
max_workers: 2 | ||
min_workers: 1 | ||
node_config: | ||
ImageId: latest_dlami | ||
InstanceType: t1.micro | ||
worker_setup_commands: | ||
- echo worker1 | ||
docker: | ||
image: anyscale/ray-ml:nightly | ||
container_name: ray_container | ||
pull_before_run: true | ||
head_node_type: head_node | ||
head_setup_commands: | ||
- echo head | ||
head_start_ray_commands: | ||
- ray stop | ||
- ray start --head --autoscaling-config=~/ray_bootstrap_config.yaml | ||
idle_timeout_minutes: 5 | ||
initialization_commands: | ||
- echo init | ||
provider: | ||
availability_zone: us-west-2a | ||
key_pair: | ||
key_name: __test-cli | ||
region: us-west-2 | ||
type: aws | ||
setup_commands: | ||
- echo a | ||
- echo b | ||
- echo ${echo hi} | ||
worker_setup_commands: | ||
- echo worker | ||
worker_start_ray_commands: | ||
- ray stop | ||
- ray start --address=$RAY_HEAD_IP |