You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by wu...@apache.org on 2019/04/21 12:19:17 UTC
[skywalking] branch master updated: Add unit test for GRPCExporter
and GRPCExporterProvider (#2498)
This is an automated email from the ASF dual-hosted git repository.
wusheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/skywalking.git
The following commit(s) were added to refs/heads/master by this push:
new ec7dba3 Add unit test for GRPCExporter and GRPCExporterProvider (#2498)
ec7dba3 is described below
commit ec7dba3cab3437cf99b02219687a794a18705118
Author: Ming Deng <mi...@qq.com>
AuthorDate: Sun Apr 21 20:19:09 2019 +0800
Add unit test for GRPCExporter and GRPCExporterProvider (#2498)
* Add unit test for GRPCExporter and GRPCExporterProvider
* MockLongValueIndicator impl the LongValueHolder and MockIntValueIndicator impl the IntValueHolder
* formate the code
---
oap-server/exporter/pom.xml | 4 +
.../provider/grpc/GRPCExporterProvider.java | 7 +-
.../provider/grpc/ExporterMockReceiver.java | 17 ++--
.../provider/grpc/GRPCExporterProviderTest.java | 112 +++++++++++++++++++++
.../exporter/provider/grpc/GRPCExporterTest.java | 103 +++++++++++++++++++
.../provider/grpc/MockDoubleValueIndicator.java | 31 ++++++
.../exporter/provider/grpc/MockIndicator.java | 73 ++++++++++++++
.../provider/grpc/MockIntValueIndicatior.java | 31 ++++++
.../provider/grpc/MockLongValueIndicator.java | 31 ++++++
.../provider/grpc/MockMetricExportServiceImpl.java | 39 +++++++
10 files changed, 439 insertions(+), 9 deletions(-)
diff --git a/oap-server/exporter/pom.xml b/oap-server/exporter/pom.xml
index 73a0caf..d7a13ac 100644
--- a/oap-server/exporter/pom.xml
+++ b/oap-server/exporter/pom.xml
@@ -35,6 +35,10 @@
<artifactId>server-core</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>io.grpc</groupId>
+ <artifactId>grpc-testing</artifactId>
+ </dependency>
</dependencies>
<build>
diff --git a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java
index 84de719..c0fa7a0 100644
--- a/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java
+++ b/oap-server/exporter/src/main/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProvider.java
@@ -53,9 +53,10 @@ public class GRPCExporterProvider extends ModuleProvider {
}
@Override public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
- exporter.setServiceInventoryCache(getManager().find(CoreModule.NAME).provider().getService(ServiceInventoryCache.class));
- exporter.setServiceInstanceInventoryCache(getManager().find(CoreModule.NAME).provider().getService(ServiceInstanceInventoryCache.class));
- exporter.setEndpointInventoryCache(getManager().find(CoreModule.NAME).provider().getService(EndpointInventoryCache.class));
+ ModuleServiceHolder serviceHolder = getManager().find(CoreModule.NAME).provider();
+ exporter.setServiceInventoryCache(serviceHolder.getService(ServiceInventoryCache.class));
+ exporter.setServiceInstanceInventoryCache(serviceHolder.getService(ServiceInstanceInventoryCache.class));
+ exporter.setEndpointInventoryCache(serviceHolder.getService(EndpointInventoryCache.class));
exporter.initSubscriptionList();
}
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/ExporterMockReceiver.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/ExporterMockReceiver.java
index 57da559..e0b307c 100644
--- a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/ExporterMockReceiver.java
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/ExporterMockReceiver.java
@@ -21,7 +21,8 @@ package org.apache.skywalking.oap.server.exporter.provider.grpc;
import io.grpc.stub.StreamObserver;
import org.apache.skywalking.oap.server.exporter.grpc.*;
import org.apache.skywalking.oap.server.library.server.ServerException;
-import org.apache.skywalking.oap.server.library.server.grpc.*;
+import org.apache.skywalking.oap.server.library.server.grpc.GRPCHandler;
+import org.apache.skywalking.oap.server.library.server.grpc.GRPCServer;
public class ExporterMockReceiver {
public static void main(String[] args) throws ServerException, InterruptedException {
@@ -36,16 +37,20 @@ public class ExporterMockReceiver {
}
public static class MockHandler extends MetricExportServiceGrpc.MetricExportServiceImplBase implements GRPCHandler {
- @Override public StreamObserver<ExportMetricValue> export(StreamObserver<ExportResponse> responseObserver) {
+ @Override
+ public StreamObserver<ExportMetricValue> export(StreamObserver<ExportResponse> responseObserver) {
return new StreamObserver<ExportMetricValue>() {
- @Override public void onNext(ExportMetricValue value) {
+ @Override
+ public void onNext(ExportMetricValue value) {
}
- @Override public void onError(Throwable throwable) {
+ @Override
+ public void onError(Throwable throwable) {
responseObserver.onError(throwable);
}
- @Override public void onCompleted() {
+ @Override
+ public void onCompleted() {
responseObserver.onCompleted();
}
};
@@ -54,7 +59,7 @@ public class ExporterMockReceiver {
@Override
public void subscription(SubscriptionReq request, StreamObserver<SubscriptionsResp> responseObserver) {
responseObserver.onNext(SubscriptionsResp.newBuilder()
- .addMetricNames("all_p99").addMetricNames("service_cpm").addMetricNames("endpoint_sla").build());
+ .addMetricNames("all_p99").addMetricNames("service_cpm").addMetricNames("endpoint_sla").build());
responseObserver.onCompleted();
}
}
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java
new file mode 100644
index 0000000..97f0741
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterProviderTest.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import org.apache.skywalking.oap.server.core.CoreModule;
+import org.apache.skywalking.oap.server.core.cache.EndpointInventoryCache;
+import org.apache.skywalking.oap.server.core.cache.ServiceInstanceInventoryCache;
+import org.apache.skywalking.oap.server.core.cache.ServiceInventoryCache;
+import org.apache.skywalking.oap.server.core.exporter.ExporterModule;
+import org.apache.skywalking.oap.server.library.module.*;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+@Ignore
+public class GRPCExporterProviderTest {
+
+ private ServiceLoader<ModuleProvider> serviceLoader = ServiceLoader.load(ModuleProvider.class);
+ private ModuleProvider grpcExporterProvider;
+
+ @Before
+ public void setUp() throws ModuleStartException {
+ Iterator<ModuleProvider> moduleProviderIterator = serviceLoader.iterator();
+ assertTrue(moduleProviderIterator.hasNext());
+
+ grpcExporterProvider = moduleProviderIterator.next();
+ assertTrue(grpcExporterProvider instanceof GRPCExporterProvider);
+
+ GRPCExporterSetting config = (GRPCExporterSetting) grpcExporterProvider.createConfigBeanIfAbsent();
+ assertNotNull(config);
+ assertNull(config.getTargetHost());
+ assertEquals(0, config.getTargetPort());
+ assertEquals(20000, config.getBufferChannelSize());
+ assertEquals(2, config.getBufferChannelNum());
+
+ //for test
+ config.setTargetHost("localhost");
+
+ grpcExporterProvider.prepare();
+
+ grpcExporterProvider.start();
+ }
+
+ @Test
+ public void name() {
+ assertEquals("grpc", grpcExporterProvider.name());
+ }
+
+ @Test
+ public void module() {
+ assertEquals(ExporterModule.class, grpcExporterProvider.module());
+ }
+
+
+ @Test
+ public void notifyAfterCompleted() throws ServiceNotProvidedException, ModuleStartException {
+ GRPCExporter exporter = mock(GRPCExporter.class);
+
+ ModuleManager manager = mock(ModuleManager.class);
+ ModuleProviderHolder providerHolder = mock(ModuleProviderHolder.class);
+
+
+ ModuleServiceHolder serviceHolder = mock(ModuleServiceHolder.class);
+
+ when(manager.find(CoreModule.NAME)).thenReturn(providerHolder);
+ when(providerHolder.provider()).thenReturn(serviceHolder);
+
+ when(serviceHolder.getService(ServiceInventoryCache.class)).thenReturn(null);
+ when(serviceHolder.getService(ServiceInstanceInventoryCache.class)).thenReturn(null);
+ when(serviceHolder.getService(EndpointInventoryCache.class)).thenReturn(null);
+
+ doNothing().when(exporter).initSubscriptionList();
+
+ grpcExporterProvider.setManager(manager);
+ Whitebox.setInternalState(grpcExporterProvider, "exporter", exporter);
+ grpcExporterProvider.notifyAfterCompleted();
+ }
+
+ @Test
+ public void requiredModules() {
+ String[] requireModules = grpcExporterProvider.requiredModules();
+ assertNotNull(requireModules);
+ assertEquals(1, requireModules.length);
+ assertEquals("core", requireModules[0]);
+ }
+}
\ No newline at end of file
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java
new file mode 100644
index 0000000..8158756
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/GRPCExporterTest.java
@@ -0,0 +1,103 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import io.grpc.testing.GrpcServerRule;
+import org.apache.skywalking.oap.server.core.analysis.indicator.IndicatorMetaInfo;
+import org.apache.skywalking.oap.server.core.source.DefaultScopeDefine;
+import org.apache.skywalking.oap.server.exporter.grpc.MetricExportServiceGrpc;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.powermock.reflect.Whitebox;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+public class GRPCExporterTest {
+
+ private GRPCExporter exporter;
+
+ @Rule
+ public final GrpcServerRule grpcServerRule = new GrpcServerRule().directExecutor();
+
+ private MetricExportServiceGrpc.MetricExportServiceImplBase server = new MockMetricExportServiceImpl();
+ private IndicatorMetaInfo metaInfo = new IndicatorMetaInfo("mock-indicator", DefaultScopeDefine.ALL);
+
+ private MetricExportServiceGrpc.MetricExportServiceBlockingStub stub;
+
+ @Before
+ public void setUp() throws Exception {
+ GRPCExporterSetting setting = new GRPCExporterSetting();
+ setting.setTargetHost("localhost");
+ setting.setTargetPort(9870);
+ exporter = new GRPCExporter(setting);
+ grpcServerRule.getServiceRegistry().addService(server);
+ stub = MetricExportServiceGrpc.newBlockingStub(grpcServerRule.getChannel());
+ }
+
+ @Test
+ public void export() {
+ exporter.export(metaInfo, new MockIndicator());
+ }
+
+ @Test
+ public void initSubscriptionList() {
+ Whitebox.setInternalState(exporter, "blockingStub", stub);
+ exporter.initSubscriptionList();
+ }
+
+ @Test
+ public void init() {
+ exporter.init();
+ }
+
+ @Test
+ public void consume() {
+
+ exporter.consume(dataList());
+ exporter.consume(Collections.emptyList());
+ }
+
+
+ @Test
+ public void onError() {
+ Exception e = new IllegalArgumentException("some something wrong");
+ exporter.onError(Collections.emptyList(), e);
+ exporter.onError(dataList(), e);
+ }
+
+ @Test
+ public void onExit() {
+ exporter.onExit();
+ }
+
+ private List<GRPCExporter.ExportData> dataList() {
+ List<GRPCExporter.ExportData> dataList = new LinkedList<>();
+ dataList.add(exporter.new ExportData(metaInfo, new MockIndicator()));
+ dataList.add(exporter.new ExportData(metaInfo, new MockIntValueIndicatior()));
+ dataList.add(exporter.new ExportData(metaInfo, new MockLongValueIndicator()));
+ dataList.add(exporter.new ExportData(metaInfo, new MockDoubleValueIndicator()));
+ return dataList;
+ }
+}
\ No newline at end of file
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueIndicator.java
new file mode 100644
index 0000000..6b4fc9c
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockDoubleValueIndicator.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import org.apache.skywalking.oap.server.core.analysis.indicator.DoubleValueHolder;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+public class MockDoubleValueIndicator extends MockIndicator implements DoubleValueHolder {
+ @Override
+ public double getValue() {
+ return 2.3;
+ }
+}
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIndicator.java
new file mode 100644
index 0000000..f1a74c4
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIndicator.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import org.apache.skywalking.oap.server.core.analysis.indicator.Indicator;
+import org.apache.skywalking.oap.server.core.remote.grpc.proto.RemoteData;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+public class MockIndicator extends Indicator {
+
+ @Override
+ public String id() {
+ return "mock-indicator";
+ }
+
+ @Override
+ public void combine(Indicator indicator) {
+
+ }
+
+ @Override
+ public void calculate() {
+
+ }
+
+ @Override
+ public Indicator toHour() {
+ return this;
+ }
+
+ @Override
+ public Indicator toDay() {
+ return this;
+ }
+
+ @Override
+ public Indicator toMonth() {
+ return this;
+ }
+
+ @Override
+ public int remoteHashCode() {
+ return 1;
+ }
+
+ @Override
+ public void deserialize(RemoteData remoteData) {
+
+ }
+
+ @Override
+ public RemoteData.Builder serialize() {
+ return null;
+ }
+}
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueIndicatior.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueIndicatior.java
new file mode 100644
index 0000000..cd3b927
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockIntValueIndicatior.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import org.apache.skywalking.oap.server.core.analysis.indicator.IntValueHolder;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+public class MockIntValueIndicatior extends MockIndicator implements IntValueHolder {
+ @Override
+ public int getValue() {
+ return 12;
+ }
+}
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueIndicator.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueIndicator.java
new file mode 100644
index 0000000..a8ee915
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockLongValueIndicator.java
@@ -0,0 +1,31 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import org.apache.skywalking.oap.server.core.analysis.indicator.LongValueHolder;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+public class MockLongValueIndicator extends MockIndicator implements LongValueHolder {
+ @Override
+ public long getValue() {
+ return 1234567891234563312L;
+ }
+}
diff --git a/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockMetricExportServiceImpl.java b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockMetricExportServiceImpl.java
new file mode 100644
index 0000000..b4d64c8
--- /dev/null
+++ b/oap-server/exporter/src/test/java/org/apache/skywalking/oap/server/exporter/provider/grpc/MockMetricExportServiceImpl.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+package org.apache.skywalking.oap.server.exporter.provider.grpc;
+
+import io.grpc.stub.StreamObserver;
+import org.apache.skywalking.oap.server.exporter.grpc.MetricExportServiceGrpc;
+import org.apache.skywalking.oap.server.exporter.grpc.SubscriptionReq;
+import org.apache.skywalking.oap.server.exporter.grpc.SubscriptionsResp;
+
+/**
+ * Created by dengming, 2019.04.20
+ */
+public class MockMetricExportServiceImpl extends MetricExportServiceGrpc.MetricExportServiceImplBase {
+ @Override
+ public void subscription(SubscriptionReq request, StreamObserver<SubscriptionsResp> responseObserver) {
+ SubscriptionsResp resp = SubscriptionsResp.newBuilder()
+ .addMetricNames("first")
+ .addMetricNames("second")
+ .build();
+ responseObserver.onNext(resp);
+ responseObserver.onCompleted();
+ }
+}