Skip to content
Permalink
Browse files
improve k8s operator test (#76)
* improve k8s operator test

* * improve k8s operator test
* modify ci badge

* add k8s operator test
  • Loading branch information
coderzc committed Aug 3, 2021
1 parent 7f82d96 commit 966beb3eef65243284ddc6b9d0c4deb83fe465fa
Showing 5 changed files with 70 additions and 7 deletions.
@@ -11,7 +11,7 @@ body:
### Note (特别注意) :
> 1. 请先**搜索**现有的[Server-Issues](https://github.com/hugegraph/hugegraph/issues) 与
[Computer-Issues](https://github.com/hugegraph-ee/hugegraph-computer/issues) 中没有与您相同
[Computer-Issues](https://github.com/hugegraph/hugegraph-computer/issues) 中没有与您相同
/ 相关的问题 (请勿重复提交)
> 2. 我们需要尽可能**详细**的信息来**复现**问题, 越详细的信息 (包括**日志 / 截图 / 配置**等)
@@ -36,7 +36,7 @@ body:
attributes:
label: Before submit
options:
- label: 我已经确认现有的 [Server-Issues](https://github.com/hugegraph/hugegraph/issues) 与 [Computer-Issues](https://github.com/hugegraph-ee/hugegraph-computer/issues) 中没有相同 / 重复问题
- label: 我已经确认现有的 [Server-Issues](https://github.com/hugegraph/hugegraph/issues) 与 [Computer-Issues](https://github.com/hugegraph/hugegraph-computer/issues) 中没有相同 / 重复问题
required: true

- type: textarea
@@ -9,7 +9,7 @@ body:
### Note (特别注意) :
> 1. 请先**搜索**现有的[Server-Issues](https://github.com/hugegraph/hugegraph/issues) 与
[Computer-Issues](https://github.com/hugegraph-ee/hugegraph-computer/issues) 中没有与您相同
[Computer-Issues](https://github.com/hugegraph/hugegraph-computer/issues) 中没有与您相同
/ 相关的问题 (请勿重复提交)
> 2. 我们需要尽可能**详细**的信息来**复现**问题, 越详细的信息 (包括**日志 / 截图 / 配置**等)
@@ -35,7 +35,7 @@ body:
attributes:
label: Before submit
options:
- label: 我已经确认现有的 [Server-Issues](https://github.com/hugegraph/hugegraph/issues) 与 [Computer-Issues](https://github.com/hugegraph-ee/hugegraph-computer/issues) 中没有相同 / 重复问题
- label: 我已经确认现有的 [Server-Issues](https://github.com/hugegraph/hugegraph/issues) 与 [Computer-Issues](https://github.com/hugegraph/hugegraph-computer/issues) 中没有相同 / 重复问题
required: true

- type: textarea
@@ -1,8 +1,8 @@
# hugegraph-computer

[![License](https://img.shields.io/badge/license-Apache%202-0E78BA.svg)](https://www.apache.org/licenses/LICENSE-2.0.html)
[![Build Status](https://travis-ci.org/hugegraph-ee/hugegraph-computer.svg?branch=master)](https://travis-ci.org/hugegraph-ee/hugegraph-computer)
[![codecov](https://codecov.io/gh/hugegraph-ee/hugegraph-computer/branch/master/graph/badge.svg)](https://codecov.io/gh/hugegraph-ee/hugegraph-computer)
[![Build Status](https://github.com/hugegraph/hugegraph-computer/actions/workflows/ci.yml/badge.svg)](https://github.com/hugegraph/hugegraph-computer/actions/workflows/ci.yml)
[![codecov](https://codecov.io/gh/hugegraph/hugegraph-computer/branch/master/graph/badge.svg)](https://codecov.io/gh/hugegraph/hugegraph-computer)

hugegraph-computer is a distributed graph processing system for hugegraph. It is an implementaion of [Pregel](https://kowshik.github.io/JPregel/pregel_paper.pdf). It runs on Kubernetes or YARN framework.

@@ -25,6 +25,7 @@
import java.io.IOException;
import java.net.URI;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

@@ -41,16 +42,19 @@
import com.baidu.hugegraph.computer.driver.JobObserver;
import com.baidu.hugegraph.computer.driver.JobStatus;
import com.baidu.hugegraph.computer.driver.config.ComputerOptions;
import com.baidu.hugegraph.computer.k8s.config.KubeDriverOptions;
import com.baidu.hugegraph.computer.k8s.config.KubeSpecOptions;
import com.baidu.hugegraph.computer.k8s.crd.model.HugeGraphComputerJob;
import com.baidu.hugegraph.computer.k8s.driver.KubernetesDriver;
import com.baidu.hugegraph.computer.k8s.operator.common.AbstractController;
import com.baidu.hugegraph.computer.k8s.operator.config.OperatorOptions;
import com.baidu.hugegraph.computer.k8s.util.KubeUtil;
import com.baidu.hugegraph.computer.suite.unit.UnitTestBase;
import com.baidu.hugegraph.testutil.Assert;
import com.baidu.hugegraph.testutil.Whitebox;
import com.google.common.collect.Lists;

import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.api.model.Quantity;

public class MiniKubeTest extends AbstractK8sTest {
@@ -286,4 +290,63 @@ public void testTwiceCreate() {

future.getNow(null);
}

@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 = CompletableFuture.runAsync(() -> {
this.driver.waitJob(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.getNow(null);
}

@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 = CompletableFuture.runAsync(() -> {
this.driver.waitJob(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.getNow(null);
}
}
@@ -11,7 +11,7 @@
<maven>3.3.9</maven>
</prerequisites>
<name>hugegraph-computer</name>
<url>https://github.com/hugegraph-ee/hugegraph-computer</url>
<url>https://github.com/hugegraph/hugegraph-computer</url>
<description>
hugegraph-computer is a fast-speed, highly-scalable, fault-tolerance graph processing system developed by baidu.
</description>

0 comments on commit 966beb3

Please sign in to comment.