You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ozone.apache.org by ru...@apache.org on 2021/01/04 06:38:28 UTC
[ozone] branch HDDS-2823 updated: HDDS-3684. Add tests for
replication annotation (#1650)
This is an automated email from the ASF dual-hosted git repository.
runzhiwang pushed a commit to branch HDDS-2823
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/HDDS-2823 by this push:
new 13f2ece HDDS-3684. Add tests for replication annotation (#1650)
13f2ece is described below
commit 13f2eceb92f0f92f33dcf4c2bac0ef6c538914c2
Author: Rui Wang <am...@users.noreply.github.com>
AuthorDate: Sun Jan 3 22:38:09 2021 -0800
HDDS-3684. Add tests for replication annotation (#1650)
---
.../hdds/scm/ha/TestReplicationAnnotation.java | 97 ++++++++++++++++++++++
1 file changed, 97 insertions(+)
diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
new file mode 100644
index 0000000..3609030
--- /dev/null
+++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
@@ -0,0 +1,97 @@
+/*
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.hadoop.hdds.scm.ha;
+
+import org.apache.hadoop.hdds.protocol.proto.HddsProtos;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.container.ContainerStateManagerV2;
+import org.apache.ratis.protocol.exceptions.NotLeaderException;
+import org.apache.ratis.server.RaftServer;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.lang.reflect.Proxy;
+import java.util.List;
+import java.util.concurrent.ExecutionException;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
+ private SCMHAInvocationHandler scmhaInvocationHandler;
+
+ @Before
+ public void setup() {
+ SCMRatisServer ratisServer = new SCMRatisServer() {
+ @Override
+ public void start() throws IOException {
+ }
+
+ @Override
+ public void registerStateMachineHandler(
+ SCMRatisProtocol.RequestType handlerType, Object handler) {
+ }
+
+ @Override
+ public SCMRatisResponse submitRequest(SCMRatisRequest request)
+ throws IOException, ExecutionException, InterruptedException {
+ throw new IOException("submitRequest is called.");
+ }
+
+ @Override
+ public void stop() throws IOException {
+ }
+
+ @Override
+ public RaftServer.Division getDivision() {
+ return null;
+ }
+
+ @Override
+ public List<String> getRatisRoles() {
+ return null;
+ }
+
+ @Override
+ public NotLeaderException triggerNotLeaderException() {
+ return null;
+ }
+ };
+
+ scmhaInvocationHandler = new SCMHAInvocationHandler(
+ RequestType.CONTAINER, null, ratisServer);
+ }
+
+ @Test
+ public void testReplicateAnnotationBasic() throws Throwable {
+ ContainerStateManagerV2 proxy =
+ (ContainerStateManagerV2) Proxy.newProxyInstance(
+ SCMHAInvocationHandler.class.getClassLoader(),
+ new Class<?>[]{ContainerStateManagerV2.class}, scmhaInvocationHandler);
+
+ try {
+ proxy.addContainer(HddsProtos.ContainerInfoProto.getDefaultInstance());
+ // Should have seen a IOException.
+ Assert.fail();
+ } catch (IOException ignore) {
+ // Expecting to hit here.
+ }
+ }
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@ozone.apache.org
For additional commands, e-mail: commits-help@ozone.apache.org