X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/98d6c8c5743e0fd6be85af3b9f30286a358bd1d4..f5fed1ca0cd3a881a78ad6c607e17b5e1732815a:/sdk/python/tests/test_arv_put.py diff --git a/sdk/python/tests/test_arv_put.py b/sdk/python/tests/test_arv_put.py index e11c30959a..93cfdc2a36 100644 --- a/sdk/python/tests/test_arv_put.py +++ b/sdk/python/tests/test_arv_put.py @@ -18,11 +18,12 @@ import os import pwd import random import re +import select import shutil +import signal import subprocess import sys import tempfile -import threading import time import unittest import uuid @@ -729,6 +730,11 @@ class ArvadosPutTest(run_test_server.TestCaseWithServers, self.call_main_with_args, ['--project-uuid', self.Z_UUID, '--stream']) + def test_error_when_multiple_storage_classes_specified(self): + self.assertRaises(SystemExit, + self.call_main_with_args, + ['--storage-classes', 'hot,cold']) + def test_error_when_excluding_absolute_path(self): tmpdir = self.make_tmpdir() self.assertRaises(SystemExit, @@ -857,6 +863,30 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers, self.assertIn('4a9c8b735dce4b5fa3acf221a0b13628+11', pipe.stdout.read().decode()) + def test_sigint_logs_request_id(self): + # Start arv-put, give it a chance to start up, send SIGINT, + # and check that its output includes the X-Request-Id. + input_stream = subprocess.Popen( + ['sleep', '10'], + stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + pipe = subprocess.Popen( + [sys.executable, arv_put.__file__, '--stream'], + stdin=input_stream.stdout, stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, env=self.ENVIRON) + # Wait for arv-put child process to print something (i.e., a + # log message) so we know its signal handler is installed. + select.select([pipe.stdout], [], [], 10) + pipe.send_signal(signal.SIGINT) + deadline = time.time() + 5 + while (pipe.poll() is None) and (time.time() < deadline): + time.sleep(.1) + returncode = pipe.poll() + input_stream.terminate() + if returncode is None: + pipe.terminate() + self.fail("arv-put did not exit within 5 seconds") + self.assertRegex(pipe.stdout.read().decode(), r'\(X-Request-Id: req-[a-z0-9]{20}\)') + def test_ArvPutSignedManifest(self): # ArvPutSignedManifest runs "arv-put foo" and then attempts to get # the newly created manifest from the API server, testing to confirm @@ -1036,6 +1066,18 @@ class ArvPutIntegrationTest(run_test_server.TestCaseWithServers, '--project-uuid', self.PROJECT_UUID]) self.assertEqual(link_name, collection['name']) + def test_put_collection_with_storage_classes_specified(self): + collection = self.run_and_find_collection("", ['--storage-classes', 'hot']) + + self.assertEqual(len(collection['storage_classes_desired']), 1) + self.assertEqual(collection['storage_classes_desired'][0], 'hot') + + def test_put_collection_without_storage_classes_specified(self): + collection = self.run_and_find_collection("") + + self.assertEqual(len(collection['storage_classes_desired']), 1) + self.assertEqual(collection['storage_classes_desired'][0], 'default') + def test_exclude_filename_pattern(self): tmpdir = self.make_tmpdir() tmpsubdir = os.path.join(tmpdir, 'subdir')