use of com.baidu.hugegraph.computer.driver.DefaultJobState in project hugegraph-computer by hugegraph.
the class MiniKubeTest method testJobInternalSucceed.
@Test
public void testJobInternalSucceed() {
Whitebox.setInternalState(this.driver, "enableInternalAlgorithm", true);
Whitebox.setInternalState(this.driver, "internalAlgorithms", Lists.newArrayList("algorithm123"));
Map<String, String> params = new HashMap<>();
params.put(KubeSpecOptions.WORKER_INSTANCES.name(), "1");
params.put(ComputerOptions.TRANSPORT_SERVER_PORT.name(), "0");
params.put(ComputerOptions.RPC_SERVER_PORT.name(), "0");
String jobId = this.driver.submitJob("algorithm123", params);
JobObserver jobObserver = Mockito.mock(JobObserver.class);
CompletableFuture<Void> future = this.driver.waitJobAsync(jobId, params, jobObserver);
DefaultJobState jobState = new DefaultJobState();
jobState.jobStatus(JobStatus.INITIALIZING);
Mockito.verify(jobObserver, Mockito.timeout(15000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState));
DefaultJobState jobState2 = new DefaultJobState();
jobState2.jobStatus(JobStatus.SUCCEEDED);
Mockito.verify(jobObserver, Mockito.timeout(15000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState2));
future.cancel(true);
}
use of com.baidu.hugegraph.computer.driver.DefaultJobState in project hugegraph-computer by hugegraph.
the class MiniKubeTest method testPullImageError.
@Test
public void testPullImageError() {
Map<String, String> params = new HashMap<>();
this.updateOptions(KubeDriverOptions.IMAGE_REPOSITORY_URL.name(), "xxx");
String jobId = this.driver.submitJob(ALGORITHM_NAME, params);
JobObserver jobObserver = Mockito.mock(JobObserver.class);
CompletableFuture<Void> future = this.driver.waitJobAsync(jobId, params, jobObserver);
DefaultJobState jobState = new DefaultJobState();
jobState.jobStatus(JobStatus.FAILED);
Mockito.verify(jobObserver, Mockito.timeout(30000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState));
String diagnostics = this.driver.diagnostics(jobId, params);
Assert.assertContains("ImagePullBackOff", diagnostics);
future.cancel(true);
}
use of com.baidu.hugegraph.computer.driver.DefaultJobState in project hugegraph-computer by hugegraph.
the class MiniKubeTest method testUnSchedulable.
@Test
public void testUnSchedulable() {
Map<String, String> params = new HashMap<>();
params.put(KubeSpecOptions.WORKER_INSTANCES.name(), "1");
params.put(KubeSpecOptions.MASTER_CPU.name(), "10");
params.put(KubeSpecOptions.MASTER_MEMORY.name(), "10Gi");
String jobId = this.driver.submitJob(ALGORITHM_NAME, params);
JobObserver jobObserver = Mockito.mock(JobObserver.class);
CompletableFuture<Void> future = this.driver.waitJobAsync(jobId, params, jobObserver);
DefaultJobState jobState = new DefaultJobState();
jobState.jobStatus(JobStatus.FAILED);
Mockito.verify(jobObserver, Mockito.timeout(30000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState));
String diagnostics = this.driver.diagnostics(jobId, params);
Assert.assertContains("Unschedulable", diagnostics);
future.cancel(true);
}
use of com.baidu.hugegraph.computer.driver.DefaultJobState in project hugegraph-computer by hugegraph.
the class MiniKubeTest method testMountConfigMapWithFailed.
@Test
public void testMountConfigMapWithFailed() {
Map<String, String> params = new HashMap<>();
params.put(KubeSpecOptions.CONFIG_MAP_PATHS.name(), "[test-config:/opt/configmap123]");
String jobId = this.driver.submitJob(ALGORITHM_NAME, params);
JobObserver jobObserver = Mockito.mock(JobObserver.class);
CompletableFuture<Void> future = this.driver.waitJobAsync(jobId, params, jobObserver);
DefaultJobState jobState = new DefaultJobState();
jobState.jobStatus(JobStatus.INITIALIZING);
Mockito.verify(jobObserver, Mockito.timeout(150000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState));
DefaultJobState jobState2 = new DefaultJobState();
jobState2.jobStatus(JobStatus.FAILED);
Mockito.verify(jobObserver, Mockito.timeout(250000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState2));
future.cancel(true);
}
use of com.baidu.hugegraph.computer.driver.DefaultJobState in project hugegraph-computer by hugegraph.
the class MiniKubeTest method testMountConfigMapAndSecret.
@Test
public void testMountConfigMapAndSecret() {
String dataBase64 = Base64.getEncoder().encodeToString("test123\ntest".getBytes());
String configMapName = "config-map-test";
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata().withNamespace(this.namespace).withName(configMapName).endMetadata().addToData("1.txt", "test123\ntest").build();
this.kubeClient.configMaps().createOrReplace(configMap);
String secretName = "secret-test";
Secret secret = new SecretBuilder().withNewMetadata().withNamespace(this.namespace).withName(secretName).endMetadata().withType("Opaque").addToData("2.txt", dataBase64).addToData("3.txt", dataBase64).build();
this.kubeClient.secrets().createOrReplace(secret);
ArrayList<String> args = Lists.newArrayList("cat /opt/configmap123/1.txt && " + "cat /opt/secret123/2.txt &&" + "cat /opt/secret123/3.txt");
super.updateOptions(KubeSpecOptions.MASTER_ARGS.name(), args);
super.updateOptions(KubeSpecOptions.WORKER_ARGS.name(), args);
Object defaultSpec = Whitebox.invoke(KubernetesDriver.class, "defaultSpec", this.driver);
Whitebox.setInternalState(this.driver, "defaultSpec", defaultSpec);
Map<String, String> params = new HashMap<>();
params.put(KubeSpecOptions.CONFIG_MAP_PATHS.name(), String.format("[%s:/opt/configmap123]", configMapName));
params.put(KubeSpecOptions.SECRET_PATHS.name(), String.format("[%s:/opt/secret123]", secretName));
String jobId = this.driver.submitJob(ALGORITHM_NAME, params);
JobObserver jobObserver = Mockito.mock(JobObserver.class);
CompletableFuture<Void> future = this.driver.waitJobAsync(jobId, params, jobObserver);
DefaultJobState jobState = new DefaultJobState();
jobState.jobStatus(JobStatus.INITIALIZING);
Mockito.verify(jobObserver, Mockito.timeout(150000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState));
DefaultJobState jobState2 = new DefaultJobState();
jobState2.jobStatus(JobStatus.SUCCEEDED);
Mockito.verify(jobObserver, Mockito.timeout(150000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState2));
future.cancel(true);
}
Aggregations