Search in sources :

Example 1 with AbstractController

use of com.baidu.hugegraph.computer.k8s.operator.common.AbstractController in project hugegraph-computer by hugegraph.

the class MiniKubeTest method testGetResourceListWithLabels.

@Test
public void testGetResourceListWithLabels() {
    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(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(15000L).atLeast(1)).onJobStateChanged(Mockito.eq(jobState));
    List<AbstractController<?>> controllers = Whitebox.getInternalState(this.entrypoint, "controllers");
    AbstractController<?> abstractController = controllers.get(0);
    List<Pod> pods = Whitebox.invoke(AbstractController.class, new Class[] { String.class, Class.class, Map.class }, "getResourceListWithLabels", abstractController, this.namespace, Pod.class, new HashMap<String, String>());
    Assert.assertNotEquals(0, pods.size());
    future.cancel(true);
}
Also used : Pod(io.fabric8.kubernetes.api.model.Pod) HashMap(java.util.HashMap) DefaultJobState(com.baidu.hugegraph.computer.driver.DefaultJobState) AbstractController(com.baidu.hugegraph.computer.k8s.operator.common.AbstractController) JobObserver(com.baidu.hugegraph.computer.driver.JobObserver) Test(org.junit.Test)

Aggregations

DefaultJobState (com.baidu.hugegraph.computer.driver.DefaultJobState)1 JobObserver (com.baidu.hugegraph.computer.driver.JobObserver)1 AbstractController (com.baidu.hugegraph.computer.k8s.operator.common.AbstractController)1 Pod (io.fabric8.kubernetes.api.model.Pod)1 HashMap (java.util.HashMap)1 Test (org.junit.Test)1