Skip to content

Commit a0760df

Browse files
[Storage] Smoke tests for Storage mounting (skypilot-org#1445)
* Set rename_dir_lim for gcsfuse * Add support for list of sources for Storage * fix demo yaml * tests * lint * lint * test * add validation * address zhwu comments * add error on basename conflicts * use gsutil cp -n instead of gsutil rsync * lint * fix name * parallelize gsutil rsync * parallelize aws s3 rsync * lint * address comments * refactor * lint * address comments * Add storage mounting tests * lint * comments * comments * lint * add setup commands * remove teardown * lint
1 parent af1b7fd commit a0760df

File tree

3 files changed

+88
-10
lines changed

3 files changed

+88
-10
lines changed

tests/test_smoke.py

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import uuid
1111

1212
import colorama
13+
import jinja2
1314
import pytest
1415

1516
import sky
@@ -31,6 +32,12 @@
3132
# id.
3233
test_id = str(uuid.uuid4())[-2:]
3334

35+
storage_setup_commands = [
36+
'touch ~/tmpfile', 'mkdir -p ~/tmp-workdir',
37+
'touch ~/tmp-workdir/tmp\ file', 'touch ~/tmp-workdir/foo',
38+
'ln -f -s ~/tmp-workdir/ ~/tmp-workdir/circle-link'
39+
]
40+
3441

3542
class Test(NamedTuple):
3643
name: str
@@ -327,23 +334,51 @@ def test_env_check():
327334
# ---------- file_mounts ----------
328335
def test_file_mounts():
329336
name = _get_cluster_name()
337+
test_commands = [
338+
*storage_setup_commands,
339+
f'sky launch -y -c {name} examples/using_file_mounts.yaml',
340+
f'sky logs {name} 1 --status', # Ensure the job succeeded.
341+
]
330342
test = Test(
331343
'using_file_mounts',
332-
[
333-
'touch ~/tmpfile',
334-
'mkdir -p ~/tmp-workdir',
335-
'touch ~/tmp-workdir/tmp\ file',
336-
'touch ~/tmp-workdir/foo',
337-
'ln -f -s ~/tmp-workdir/ ~/tmp-workdir/circle-link',
338-
f'sky launch -y -c {name} examples/using_file_mounts.yaml',
339-
f'sky logs {name} 1 --status', # Ensure the job succeeded.
340-
],
344+
test_commands,
341345
f'sky down -y {name}',
342346
timeout=20 * 60, # 20 mins
343347
)
344348
run_one_test(test)
345349

346350

351+
# ---------- storage ----------
352+
def test_storage_mounts():
353+
name = _get_cluster_name()
354+
storage_name = f'sky-test-{int(time.time())}'
355+
template_str = pathlib.Path(
356+
'tests/test_yamls/test_storage_mounting.yaml').read_text()
357+
template = jinja2.Template(template_str)
358+
content = template.render(storage_name=storage_name)
359+
with tempfile.NamedTemporaryFile(suffix='.yaml', mode='w') as f:
360+
f.write(content)
361+
f.flush()
362+
file_path = f.name
363+
test_commands = [
364+
*storage_setup_commands,
365+
f'sky launch -y -c {name}-aws --cloud aws {file_path}',
366+
f'sky logs {name}-aws 1 --status', # Ensure job succeeded.
367+
f'aws s3 ls {storage_name}/hello.txt',
368+
f'sky storage delete {storage_name}', # Prepare for next cloud
369+
f'sky launch -y -c {name}-gcp --cloud gcp {file_path}',
370+
f'sky logs {name}-gcp 1 --status', # Ensure job succeeded.
371+
f'gsutil ls gs://{storage_name}/hello.txt',
372+
]
373+
test = Test(
374+
'storage_mounts',
375+
test_commands,
376+
f'sky down -y {name}-aws {name}-gcp; sky storage delete {storage_name}',
377+
timeout=20 * 60, # 20 mins
378+
)
379+
run_one_test(test)
380+
381+
347382
# ---------- CLI logs ----------
348383
def test_logs():
349384
name = _get_cluster_name()
@@ -921,7 +956,7 @@ def test_spot_cancellation():
921956
'--output text) && printf "$s" && echo; [[ -z "$s" ]] || [[ "$s" = "terminated" ]] || [[ "$s" = "shutting-down" ]]'
922957
),
923958
# Test cancelling the spot cluster during spot job being setup.
924-
f'sky spot launch --cloud aws --region {region} -n {name}-2 tests/test_yamls/long_setup.yaml -y -d',
959+
f'sky spot launch --cloud aws --region {region} -n {name}-2 tests/test_yamls/test_long_setup.yaml -y -d',
925960
'sleep 300',
926961
f'sky spot cancel -y -n {name}-2',
927962
'sleep 5',
@@ -974,6 +1009,7 @@ def test_spot_storage():
9741009
test = Test(
9751010
'managed-spot-storage',
9761011
[
1012+
*storage_setup_commands,
9771013
f'sky spot launch -n {name} {file_path} -y',
9781014
'sleep 60', # Wait the spot queue to be updated
9791015
f'sky spot queue | grep {name} | grep SUCCEEDED',
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
file_mounts:
2+
# Mounting public buckets
3+
/mount_public_s3:
4+
source: s3://digitalcorpora
5+
mode: MOUNT
6+
7+
# Mounting public buckets
8+
/mount_public_gcp:
9+
source: gs://gcp-public-data-sentinel-2
10+
mode: MOUNT
11+
12+
# Mounting private buckets in COPY mode
13+
/mount_private_copy:
14+
name: {{storage_name}}
15+
source: ~/tmp-workdir
16+
mode: COPY
17+
18+
# Mounting private buckets in MOUNT mode
19+
/mount_private_mount:
20+
name: {{storage_name}}
21+
source: ~/tmp-workdir
22+
mode: MOUNT
23+
24+
run: |
25+
set -ex
26+
27+
# Check public bucket contents
28+
ls -ltr /mount_public_s3/corpora
29+
ls -ltr /mount_public_gcp/tiles
30+
31+
# Check private bucket contents
32+
ls -ltr /mount_private_copy/foo
33+
ls -ltr /mount_private_copy/tmp\ file
34+
ls -ltr /mount_private_mount/foo
35+
ls -ltr /mount_private_mount/tmp\ file
36+
37+
# Symlinks are not copied to buckets
38+
! ls /mount_private_copy/circle-link
39+
! ls /mount_private_mount/circle-link
40+
41+
# Write to private bucket in MOUNT mode should pass
42+
echo "hello" > /mount_private_mount/hello.txt

0 commit comments

Comments
 (0)