This is an automated email from the ASF dual-hosted git repository.
amashenkov pushed a commit to branch ignite-18171
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/ignite-18171 by this push:
new 0c0d5ae3ab wip. Add todos.
0c0d5ae3ab is described below
commit 0c0d5ae3aba14eb1ca9912c638109504e15636b0
Author: amashenkov <[email protected]>
AuthorDate: Thu Nov 24 18:36:04 2022 +0300
wip. Add todos.
---
.../ignite/internal/ItNodeStartStopTest.java | 141 ++++++++++++++++++---
1 file changed, 124 insertions(+), 17 deletions(-)
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
index a34e3d6523..27c2f4cbb3 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/ItNodeStartStopTest.java
@@ -42,6 +42,7 @@ import
org.apache.ignite.internal.testframework.BaseIgniteAbstractTest;
import org.apache.ignite.internal.testframework.WorkDirectory;
import org.apache.ignite.internal.testframework.WorkDirectoryExtension;
import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assumptions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DynamicContainer;
import org.junit.jupiter.api.DynamicNode;
@@ -58,9 +59,18 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
private static final String connectionAddr = "\"localhost:3344\",
\"localhost:3345\", \"localhost:3346\"";
+ /** Cluster management group node name. */
+ private static final String CMG_NODE = "C";
+ /** MetaStorage group node name. */
+ private static final String METASTORAGE_NODE = "M";
+ /** Data node 1. */
+ private static final String DATA_NODE = "D";
+ /** Data node 2. */
+ private static final String DATA_NODE_2 = "D2";
+
/** Nodes configurations. */
private static final Map<String, String> nodesCfg = Map.of(
- "C", "{\n"
+ CMG_NODE, "{\n"
+ " \"network\": {\n"
+ " \"port\":3344,\n"
+ " \"nodeFinder\":{\n"
@@ -68,7 +78,7 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
+ " }\n"
+ " }\n"
+ "}",
- "M", "{\n"
+ METASTORAGE_NODE, "{\n"
+ " \"network\": {\n"
+ " \"port\":3345,\n"
+ " \"nodeFinder\":{\n"
@@ -76,7 +86,7 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
+ " }\n"
+ " }\n"
+ "}",
- "D", "{\n"
+ DATA_NODE, "{\n"
+ " \"network\": {\n"
+ " \"port\":3346,\n"
+ " \"nodeFinder\":{\n"
@@ -84,7 +94,7 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
+ " }\n"
+ " }\n"
+ "}",
- "D2", "{\n"
+ DATA_NODE_2, "{\n"
+ " \"network\": {\n"
+ " \"port\":3347,\n"
+ " \"nodeFinder\":{\n"
@@ -108,7 +118,10 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
nodesCfg.forEach((k, v) -> futures.add(IgnitionManager.start(k, v,
WORK_DIR.resolve(k))));
//TODO: Fix metastore group
- IgnitionManager.init("C", List.of("C"), List.of("C"), "cluster");
+ IgnitionManager.init(CMG_NODE, List.of(CMG_NODE /* METASTORAGE_NODE
*/), List.of(CMG_NODE), "cluster");
+
+ // TODO: Create distribution zones: spans both nodes, spans a single
node.
+ // TODO: Create tables in these distribution zone + add data.
for (CompletableFuture<Ignite> future : futures) {
assertThat(future, willCompleteSuccessfully());
@@ -130,17 +143,18 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
/** Filter out duplicates and invalid grids. */
private static BiPredicate<String, Set<String>> nodeFilter() {
- return (nodeName, grid) -> (!grid.isEmpty() || "C".equals(nodeName))
// CMG node always starts first.
- && (!"D2".equals(nodeName) || grid.contains("D")); // Data
nodes are interchangeable.
+ return (nodeName, grid) -> (!grid.isEmpty() ||
CMG_NODE.equals(nodeName)) // CMG node always starts first.
+ && (!DATA_NODE_2.equals(nodeName) ||
grid.contains(DATA_NODE)); // Data nodes are interchangeable.
}
/**
- * Test factory for {@link #testStartSequence()} test method.
+ * Test factory for testing node startup order.
*
* @return JUnit tests.
+ * @see #checkNodeStartupSequence() ()
*/
@TestFactory
- public Stream<DynamicNode> startupTestFactory() {
+ public Stream<DynamicNode> gridStartupTestFactory() {
return GridGenerator.generateStartupSequences(
nodesCfg.keySet(),
nodeFilter()
@@ -155,7 +169,7 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
tests.add(createTest(
"Start " + nodeName,
() -> startNode(nodeName),
- this::testStartSequence,
+ this::checkNodeStartupSequence,
() -> {
if (last) {
stopNodes(nodes);
@@ -169,12 +183,13 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
}
/**
- * Test factory for {@link #testNodeRestart()} test method.
+ * Test factory for testing single node restart.
*
* @return JUnit tests.
+ * @see #checkNodeRestart() ()
*/
@TestFactory
- public Stream<DynamicNode> restartTestFactory() {
+ public Stream<DynamicNode> nodeRestartTestFactory() {
return GridGenerator.generateGrids(
nodesCfg.keySet(),
nodeFilter() // Data nodes are interchangeable.
@@ -194,7 +209,7 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
}
stopNode(nodeName);
},
- this::testNodeRestart,
+ this::checkNodeRestart,
() -> {
}
));
@@ -202,7 +217,7 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
tests.add(createTest(
"Start " + nodeName,
() -> startNode(nodeName),
- this::testNodeRestart,
+ this::checkNodeRestart,
() -> {
if (last) {
stopNodes(nodes);
@@ -215,13 +230,105 @@ public class ItNodeStartStopTest extends
BaseIgniteAbstractTest {
});
}
- public void testStartSequence() {
- log.info("Start sequence test: cluster=[" + String.join(", ", new
TreeSet<>(clusterNodes.keySet())) + ']');
+ public void checkNodeStartupSequence() {
+ log.info("Node startup sequence test: cluster=[" + String.join(", ",
new TreeSet<>(clusterNodes.keySet())) + ']');
+
+ validateNodeJoin();
+
+ Assumptions.assumeTrue(clusterNodes.containsKey(CMG_NODE), "CMG must
start first");
+
+ validateDistributionZone();
+ validateDDL();
+ validateROTransaction();
+ validateRWTransaction();
}
- public void testNodeRestart() {
+ public void checkNodeRestart() {
log.info("Node restart test: cluster=[" + String.join(", ", new
TreeSet<>(clusterNodes.keySet())) + ']');
+ validateNodeJoin();
+ validateDistributionZone();
+ validateDDL();
+ validateROTransaction();
+ validateRWTransaction();
+ }
+
+ private void validateNodeJoin() {
+ if (!clusterNodes.containsKey(CMG_NODE)) {
+ //TODO: add node and check it can't join.
+ return;
+ }
+
+ if (!clusterNodes.containsKey(METASTORAGE_NODE)) {
+ //TODO: add node and check it joins, but logical topology is
unchanged.
+ } else {
+ //TODO: add node and check it joins and updates logical topology.
+ }
+ }
+
+ private void validateDistributionZone() {
+ if (!clusterNodes.containsKey(METASTORAGE_NODE)) {
+ //TODO: creating distribution zone fails.
+ return;
+ }
+
+ if (!clusterNodes.containsKey(DATA_NODE) &&
!clusterNodes.containsKey(DATA_NODE_2)) {
+ //TODO: creating distribution zone fails.
+ return;
+ }
+
+ try {
+ if (clusterNodes.containsKey(DATA_NODE) &&
!clusterNodes.containsKey(DATA_NODE_2)) {
+ //TODO: creating distribution zone that spans unavailable node
will fails.
+ //TODO: creating distribution zone that spans on the DATA_NODE
only will success.
+ return;
+ }
+
+ //TODO: creating distribution zone that spans unavailable node
will fails.
+ } finally {
+ //TODO: drop distribution zone.
+ }
+ }
+
+ private void validateDDL() {
+ if (!clusterNodes.containsKey(METASTORAGE_NODE)) {
+ //TODO: create table and check it fails.
+ return;
+ }
+
+ if (!clusterNodes.containsKey(DATA_NODE) &&
!clusterNodes.containsKey(DATA_NODE_2)) {
+ //TODO: create table and check it fails because distribution zone
must have quorum.
+ return;
+ }
+
+ try {
+ if (clusterNodes.containsKey(DATA_NODE) &&
!clusterNodes.containsKey(DATA_NODE_2)) {
+ //TODO: creating table in distribution zone that spans all
data nodes will fails.
+ //TODO: creating table in distribution zone that spans
DATA_NODE only will success.
+ }
+
+ //TODO: creating table will success.
+ } finally {
+ //TODO: drop table.
+ }
+ }
+
+ public void validateROTransaction() {
+ if (!clusterNodes.containsKey(DATA_NODE) &&
!clusterNodes.containsKey(DATA_NODE_2)) {
+ //TODO: table RO transaction will fails.
+ return;
+ }
+
+ //TODO: table RO transaction will success.
+ }
+
+ public void validateRWTransaction() {
+ if (clusterNodes.containsKey(DATA_NODE) &&
clusterNodes.containsKey(DATA_NODE_2)) {
+ //TODO: table RW transaction will success.
+ return;
+ }
+
+ //TODO: table RO transaction will fails.
}
/**