-
Notifications
You must be signed in to change notification settings - Fork 526
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
263 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
...ertest-test/src/main/java/org/apache/hugegraph/MultiClusterTest/BaseMultiClusterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.hugegraph.MultiClusterTest; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.IOException; | ||
import java.io.InputStreamReader; | ||
|
||
import org.apache.hugegraph.ct.env.BaseEnv; | ||
import org.apache.hugegraph.ct.env.MultiNodeEnv; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
|
||
public class BaseMultiClusterTest { | ||
|
||
protected static BaseEnv env; | ||
|
||
protected static Process p; | ||
|
||
@BeforeClass | ||
public static void initEnv() throws InterruptedException { | ||
env = new MultiNodeEnv(); | ||
env.startCluster(); | ||
} | ||
|
||
@AfterClass | ||
public static void clearEnv() throws InterruptedException { | ||
env.clearCluster(); | ||
Thread.sleep(2000); | ||
} | ||
|
||
protected String execCurl(String[] cmds) throws IOException { | ||
ProcessBuilder process = new ProcessBuilder(cmds); | ||
p = process.start(); | ||
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); | ||
StringBuilder builder = new StringBuilder(); | ||
String line; | ||
while ((line = reader.readLine()) != null) { | ||
builder.append(line); | ||
builder.append(System.getProperty("line.separator")); | ||
} | ||
p.destroy(); | ||
return builder.toString(); | ||
} | ||
} |
72 changes: 72 additions & 0 deletions
72
...test-test/src/main/java/org/apache/hugegraph/MultiClusterTest/MultiClusterDeployTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.hugegraph.MultiClusterTest; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class MultiClusterDeployTest extends BaseMultiClusterTest { | ||
|
||
@Test | ||
public void testPDNodesDeployment() throws IOException { | ||
List<String> addrs = env.getPDRestAddrs(); | ||
for (String addr : addrs) { | ||
String url = addr; | ||
String[] cmds = {"curl", url}; | ||
StringBuffer sb = new StringBuffer(); | ||
for (int i = 0; i < cmds.length; i++) { | ||
sb.append(cmds[i] + " "); | ||
} | ||
String responseMsg = execCurl(cmds); | ||
Assert.assertEquals(responseMsg, ""); | ||
} | ||
} | ||
|
||
@Test | ||
public void testStoreNodesDeployment() throws IOException, InterruptedException { | ||
List<String> addrs = env.getStoreRestAddrs(); | ||
for (String addr : addrs) { | ||
String url = addr; | ||
String[] cmds = {"curl", url}; | ||
StringBuffer sb = new StringBuffer(); | ||
for (int i = 0; i < cmds.length; i++) { | ||
sb.append(cmds[i] + " "); | ||
} | ||
String responseMsg = execCurl(cmds); | ||
Assert.assertTrue(responseMsg.startsWith("{")); | ||
} | ||
} | ||
|
||
@Test | ||
public void testServerNodesDeployment() throws IOException, InterruptedException { | ||
List<String> addrs = env.getServerRestAddrs(); | ||
for (String addr : addrs) { | ||
String url = addr; | ||
String[] cmds = {"curl", url}; | ||
StringBuffer sb = new StringBuffer(); | ||
for (int i = 0; i < cmds.length; i++) { | ||
sb.append(cmds[i] + " "); | ||
} | ||
String responseMsg = execCurl(cmds); | ||
Assert.assertTrue(responseMsg.startsWith("{")); | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ertest-test/src/main/java/org/apache/hugegraph/MultiClusterTest/MultiClusterFileTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.hugegraph.MultiClusterTest; | ||
|
||
import java.io.File; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
public class MultiClusterFileTest extends BaseMultiClusterTest { | ||
|
||
@Test | ||
public void checkPDNodeDir() { | ||
for (String nodeDir : env.getPDNodeDir()) { | ||
Assert.assertTrue(new File(nodeDir).isDirectory()); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkStoreNodeDir() { | ||
for (String nodeDir : env.getStoreNodeDir()) { | ||
Assert.assertTrue(new File(nodeDir).isDirectory()); | ||
} | ||
} | ||
|
||
@Test | ||
public void checkServerNodeDir() { | ||
for (String nodeDir : env.getServerNodeDir()) { | ||
Assert.assertTrue(new File(nodeDir).isDirectory()); | ||
} | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...rtest-test/src/main/java/org/apache/hugegraph/MultiClusterTest/MultiClusterSuiteTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* 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 | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* 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.hugegraph.MultiClusterTest; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
|
||
@RunWith(Suite.class) | ||
@Suite.SuiteClasses({ | ||
MultiClusterDeployTest.class, | ||
MultiClusterFileTest.class, | ||
}) | ||
@Slf4j | ||
public class MultiClusterSuiteTest { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters