You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2020/12/02 21:26:51 UTC
[GitHub] [ozone] amaliujia opened a new pull request #1650: HDDS-3684. Add tests for replication annotation
amaliujia opened a new pull request #1650:
URL: https://github.com/apache/ozone/pull/1650
## What changes were proposed in this pull request?
Add tests for replication annotation
## What is the link to the Apache JIRA
https://issues.apache.org/jira/browse/HDDS-3684
## How was this patch tested?
Unit Test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] GlenGeng commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550069026
##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/MockSCMHAManager.java
##########
@@ -15,29 +15,28 @@
* the License.
*/
+/*
+ * 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
Review comment:
Hey Rui, Why we need to move MockRatisServer out of MockSCMHAManager ? My concern is
`// TODO: Move this class to test package after fixing Recon`, I would like to separate them until they are moved back to test dir.
You duplicated the licenses.
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
Review comment:
Hey Rui, I suggested to simulate the real ratis call, what do you think ?
```
public class TestReplicationAnnotation {
@Test
public void testReplicateAnnotationBasic() throws Throwable {
final ContainerStateManagerV2 csm = new ContainerStateManagerV2() {
@Override
public boolean contains(HddsProtos.ContainerID containerID) {
return false;
}
@Override
public Set<ContainerID> getContainerIDs() {
return null;
}
@Override
public Set<ContainerID> getContainerIDs(HddsProtos.LifeCycleState state) {
return null;
}
@Override
public ContainerInfo getContainer(HddsProtos.ContainerID id) {
return null;
}
@Override
public Set<ContainerReplica> getContainerReplicas(HddsProtos.ContainerID id) {
return null;
}
@Override
public void updateContainerReplica(HddsProtos.ContainerID id, ContainerReplica replica) {
}
@Override
public void removeContainerReplica(HddsProtos.ContainerID id, ContainerReplica replica) {
}
@Override
public void addContainer(HddsProtos.ContainerInfoProto containerInfo) throws IOException {
}
@Override
public void updateContainerState(HddsProtos.ContainerID id, HddsProtos.LifeCycleEvent event) throws IOException, InvalidStateTransitionException {
}
@Override
public void updateDeleteTransactionId(Map<ContainerID, Long> deleteTransactionMap) throws IOException {
}
@Override
public ContainerInfo getMatchingContainer(long size, String owner, PipelineID pipelineID, NavigableSet<ContainerID> containerIDs) {
return null;
}
@Override
public void removeContainer(HddsProtos.ContainerID containerInfo) throws IOException {
}
@Override
public void close() throws IOException {
}
};
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;
}
};
final SCMHAInvocationHandler invocationHandler =
new SCMHAInvocationHandler(
SCMRatisProtocol.RequestType.CONTAINER, csm, ratisServer);
ContainerStateManagerV2 proxy = (ContainerStateManagerV2) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{ContainerStateManagerV2.class}, invocationHandler);
try {
proxy.addContainer(HddsProtos.ContainerInfoProto.getDefaultInstance());
Assert.fail();
} catch (IOException ignore) {
}
}
}
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550421566
##########
File path: 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());
Review comment:
@GlenGeng
Done.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550421682
##########
File path: 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);
Review comment:
We only want to see that it will hit SCMHAInvocationHandler.invokeRatis() so there is no need to implement a ContainerStateManagerV2.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] GlenGeng commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550410187
##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/MockSCMHAManager.java
##########
@@ -92,11 +92,20 @@ public void shutdown() throws IOException {
ratisServer.stop();
}
- private class MockRatisServer implements SCMRatisServer {
+ /**
+ * Mock RatisServer implementation for testing.
Review comment:
Hey Rui, changes in MockSCMHAManager.java may not be needed, since MockRatisServer is an inner class of MockSCMHAManager,
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
##########
@@ -0,0 +1,139 @@
+/*
+ * 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.RequestType;
+import org.apache.hadoop.hdds.scm.container.ContainerID;
+import org.apache.hadoop.hdds.scm.container.ContainerInfo;
+import org.apache.hadoop.hdds.scm.container.ContainerReplica;
+import org.apache.hadoop.hdds.scm.container.ContainerStateManagerV2;
+import org.apache.hadoop.hdds.scm.pipeline.PipelineID;
+import org.apache.hadoop.ozone.common.statemachine.InvalidStateTransitionException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.NavigableSet;
+import java.util.Set;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
+ private SCMHAInvocationHandler scmhaInvocationHandler;
+ private ContainerStateManagerV2 mockCSM;
+
+ @Before
+ public void setup() {
+ SCMHAManager mock = MockSCMHAManager.getInstance(true);
+ mockCSM = new ContainerStateManagerV2() {
+ @Override
+ public boolean contains(HddsProtos.ContainerID containerID) {
+ return false;
+ }
+
+ @Override
+ public Set<ContainerID> getContainerIDs() {
+ return null;
+ }
+
+ @Override
+ public Set<ContainerID> getContainerIDs(
+ HddsProtos.LifeCycleState state) {
+ return null;
+ }
+
+ @Override
+ public ContainerInfo getContainer(HddsProtos.ContainerID id) {
+ return null;
+ }
+
+ @Override
+ public Set<ContainerReplica> getContainerReplicas(
+ HddsProtos.ContainerID id) {
+ return null;
+ }
+
+ @Override
+ public void updateContainerReplica(
+ HddsProtos.ContainerID id, ContainerReplica replica) {
+
+ }
+
+ @Override
+ public void removeContainerReplica(
+ HddsProtos.ContainerID id, ContainerReplica replica) {
+
+ }
+
+ @Override
+ public void addContainer(HddsProtos.ContainerInfoProto containerInfo)
+ throws IOException {
+
+ }
+
+ @Override
+ public void updateContainerState(
+ HddsProtos.ContainerID id, HddsProtos.LifeCycleEvent event)
+ throws IOException, InvalidStateTransitionException {
+
+ }
+
+ @Override
+ public void updateDeleteTransactionId(
+ Map<ContainerID, Long> deleteTransactionMap) throws IOException {
+
+ }
+
+ @Override
+ public ContainerInfo getMatchingContainer(
+ long size, String owner, PipelineID pipelineID,
+ NavigableSet<ContainerID> containerIDs) {
+ return null;
+ }
+
+ @Override
+ public void removeContainer(HddsProtos.ContainerID containerInfo)
+ throws IOException {
+ }
+
+ @Override
+ public void close() throws IOException {
+
+ }
+ };
+
+ scmhaInvocationHandler = new SCMHAInvocationHandler(
+ RequestType.CONTAINER, mockCSM, mock.getRatisServer());
+ }
+
+ @Test
+ public void testReplicateAnnotationBasic() throws Throwable {
+ // test whether this call will hit the Ratis based replication
+ // code path in SCMHAInvocationHandler. The invoke() can return means the
+ // request is handled properly thus response is successful. Expected
+ // result is null because the function returns nothing.
+ Object[] arguments = {HddsProtos.ContainerInfoProto.getDefaultInstance()};
+ Assert.assertEquals(null, scmhaInvocationHandler.invoke(new Object(),
Review comment:
Hey Rui, I consider you have to use my anonymous version of SCMRatisServer,
because of
```
@Override
public SCMRatisResponse submitRequest(SCMRatisRequest request) throws IOException, ExecutionException, InterruptedException {
throw new IOException("submitRequest is called.");
}
```
,
from the IOException
```
ContainerStateManagerV2 proxy = (ContainerStateManagerV2) Proxy.newProxyInstance(
SCMHAInvocationHandler.class.getClassLoader(),
new Class<?>[]{ContainerStateManagerV2.class}, invocationHandler);
try {
proxy.addContainer(HddsProtos.ContainerInfoProto.getDefaultInstance());
Assert.fail();
} catch (IOException ignore) {
}
```
we can know that `invokeRatis()` is called, due to the annotation.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#issuecomment-752862764
@GlenGeng
can you take another look?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r534536573
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestRelicationAnnotation.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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 java.io.IOException;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestRelicationAnnotation {
+ private SCMHAInvocationHandler scmhaInvocationHandler;
+
+ @Before
+ public void setup() {
+ scmhaInvocationHandler = new SCMHAInvocationHandler(
+ RequestType.CONTAINER,
+ null,
+ new MockRatisServer());
+ }
+
+ @Test(expected = IOException.class)
+ public void testReplicateAnnotationBasic() throws Throwable {
+ // test whether replicatedOperation will hit the Ratis based replication
+ // code path in SCMHAInvocationHandler. Expect to see a IOException cause
+ // no handler is added yet.
+ scmhaInvocationHandler.invoke(new Object(),
+ this.getClass().getMethod("replicatedOperation"), new Object[0]);
+ }
+
+ @Replicate
+ public void replicatedOperation() { }
Review comment:
Should I actually mock a InvocationHandler and add a request type `RequestType.Test`? Then make sure `replicatedOperation` is eventually called.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#issuecomment-737505759
R @timmylicheng
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550355943
##########
File path: hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/MockSCMHAManager.java
##########
@@ -15,29 +15,28 @@
* the License.
*/
+/*
+ * 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
Review comment:
O we don't need to :)
That was a old design but now our codebase has changed so there is no need to move out this Ratis server. I will move it back.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] runzhiwang commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
runzhiwang commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r551137844
##########
File path: 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();
Review comment:
Please add some message such as Assert.fail("xxxxx");
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550404386
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
Review comment:
Done
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia edited a comment on pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia edited a comment on pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#issuecomment-752308325
cc @GlenGeng @ChenSammi @nandakumar131
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] GlenGeng commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550389764
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
Review comment:
I consider that we can create a MockContainerStateManagerV2 when we need it. This anonymous one is an auto generated class by IDE.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] GlenGeng commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
GlenGeng commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r535194289
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestRelicationAnnotation.java
##########
@@ -0,0 +1,50 @@
+/*
+ * 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 java.io.IOException;
+import org.apache.hadoop.hdds.protocol.proto.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestRelicationAnnotation {
Review comment:
typo `Relication` -> `Replication`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r550357487
##########
File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/ha/TestReplicationAnnotation.java
##########
@@ -0,0 +1,55 @@
+/*
+ * 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.SCMRatisProtocol.RequestType;
+import org.apache.hadoop.hdds.scm.metadata.Replicate;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Tests on {@link org.apache.hadoop.hdds.scm.metadata.Replicate}.
+ */
+public class TestReplicationAnnotation {
Review comment:
I see. How about creating a MockContainerStateManagerV2 directly?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] runzhiwang merged pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
runzhiwang merged pull request #1650:
URL: https://github.com/apache/ozone/pull/1650
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] GlenGeng commented on pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
GlenGeng commented on pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#issuecomment-752881835
+1. waiting for CI.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] amaliujia commented on pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
amaliujia commented on pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#issuecomment-752308325
cc @GlenGeng @ChenSammi
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org
[GitHub] [ozone] runzhiwang commented on a change in pull request #1650: HDDS-3684. Add tests for replication annotation
Posted by GitBox <gi...@apache.org>.
runzhiwang commented on a change in pull request #1650:
URL: https://github.com/apache/ozone/pull/1650#discussion_r551137844
##########
File path: 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();
Review comment:
Please add some message such as Assert.fail("xxxxx");. You can do it in next pr, I will merge this first.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org