|
@@ -115,32 +115,47 @@ public class TestRegistryDNS extends Assert {
|
|
|
+ "}\n";
|
|
|
static final String CONTAINER_RECORD = "{\n"
|
|
|
+ " \"type\" : \"JSONServiceRecord\",\n"
|
|
|
- + " \"description\" : \"COMP-NAME\",\n"
|
|
|
+ + " \"description\" : \"httpd-1\",\n"
|
|
|
+ " \"external\" : [ ],\n"
|
|
|
+ " \"internal\" : [ ],\n"
|
|
|
+ " \"yarn:id\" : \"container_e50_1451931954322_0016_01_000002\",\n"
|
|
|
+ " \"yarn:persistence\" : \"container\",\n"
|
|
|
+ " \"yarn:ip\" : \"172.17.0.19\",\n"
|
|
|
- + " \"yarn:hostname\" : \"0a134d6329ba\"\n"
|
|
|
+ + " \"yarn:hostname\" : \"host1\",\n"
|
|
|
+ + " \"yarn:component\" : \"httpd\"\n"
|
|
|
+ + "}\n";
|
|
|
+
|
|
|
+ static final String CONTAINER_RECORD2 = "{\n"
|
|
|
+ + " \"type\" : \"JSONServiceRecord\",\n"
|
|
|
+ + " \"description\" : \"httpd-2\",\n"
|
|
|
+ + " \"external\" : [ ],\n"
|
|
|
+ + " \"internal\" : [ ],\n"
|
|
|
+ + " \"yarn:id\" : \"container_e50_1451931954322_0016_01_000003\",\n"
|
|
|
+ + " \"yarn:persistence\" : \"container\",\n"
|
|
|
+ + " \"yarn:ip\" : \"172.17.0.20\",\n"
|
|
|
+ + " \"yarn:hostname\" : \"host2\",\n"
|
|
|
+ + " \"yarn:component\" : \"httpd\"\n"
|
|
|
+ "}\n";
|
|
|
|
|
|
private static final String CONTAINER_RECORD_NO_IP = "{\n"
|
|
|
+ " \"type\" : \"JSONServiceRecord\",\n"
|
|
|
- + " \"description\" : \"COMP-NAME\",\n"
|
|
|
+ + " \"description\" : \"httpd-1\",\n"
|
|
|
+ " \"external\" : [ ],\n"
|
|
|
+ " \"internal\" : [ ],\n"
|
|
|
+ " \"yarn:id\" : \"container_e50_1451931954322_0016_01_000002\",\n"
|
|
|
- + " \"yarn:persistence\" : \"container\"\n"
|
|
|
+ + " \"yarn:persistence\" : \"container\",\n"
|
|
|
+ + " \"yarn:component\" : \"httpd\"\n"
|
|
|
+ "}\n";
|
|
|
|
|
|
private static final String CONTAINER_RECORD_YARN_PERSISTANCE_ABSENT = "{\n"
|
|
|
+ " \"type\" : \"JSONServiceRecord\",\n"
|
|
|
- + " \"description\" : \"COMP-NAME\",\n"
|
|
|
+ + " \"description\" : \"httpd-1\",\n"
|
|
|
+ " \"external\" : [ ],\n"
|
|
|
+ " \"internal\" : [ ],\n"
|
|
|
+ " \"yarn:id\" : \"container_e50_1451931954322_0016_01_000003\",\n"
|
|
|
+ " \"yarn:ip\" : \"172.17.0.19\",\n"
|
|
|
- + " \"yarn:hostname\" : \"0a134d6329bb\"\n"
|
|
|
+ + " \"yarn:hostname\" : \"0a134d6329bb\",\n"
|
|
|
+ + " \"yarn:component\" : \"httpd\""
|
|
|
+ "}\n";
|
|
|
|
|
|
@Before
|
|
@@ -229,7 +244,7 @@ public class TestRegistryDNS extends Assert {
|
|
|
assertEquals("wrong result", "172.17.0.19",
|
|
|
((ARecord) recs[0]).getAddress().getHostAddress());
|
|
|
|
|
|
- recs = assertDNSQuery("comp-name.test1.root.dev.test.", 1);
|
|
|
+ recs = assertDNSQuery("httpd-1.test1.root.dev.test.", 1);
|
|
|
assertTrue("not an ARecord", recs[0] instanceof ARecord);
|
|
|
}
|
|
|
|
|
@@ -268,7 +283,7 @@ public class TestRegistryDNS extends Assert {
|
|
|
((ARecord) recs[0]).getAddress().getHostAddress());
|
|
|
assertEquals("wrong ttl", 30L, recs[0].getTTL());
|
|
|
|
|
|
- recs = assertDNSQuery("comp-name.test1.root.dev.test.", 1);
|
|
|
+ recs = assertDNSQuery("httpd-1.test1.root.dev.test.", 1);
|
|
|
assertTrue("not an ARecord", recs[0] instanceof ARecord);
|
|
|
|
|
|
assertEquals("wrong ttl", 30L, recs[0].getTTL());
|
|
@@ -286,7 +301,7 @@ public class TestRegistryDNS extends Assert {
|
|
|
// start assessing whether correct records are available
|
|
|
Record[] recs = assertDNSQuery("19.0.17.172.in-addr.arpa.", Type.PTR, 1);
|
|
|
assertEquals("wrong result",
|
|
|
- "comp-name.test1.root.dev.test.",
|
|
|
+ "httpd-1.test1.root.dev.test.",
|
|
|
((PTRRecord) recs[0]).getTarget().toString());
|
|
|
}
|
|
|
|
|
@@ -312,7 +327,7 @@ public class TestRegistryDNS extends Assert {
|
|
|
// start assessing whether correct records are available
|
|
|
Record[] recs = assertDNSQuery("19.0.17.172.in-addr.arpa.", Type.PTR, 1);
|
|
|
assertEquals("wrong result",
|
|
|
- "comp-name.test1.root.dev.test.",
|
|
|
+ "httpd-1.test1.root.dev.test.",
|
|
|
((PTRRecord) recs[0]).getTarget().toString());
|
|
|
}
|
|
|
|
|
@@ -490,7 +505,7 @@ public class TestRegistryDNS extends Assert {
|
|
|
assertEquals("wrong result", "172.17.0.19",
|
|
|
((AAAARecord) recs[0]).getAddress().getHostAddress());
|
|
|
|
|
|
- recs = assertDNSQuery("comp-name.test1.root.dev.test.", Type.AAAA, 1);
|
|
|
+ recs = assertDNSQuery("httpd-1.test1.root.dev.test.", Type.AAAA, 1);
|
|
|
assertTrue("not an ARecord", recs[0] instanceof AAAARecord);
|
|
|
}
|
|
|
|
|
@@ -565,13 +580,13 @@ public class TestRegistryDNS extends Assert {
|
|
|
assertEquals("wrong result", "172.17.0.19",
|
|
|
((ARecord) recs[0]).getAddress().getHostAddress());
|
|
|
|
|
|
- recs = assertDNSQuery("comp-name.test1.root.dev.test.", 1);
|
|
|
+ recs = assertDNSQuery("httpd-1.test1.root.dev.test.", 1);
|
|
|
assertTrue("not an ARecord", recs[0] instanceof ARecord);
|
|
|
|
|
|
// lookup dyanmic reverse records
|
|
|
recs = assertDNSQuery("19.0.17.172.in-addr.arpa.", Type.PTR, 1);
|
|
|
assertEquals("wrong result",
|
|
|
- "comp-name.test1.root.dev.test.",
|
|
|
+ "httpd-1.test1.root.dev.test.",
|
|
|
((PTRRecord) recs[0]).getTarget().toString());
|
|
|
|
|
|
// now lookup static reverse records
|
|
@@ -649,6 +664,27 @@ public class TestRegistryDNS extends Assert {
|
|
|
assertDNSQueryNotNull("mail.yahoo.com.", Type.CNAME);
|
|
|
}
|
|
|
|
|
|
+ @Test
|
|
|
+ public void testMultiARecord() throws Exception {
|
|
|
+ ServiceRecord record = getMarshal().fromBytes("somepath",
|
|
|
+ CONTAINER_RECORD.getBytes());
|
|
|
+ ServiceRecord record2 = getMarshal().fromBytes("somepath",
|
|
|
+ CONTAINER_RECORD2.getBytes());
|
|
|
+ getRegistryDNS().register(
|
|
|
+ "/registry/users/root/services/org-apache-slider/test1/components/"
|
|
|
+ + "ctr-e50-1451931954322-0016-01-000002",
|
|
|
+ record);
|
|
|
+ getRegistryDNS().register(
|
|
|
+ "/registry/users/root/services/org-apache-slider/test1/components/"
|
|
|
+ + "ctr-e50-1451931954322-0016-01-000003",
|
|
|
+ record2);
|
|
|
+
|
|
|
+ // start assessing whether correct records are available
|
|
|
+ Record[] recs =
|
|
|
+ assertDNSQuery("httpd.test1.root.dev.test.", 2);
|
|
|
+ assertTrue("not an ARecord", recs[0] instanceof ARecord);
|
|
|
+ assertTrue("not an ARecord", recs[1] instanceof ARecord);
|
|
|
+ }
|
|
|
public RegistryDNS getRegistryDNS() {
|
|
|
return registryDNS;
|
|
|
}
|