This is an automated email from the ASF dual-hosted git repository.
sk0x50 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 226c23e0a4 IGNITE-19627 Fixed ItReadOnlyTransactionTest (#2133)
226c23e0a4 is described below
commit 226c23e0a4b3d38de907ffc268a96ae4c28374c4
Author: Mirza Aliev <[email protected]>
AuthorDate: Thu Jun 1 20:06:54 2023 +0400
IGNITE-19627 Fixed ItReadOnlyTransactionTest (#2133)
---
.../internal/table/ItReadOnlyTransactionTest.java | 75 ++++++++++------------
1 file changed, 34 insertions(+), 41 deletions(-)
diff --git
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
index ccd2c9a99a..ad95f44e20 100644
---
a/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
+++
b/modules/runner/src/integrationTest/java/org/apache/ignite/internal/table/ItReadOnlyTransactionTest.java
@@ -41,7 +41,8 @@ import
org.apache.ignite.internal.sql.engine.ClusterPerClassIntegrationTest;
import org.apache.ignite.lang.IgniteStringFormatter;
import org.apache.ignite.network.ClusterNode;
import org.apache.ignite.tx.Transaction;
-import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
/**
@@ -49,18 +50,19 @@ import org.junit.jupiter.api.Test;
*/
public class ItReadOnlyTransactionTest extends ClusterPerClassIntegrationTest {
/** Table name. */
- public static final String TABLE_NAME = "tbl";
- /** Gap in future to request a data. */
- public static final int FUTURE_GAP = 200;
+ private static final String TABLE_NAME = "tbl";
+
+ private static final String ZONE_NAME = "ZONE_" + TABLE_NAME.toUpperCase();
- @BeforeAll
- public void beforeTestStart() {
- String zoneName = "ZONE_" + TABLE_NAME.toUpperCase();
+ /** Gap in future to request a data. */
+ private static final int FUTURE_GAP = 700;
+ @BeforeEach
+ public void beforeEach() {
sql(IgniteStringFormatter.format("CREATE ZONE IF NOT EXISTS {} WITH
REPLICAS={}, PARTITIONS={};",
- zoneName, nodes(), 10));
+ ZONE_NAME, nodes(), 10));
sql(IgniteStringFormatter.format("CREATE TABLE {}(id INT PRIMARY KEY,
val VARCHAR) WITH PRIMARY_ZONE='{}'",
- TABLE_NAME, zoneName));
+ TABLE_NAME, ZONE_NAME));
Ignite ignite = CLUSTER_NODES.get(0);
@@ -75,23 +77,11 @@ public class ItReadOnlyTransactionTest extends
ClusterPerClassIntegrationTest {
assertEquals(100, checkData(null, id -> "str " + id));
}
- /**
- * Check rows in the table {@link ItReadOnlyTransactionTest#TABLE_NAME}.
- *
- * @param tx Transaction. The parameter might be {@code null} for implicit
transaction.
- * @param valueMapper Function to map a primary key to a column.
- * @return Count of rows in the table.
- */
- private static int checkData(Transaction tx, Function<Integer, String>
valueMapper) {
- List<List<Object>> rows = sql(tx, "SELECT id, val FROM " + TABLE_NAME
+ " ORDER BY id");
-
- for (List<Object> row : rows) {
- var id = (Integer) row.get(0);
+ @AfterEach
+ public void afterEach() {
+ sql(IgniteStringFormatter.format("DROP TABLE {}", TABLE_NAME));
- assertEquals(valueMapper.apply(id), row.get(1));
- }
-
- return rows.size();
+ sql(IgniteStringFormatter.format("DROP ZONE {}", ZONE_NAME));
}
@Test
@@ -139,14 +129,6 @@ public class ItReadOnlyTransactionTest extends
ClusterPerClassIntegrationTest {
}
assertEquals(100 + nodes(), checkData(null, id -> id < 100 ? ("str " +
id) : ("new str " + id)));
-
- Ignite ignite = CLUSTER_NODES.get(0);
-
- ignite.transactions().runInTransaction(tx -> {
- for (int i = 100; i < 100 + nodes(); i++) {
- sql(tx, "DELETE FROM " + TABLE_NAME + " WHERE id = ?", i);
- }
- });
}
@Test
@@ -188,14 +170,6 @@ public class ItReadOnlyTransactionTest extends
ClusterPerClassIntegrationTest {
}
assertEquals(100 - nodes(), checkData(null, id -> "str " + id));
-
- Ignite ignite = CLUSTER_NODES.get(0);
-
- ignite.transactions().runInTransaction(tx -> {
- for (int i = 0; i < nodes(); i++) {
- sql(tx, "INSERT INTO " + TABLE_NAME + " VALUES (?, ?)", i,
"str " + i);
- }
- });
}
private static Row createRow(SchemaDescriptor schema, int id) {
@@ -214,4 +188,23 @@ public class ItReadOnlyTransactionTest extends
ClusterPerClassIntegrationTest {
return new Row(schema, rowBuilder.build());
}
+
+ /**
+ * Check rows in the table {@link ItReadOnlyTransactionTest#TABLE_NAME}.
+ *
+ * @param tx Transaction. The parameter might be {@code null} for implicit
transaction.
+ * @param valueMapper Function to map a primary key to a column.
+ * @return Count of rows in the table.
+ */
+ private static int checkData(Transaction tx, Function<Integer, String>
valueMapper) {
+ List<List<Object>> rows = sql(tx, "SELECT id, val FROM " + TABLE_NAME
+ " ORDER BY id");
+
+ for (List<Object> row : rows) {
+ var id = (Integer) row.get(0);
+
+ assertEquals(valueMapper.apply(id), row.get(1));
+ }
+
+ return rows.size();
+ }
}