def test_automatic_restart_is_always_false(self): manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, TEST_JOB_CONFIG) machine_config = manifest.to_dict() assert not machine_config["scheduling"]["automaticRestart"]
def test_config_contains_machine_type(self): manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, TEST_JOB_CONFIG) machine_config = manifest.to_dict() assert machine_config["machineType"] == "n1-standard-1"
def test_config_service_account_default(self): manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, TEST_JOB_CONFIG) machine_config = manifest.to_dict() assert machine_config["serviceAccounts"][0]["email"] == "default"
def test_config_empty_labels(self): job_config = copy.deepcopy(TEST_JOB_CONFIG) manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, job_config) machine_config = manifest.to_dict() assert machine_config["labels"] == {}
def test_config_contains_default_service_account_by_default(self): job_config = copy.deepcopy(TEST_JOB_CONFIG) manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, job_config) machine_config = manifest.to_dict() assert machine_config["serviceAccounts"][0]["email"] == "default"
def test_config_contains_vmname(self): manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "myvm", self.cloud_init, TEST_JOB_CONFIG) machine_config = manifest.to_dict() assert machine_config["name"] == "myvm"
def test_config_contains_labels(self): job_config = copy.deepcopy(TEST_JOB_CONFIG) job_config["labels"] = {"customer": "dummy"} manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, job_config) machine_config = manifest.to_dict() assert machine_config["labels"] == {"customer": "dummy"}
def test_config_contains_preemptible_flag_if_set_false(self): job_config = copy.deepcopy(TEST_JOB_CONFIG) job_config["preemptible"] = False manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, job_config) machine_config = manifest.to_dict() assert not machine_config["scheduling"]["preemptible"]
def test_config_service_account_can_be_overridden(self): job_config = copy.deepcopy(TEST_JOB_CONFIG) job_config["service_account"] = "*****@*****.**" manifest = clash.MachineConfig(self.gcloud.get_compute_client(), "_", self.cloud_init, job_config) machine_config = manifest.to_dict() assert machine_config["serviceAccounts"][0][ "email"] == "*****@*****.**"
def test_config_contains_cloud_init_config(self): config = clash.MachineConfig( self.gcloud.get_compute_client(), "_", clash.CloudInitConfig("myname", "_", TEST_JOB_CONFIG), TEST_JOB_CONFIG, ) machine_config = config.to_dict() assert machine_config["metadata"]["items"][0]["key"] == "user-data" cloud_init = yaml.load(machine_config["metadata"]["items"][0]["value"]) assert cloud_init["users"][0]["name"] == "clash"