Exemple #1
0
    def step3_job_monitoring(self):
        to_screen("""\
testing REST APIs related to querying a job, including
- rest_api_job_list
- rest_api_job_info
        """)
        client = ClusterList().load().get_client(
            get_defaults()["cluster-alias"])
        self.cmd_exec(['opai', 'job', 'list'])
        job_list = client.rest_api_job_list(
            client.user)  # ! only jobs from current user to reduce time
        job_list = [job['name'] for job in job_list]
        assert self.job_name in job_list, job_list
        to_screen(f"testing job monitoring with {self.job_name}")
        status = client.rest_api_job_info(self.job_name)
        to_screen(
            f"retrieving job status and get its state {JobStatusParser.state(status)}"
        )
        client.rest_api_job_info(self.job_name, 'config')
        to_screen("retrieving job config")
        logs = JobStatusParser.all_tasks_logs(status)
        assert logs, f"failed to read logs from status \n{status}"
        for k, v in logs.items():
            for t, content in v.items():
                to_screen(
                    f"reading logs {k} for {t} and get {len(content)} Bytes")
Exemple #2
0
    def step1_init_clusters(self):
        to_screen("""\
testing REST APIs related to retrieving cluster info, including
- rest_api_cluster_info
- rest_api_user
- rest_api_token
- rest_api_virtual_clusters
        """)
        with open(self.ut_init_shell) as fn:
            for line in fn:
                if line.startswith('#'):
                    continue
                self.cmd_exec(line)
        alias = get_defaults()["cluster-alias"]
        self.assertTrue(alias, "not specify a cluster")
        self.cmd_exec('opai cluster resources')
Exemple #3
0
 def test_update_defaults(self):
     # ! not test global defaults updating, test it in integration tests
     test_key, test_value = self.get_random_var_name(), randstr(10)
     # add a default key
     update_default(test_key, test_value, is_global=False, to_delete=False)
     self.assertEqual(
         get_defaults()[test_key],
         test_value,
         msg=f"failed to check {test_key} in {LayeredSettings.as_dict()}")
     # should appear in local
     self.assertEqual(
         from_file(self.local_default_file)[test_key], test_value)
     # delete
     update_default(test_key, test_value, is_global=False, to_delete=True)
     with self.assertRaises(KeyError):
         os.system(f"cat {self.local_default_file}")
         from_file(self.local_default_file, {})[test_key]
     # add not allowed
     test_key = randstr(10)
     update_default(test_key, test_value, is_global=False, to_delete=False)
     with self.assertRaises(KeyError):
         from_file(self.local_default_file, {})[test_key]