|
18 | 18 |
|
19 | 19 | package org.apache.hadoop.ozone; |
20 | 20 |
|
| 21 | +import static org.apache.hadoop.hdds.protocol.DatanodeDetails.Port; |
| 22 | +import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY; |
| 23 | +import static org.apache.hadoop.ozone.OzoneConfigKeys.DFS_CONTAINER_RATIS_IPC_RANDOM_PORT; |
| 24 | +import static org.junit.Assert.assertEquals; |
| 25 | +import static org.junit.Assert.assertFalse; |
| 26 | +import static org.junit.Assert.assertTrue; |
| 27 | +import static org.junit.Assert.fail; |
| 28 | + |
| 29 | +import java.io.File; |
| 30 | +import java.io.FileOutputStream; |
| 31 | +import java.io.FileReader; |
| 32 | +import java.io.IOException; |
| 33 | +import java.util.ArrayList; |
| 34 | +import java.util.HashSet; |
| 35 | +import java.util.List; |
| 36 | + |
21 | 37 | import org.apache.commons.lang3.RandomUtils; |
22 | 38 | import org.apache.hadoop.conf.Configuration; |
23 | 39 | import org.apache.hadoop.hdds.HddsConfigKeys; |
24 | 40 | import org.apache.hadoop.hdds.conf.OzoneConfiguration; |
25 | 41 | import org.apache.hadoop.hdds.protocol.DatanodeDetails; |
| 42 | +import org.apache.hadoop.hdds.protocol.proto.HddsProtos; |
| 43 | +import org.apache.hadoop.hdds.scm.TestUtils; |
| 44 | +import org.apache.hadoop.hdds.scm.XceiverClientGrpc; |
| 45 | +import org.apache.hadoop.hdds.scm.pipeline.Pipeline; |
26 | 46 | import org.apache.hadoop.hdds.scm.pipeline.PipelineID; |
27 | 47 | import org.apache.hadoop.hdds.scm.server.StorageContainerManager; |
28 | 48 | import org.apache.hadoop.ozone.container.common.SCMTestUtils; |
29 | 49 | import org.apache.hadoop.ozone.container.common.helpers.ContainerUtils; |
30 | | -import org.apache.hadoop.ozone.container.common.statemachine |
31 | | - .DatanodeStateMachine; |
32 | | -import org.apache.hadoop.ozone.container.common.statemachine |
33 | | - .EndpointStateMachine; |
| 50 | +import org.apache.hadoop.ozone.container.common.statemachine.DatanodeStateMachine; |
| 51 | +import org.apache.hadoop.ozone.container.common.statemachine.EndpointStateMachine; |
34 | 52 | import org.apache.hadoop.ozone.container.ozoneimpl.TestOzoneContainer; |
35 | | -import org.apache.hadoop.hdds.protocol.proto.HddsProtos; |
36 | | -import org.apache.hadoop.hdds.scm.TestUtils; |
37 | | -import org.apache.hadoop.hdds.scm.XceiverClientGrpc; |
38 | | -import org.apache.hadoop.hdds.scm.pipeline.Pipeline; |
39 | 53 | import org.apache.hadoop.test.PathUtils; |
40 | 54 | import org.apache.hadoop.test.TestGenericTestUtils; |
41 | 55 | import org.junit.AfterClass; |
|
44 | 58 | import org.junit.Test; |
45 | 59 | import org.yaml.snakeyaml.Yaml; |
46 | 60 |
|
47 | | -import java.io.File; |
48 | | -import java.io.FileOutputStream; |
49 | | -import java.io.FileReader; |
50 | | -import java.io.IOException; |
51 | | -import java.util.ArrayList; |
52 | | -import java.util.HashSet; |
53 | | -import java.util.List; |
54 | | - |
55 | | -import static org.apache.hadoop.hdds.protocol.DatanodeDetails.Port; |
56 | | -import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_DATANODE_DATA_DIR_KEY; |
57 | | -import static org.apache.hadoop.ozone.OzoneConfigKeys.DFS_CONTAINER_RATIS_IPC_RANDOM_PORT; |
58 | | -import static org.junit.Assert.*; |
59 | | - |
60 | 61 | /** |
61 | 62 | * Test cases for mini ozone cluster. |
62 | 63 | */ |
@@ -167,6 +168,17 @@ public void testDatanodeIDPersistent() throws Exception { |
167 | 168 | } catch (Exception e) { |
168 | 169 | assertTrue(e instanceof IOException); |
169 | 170 | } |
| 171 | + |
| 172 | + // Test upgrade scenario - protobuf file instead of yaml |
| 173 | + File protoFile = new File(WRITE_TMP, "valid-proto.id"); |
| 174 | + try (FileOutputStream out = new FileOutputStream(protoFile)) { |
| 175 | + HddsProtos.DatanodeDetailsProto proto = id1.getProtoBufMessage(); |
| 176 | + proto.writeTo(out); |
| 177 | + } |
| 178 | + validId = ContainerUtils.readDatanodeDetailsFrom(protoFile); |
| 179 | + assertEquals(validId.getCertSerialId(), certSerialId); |
| 180 | + assertEquals(id1, validId); |
| 181 | + assertEquals(id1.getProtoBufMessage(), validId.getProtoBufMessage()); |
170 | 182 | } |
171 | 183 |
|
172 | 184 | @Test |
|
0 commit comments