示例#1
0
 def test_query_invalid_uuid(self):
     cp = cli.show([uuid.uuid4()], self.cook_url)
     self.assertEqual(1, cp.returncode, cp.stderr)
     self.assertIn('No matching data found', cli.stdout(cp))
     cp = cli.wait([uuid.uuid4()], self.cook_url)
     self.assertEqual(1, cp.returncode, cp.stderr)
     self.assertIn('No matching data found', cli.stdout(cp))
示例#2
0
 def test_submit_output_should_explain_what_happened(self):
     cp, _ = cli.submit('ls', self.cook_url)
     self.assertEqual(0, cp.returncode, cp.stderr)
     self.assertIn("succeeded", cli.stdout(cp))
     self.assertIn("Your job UUID is", cli.stdout(cp))
     cp, _ = cli.submit_stdin(['ls', 'ls', 'ls'], self.cook_url)
     self.assertEqual(0, cp.returncode, cp.stderr)
     self.assertIn("succeeded", cli.stdout(cp))
     self.assertIn("Your job UUIDs are", cli.stdout(cp))
示例#3
0
 def test_usage(self):
     cp = cli.cli('')
     self.assertEqual(0, cp.returncode, cp.stderr)
     stdout = cli.stdout(cp)
     cp = cli.cli('', flags='--help')
     self.assertEqual(0, cp.returncode, cp.stderr)
     self.assertEqual(stdout, cli.stdout(cp))
     self.assertIn('usage:', stdout)
     self.assertIn('positional arguments:', stdout)
     self.assertIn('optional arguments:', stdout)
示例#4
0
 def test_no_matching_data_error_shows_only_cluster_of_interest(self):
     name = uuid.uuid4()
     config = {
         'clusters': [{
             'name': 'FOO',
             'url': f'{self.cook_url_1}'
         }, {
             'name': 'BAR',
             'url': f'{self.cook_url_2}'
         }]
     }
     with cli.temp_config_file(config) as path:
         flags = f'--config {path}'
         cp, uuids = cli.submit('ls',
                                flags=flags,
                                submit_flags=f'--name {name}')
         self.assertEqual(0, cp.returncode, cp.stderr)
         user = util.get_user(self.cook_url_1, uuids[0])
         jobs_flags = f'--user {user} --name {name} --all'
         cp, jobs = cli.jobs_json(self.cook_url_1, jobs_flags)
         self.assertEqual(0, cp.returncode, cp.stderr)
         self.assertEqual(1, len(jobs))
         cs = f'{cli.command()} {flags}'
         netloc_1 = urlparse(self.cook_url_1).netloc
         netloc_2 = urlparse(self.cook_url_2).netloc
         command = f'{cs} jobs {jobs_flags} -1 | sed "s/{netloc_1}/{netloc_2}/" | {cs} show'
         self.logger.info(command)
         cp = subprocess.run(command, shell=True, stdout=subprocess.PIPE)
         self.assertEqual(1, cp.returncode, cp.stderr)
         self.assertIn(
             'No matching data found in BAR.\nDo you need to add another cluster',
             cli.stdout(cp))
示例#5
0
    def test_ssh(self):
        # Submit to cluster #2
        cp, uuids = cli.submit('ls', self.cook_url_2)
        self.assertEqual(0, cp.returncode, cp.stderr)
        instance = util.wait_for_instance(self.cook_url_2, uuids[0])

        # Run ssh for the submitted job, with both clusters configured
        config = self.__two_cluster_config()
        with cli.temp_config_file(config) as path:
            hostname = instance['hostname']
            env = os.environ
            env['CS_SSH'] = 'echo'
            cp = cli.ssh(uuids[0], env=env, flags=f'--config {path}')
            stdout = cli.stdout(cp)
            self.assertEqual(0, cp.returncode, cli.output(cp))
            self.assertIn(f'Attempting ssh for job instance {instance["task_id"]}', stdout)
            self.assertIn('Executing ssh', stdout)
            self.assertIn(hostname, stdout)
            self.assertIn(f'-t {hostname} cd', stdout)
            self.assertIn('; bash', stdout)
示例#6
0
 def test_list_no_matching_jobs(self):
     cp = cli.list_jobs(self.cook_url, '--name %s' % uuid.uuid4())
     self.assertEqual(0, cp.returncode, cp.stderr)
     self.assertEqual('No jobs found in %s.' % self.cook_url,
                      cli.stdout(cp))