Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SkyServe][Test] Fix test_smoke.py::test_skyserve_new_autoscaler_update #3824

Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ service:
base_ondemand_fallback_replicas: 1

resources:
cloud: gcp
cloud: {{generic_cloud}}
ports: 8081
use_spot: true
cpus: 2+
Expand All @@ -22,4 +22,4 @@ run: |
# blue-green update.
sleep 120
fi
python3 server.py
python3 server.py --port 8081
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ service:
replicas: 2

resources:
cloud: gcp
cloud: {{generic_cloud}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this templating stuff considering we have the --cloud in our test already?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though the test yaml with cloud: gcp worked as we expected due to --cloud option, it was confusing and I was not able to come up with a good reason to keep it as cloud: gcp while it is being tested for other clouds as well. Should we keep it as it was without templating?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep the original way or just remove the cloud: in the YAML, as it seems unnecessary to do a template when our CLIs are built for being able to override the fields.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed the cloud: from YAML, and reverted the template :)

ports: 8081
cpus: 2+

workdir: examples/serve/http_server

run: python3 server.py
run: python3 server.py --port 8081
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Is the other changes in this PR needed except for this one?

Copy link
Collaborator Author

@landscapepainter landscapepainter Aug 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test will work by only keeping this change.

76 changes: 48 additions & 28 deletions tests/test_smoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -3952,7 +3952,7 @@ def test_skyserve_update_autoscale(generic_cloud: str):
@pytest.mark.parametrize('mode', ['rolling', 'blue_green'])
def test_skyserve_new_autoscaler_update(mode: str, generic_cloud: str):
"""Test skyserve with update that changes autoscaler"""
name = _get_service_name() + mode
name = f'{_get_service_name()}-{mode}'

wait_until_no_pending = (
f's=$(sky serve status {name}); echo "$s"; '
Expand Down Expand Up @@ -3981,33 +3981,53 @@ def test_skyserve_new_autoscaler_update(mode: str, generic_cloud: str):
(2, False, 'READY')]) +
_check_service_version(name, "1"),
]
test = Test(
'test-skyserve-new-autoscaler-update',
[
f'sky serve up -n {name} --cloud {generic_cloud} -y tests/skyserve/update/new_autoscaler_before.yaml',
_SERVE_WAIT_UNTIL_READY.format(name=name, replica_num=2) +
_check_service_version(name, "1"),
f'{_SERVE_ENDPOINT_WAIT.format(name=name)}; '
's=$(curl http://$endpoint); echo "$s"; echo "$s" | grep "Hi, SkyPilot here"',
f'sky serve update {name} --cloud {generic_cloud} --mode {mode} -y tests/skyserve/update/new_autoscaler_after.yaml',
# Wait for update to be registered
f'sleep 90',
wait_until_no_pending,
_check_replica_in_status(
name, [(4, True, _SERVICE_LAUNCHING_STATUS_REGEX + '\|READY'),
(1, False, _SERVICE_LAUNCHING_STATUS_REGEX),
(2, False, 'READY')]),
*update_check,
_SERVE_WAIT_UNTIL_READY.format(name=name, replica_num=5),
f'{_SERVE_ENDPOINT_WAIT.format(name=name)}; '
'curl http://$endpoint | grep "Hi, SkyPilot here"',
_check_replica_in_status(name, [(4, True, 'READY'),
(1, False, 'READY')]),
],
_TEARDOWN_SERVICE.format(name=name),
timeout=20 * 60,
)
run_one_test(test)

before_template_str = pathlib.Path(
'tests/skyserve/update/new_autoscaler_before.yaml.j2').read_text()
after_template_str = pathlib.Path(
'tests/skyserve/update/new_autoscaler_after.yaml.j2').read_text()
before_template = jinja2.Template(before_template_str)
after_template = jinja2.Template(after_template_str)
before_content = before_template.render(generic_cloud=generic_cloud)
after_content = after_template.render(generic_cloud=generic_cloud)
with tempfile.NamedTemporaryFile(
suffix='.yaml',
mode='w') as before_file, tempfile.NamedTemporaryFile(
suffix='.yaml', mode='w') as after_file:
before_file.write(before_content)
before_file.flush()
before_file_path = before_file.name
after_file.write(after_content)
after_file.flush()
after_file_path = after_file.name
test = Test(
'test-skyserve-new-autoscaler-update',
[
f'sky serve up -n {name} --cloud {generic_cloud} -y {before_file_path}',
_SERVE_WAIT_UNTIL_READY.format(name=name, replica_num=2) +
_check_service_version(name, "1"),
f'{_SERVE_ENDPOINT_WAIT.format(name=name)}; '
's=$(curl http://$endpoint); echo "$s"; echo "$s" | grep "Hi, SkyPilot here"',
f'sky serve update {name} --cloud {generic_cloud} --mode {mode} -y {after_file_path}',
# Wait for update to be registered
f'sleep 90',
wait_until_no_pending,
_check_replica_in_status(name, [
(4, True, _SERVICE_LAUNCHING_STATUS_REGEX + '\|READY'),
(1, False, _SERVICE_LAUNCHING_STATUS_REGEX),
(2, False, 'READY')
]),
*update_check,
_SERVE_WAIT_UNTIL_READY.format(name=name, replica_num=5),
f'{_SERVE_ENDPOINT_WAIT.format(name=name)}; '
'curl http://$endpoint | grep "Hi, SkyPilot here"',
_check_replica_in_status(name, [(4, True, 'READY'),
(1, False, 'READY')]),
],
_TEARDOWN_SERVICE.format(name=name),
timeout=20 * 60,
)
run_one_test(test)


@pytest.mark.serve
Expand Down
Loading