ClusterValidator { public void validate() throws MalformedClusterException { validate(Version.CURRENT); } ClusterValidator(Cluster cluster); void validate(); void validate(Version version);  }
@Test public void testSamePublicAndPrivateAddressOnSameNode() { Node node = newTestNode("foo1", "host").setPort(9410).setPublicHostname("host").setPublicPort(9410); new ClusterValidator(newTestCluster(newTestStripe("stripe1").addNodes(node))).validate(); }
@Test public void testSamePublicAndPrivateAddressAcrossNodes() { Node node1 = newTestNode("foo1", "host1").setPort(9410).setPublicHostname("host2").setPublicPort(9410); Node node2 = newTestNode("foo2", "host2", Testing.N_UIDS[2]).setPort(9410).setPublicHostname("host1").setPublicPort(9410); new ClusterValidator(newTestCluster(newTestStripe("stripe1").addNodes(node1, node2))).validate(); }
@Test public void testSetSameBackupPath_ok() { Node node1 = newTestNode("node1", "localhost1"); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]); node1.setBackupDir(RawPath.valueOf("backup")); node2.setBackupDir(RawPath.valueOf("backup")); new ClusterValidator(newTestCluster(newTestStripe("stripe1").addNodes(node1), newTestStripe("stripe2", Testing.S_UIDS[2]).addNodes(node2))).validate(); }
@Test public void testSetDifferentBackupPaths_ok() { Node node1 = newTestNode("node1", "localhost1"); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]); node1.setBackupDir(RawPath.valueOf("backup-1")); node2.setBackupDir(RawPath.valueOf("backup-2")); new ClusterValidator(newTestCluster(newTestStripe("stripe1").addNodes(node1), newTestStripe("stripe2", Testing.S_UIDS[2]).addNodes(node2))).validate(); }
@Test public void testValidCluster() { Node[] nodes = Stream.of( newTestNode("node1", "localhost1"), newTestNode("node2", "localhost2", Testing.N_UIDS[2]) ).map(node -> node .setSecurityAuditLogDir(RawPath.valueOf("audit-" + random.nextInt())) .setSecurityDir(RawPath.valueOf("security-root" + random.nextInt())) .putDataDir("dir-1", RawPath.valueOf("some-path" + random.nextInt())) .setBackupDir(RawPath.valueOf("backup-" + random.nextInt())) .setMetadataDir(RawPath.valueOf("metadata-" + random.nextInt())) .setLogDir(RawPath.valueOf("logs-" + random.nextInt())) .setName("-" + random.nextInt()) .setHostname("host-" + random.nextInt()) .setPort(1 + random.nextInt(65500)) .setGroupPort(1 + random.nextInt(65500)) .setBindAddress(generateAddress()) .setGroupBindAddress(generateAddress()) ).toArray(Node[]::new); Cluster cluster = newTestCluster(newTestStripe("stripe1").addNodes(nodes)) .setSecurityAuthc("file") .setSecuritySslTls(true) .setSecurityWhitelist(false) .putOffheapResource("main", 1L, GB) .setFailoverPriority(consistency()) .setClientReconnectWindow(100L, SECONDS) .setClientLeaseDuration(100L, SECONDS); new ClusterValidator(cluster).validate(); }
@Test public void testGoodSecurity_1() { Node node1 = newTestNode("node1", "localhost1").setSecurityDir(RawPath.valueOf("security-dir")).setSecurityAuditLogDir(RawPath.valueOf("security-audit-dir")); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]).setSecurityDir(RawPath.valueOf("security-dir")).setSecurityAuditLogDir(RawPath.valueOf("security-audit-dir")); Cluster cluster = newTestCluster(newTestStripe("stripe1").addNodes(node1, node2)).setSecuritySslTls(false).setSecurityWhitelist(true); new ClusterValidator(cluster).validate(); }
@Test public void testGoodSecurity_2() { Node node1 = newTestNode("node1", "localhost1").setSecurityDir(RawPath.valueOf("security-dir")).setSecurityAuditLogDir(RawPath.valueOf("security-audit-dir")); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]).setSecurityDir(RawPath.valueOf("security-dir")).setSecurityAuditLogDir(RawPath.valueOf("security-audit-dir")); Cluster cluster = newTestCluster(newTestStripe("stripe1").addNodes(node1, node2)).setSecurityWhitelist(true); new ClusterValidator(cluster).validate(); }
@Test public void testGoodSecurity_3() { Node node1 = newTestNode("node1", "localhost1").setSecurityDir(RawPath.valueOf("security-root-dir")); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]).setSecurityDir(RawPath.valueOf("security-root-dir")); Cluster cluster = newTestCluster(newTestStripe("stripe1").addNodes(node1, node2)).setSecurityAuthc("file"); new ClusterValidator(cluster).validate(); }
@Test public void testGoodSecurity_4() { Node node1 = newTestNode("node1", "localhost1").setSecurityDir(RawPath.valueOf("security-root-dir")); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]).setSecurityDir(RawPath.valueOf("security-root-dir")); Cluster cluster = newTestCluster(newTestStripe("stripe1").addNodes(node1, node2)).setSecuritySslTls(true).setSecurityAuthc("certificate"); new ClusterValidator(cluster).validate(); }
@Test public void testGoodSecurity_5() { Node node1 = newTestNode("node1", "localhost1").setSecurityDir(RawPath.valueOf("security-root-dir")).setSecurityAuditLogDir(RawPath.valueOf("security-audit-dir")); Node node2 = newTestNode("node2", "localhost2", Testing.N_UIDS[2]).setSecurityDir(RawPath.valueOf("security-root-dir")).setSecurityAuditLogDir(RawPath.valueOf("security-audit-dir")); Cluster cluster = newTestCluster(newTestStripe("stripe1").addNodes(node1, node2)) .setSecuritySslTls(true) .setSecurityAuthc("certificate") .setSecurityWhitelist(true); new ClusterValidator(cluster).validate(); }