You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by "ptupitsyn (via GitHub)" <gi...@apache.org> on 2026/03/10 10:29:16 UTC

[PR] IGNITE-27034 Add client tests for table partition count change [ignite-3]

ptupitsyn opened a new pull request, #7742:
URL: https://github.com/apache/ignite-3/pull/7742

   (no comment)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27034 Add client tests for table partition count change [ignite-3]

Posted by "ptupitsyn (via GitHub)" <gi...@apache.org>.
ptupitsyn merged PR #7742:
URL: https://github.com/apache/ignite-3/pull/7742


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] IGNITE-27034 Add client tests for table partition count change [ignite-3]

Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #7742:
URL: https://github.com/apache/ignite-3/pull/7742#discussion_r2910813375


##########
modules/platforms/dotnet/Apache.Ignite.Tests/Table/TablesPartitionCountTests.cs:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+namespace Apache.Ignite.Tests.Table;
+
+using System.Threading.Tasks;
+using NUnit.Framework;
+
+/// <summary>
+/// Tests for table partition count changes.
+/// </summary>
+public class TablesPartitionCountTests : IgniteTestsBase
+{
+    private const string TestTable = "TEST_TABLE";
+    private const string TestZone = "TEST_PARTITION_ZONE";
+
+    [TearDown]
+    public async Task DropTestZone()
+    {
+        var sql = Client.Sql;
+        await sql.ExecuteAsync(null, $"DROP TABLE IF EXISTS {TestTable}");
+        await sql.ExecuteAsync(null, $"DROP ZONE IF EXISTS {TestZone}");
+    }
+
+    [Test]
+    public async Task TestTablePartitionCountChange()
+    {
+        var sql = Client.Sql;
+
+        // Create zone and table with 5 partitions
+        await sql.ExecuteAsync(null, $"CREATE ZONE {TestZone} (REPLICAS 1, PARTITIONS 5) STORAGE PROFILES ['default']");
+        await sql.ExecuteAsync(null, $"CREATE TABLE {TestTable} (id INT PRIMARY KEY, val VARCHAR) ZONE {TestZone}");
+
+        // Perform operations to ensure client caches partition info
+        var table = await Client.Tables.GetTableAsync(TestTable);
+        var partitions = await table!.PartitionDistribution.GetPartitionsAsync();
+        Assert.AreEqual(5, partitions.Count);
+
+        var view = table.GetKeyValueView<int, string>();
+        var key1 = 1;
+        await view.PutAsync(null, key1, "value1");
+
+        // Drop and recreate with different partition count
+        await sql.ExecuteAsync(null, $"DROP TABLE {TestTable}");
+        await sql.ExecuteAsync(null, $"DROP ZONE {TestZone}");
+        await sql.ExecuteAsync(null, $"CREATE ZONE {TestZone} (REPLICAS 1, PARTITIONS 10) STORAGE PROFILES ['default']");
+        await sql.ExecuteAsync(null, $"CREATE TABLE {TestTable}(id INT PRIMARY KEY, val VARCHAR) ZONE {TestZone}");
+
+        // Old table handle does not work after drop
+        Assert.ThrowsAsync<TableNotFoundException>(async () => await view.GetAsync(null, key1));

Review Comment:
   The result of `Assert.ThrowsAsync` is not awaited. NUnit's `Assert.ThrowsAsync` returns a `Task` that must be awaited to properly observe the assertion; not awaiting it means the assertion may never run and exceptions thrown inside the lambda may go unobserved. Change it to `await Assert.ThrowsAsync<TableNotFoundException>(...)` or use `Assert.That(() => view.GetAsync(null, key1), Throws.TypeOf<TableNotFoundException>())` with the appropriate async overload.
   ```suggestion
           await Assert.ThrowsAsync<TableNotFoundException>(async () => await view.GetAsync(null, key1));
   ```



##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientTablesTest.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.ignite.internal.runner.app.client;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.lang.TableNotFoundException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.Table;
+import org.apache.ignite.table.Tuple;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for thin client table operations.
+ */
+@SuppressWarnings("resource")
+public class ItThinClientTablesTest extends ItAbstractThinClientTest {
+    private static final String TEST_TABLE = "TEST_TABLE";
+    private static final String TEST_ZONE = "TEST_PARTITION_ZONE";
+
+    @AfterEach
+    public void afterEach() {
+        IgniteSql sql = client().sql();
+        sql.execute("DROP TABLE IF EXISTS " + TEST_TABLE);
+        sql.execute("DROP ZONE IF EXISTS " + TEST_ZONE);
+    }
+
+    @Test
+    public void testTablePartitionCountChange() {
+        IgniteClient client = client();
+        IgniteSql sql = client.sql();
+
+        // Create zone and table with 5 partitions
+        sql.execute("CREATE ZONE " + TEST_ZONE + " (REPLICAS 1, PARTITIONS 5) STORAGE PROFILES ['default']");
+        sql.execute("CREATE TABLE " + TEST_TABLE + "(id INT PRIMARY KEY, val VARCHAR) ZONE " + TEST_ZONE);
+
+        // Perform operations to ensure client caches partition info
+        Table table = client.tables().table(TEST_TABLE);
+        assertEquals(5, table.partitionDistribution().partitions().size());
+
+        RecordView<Tuple> view = table.recordView();
+        Tuple key1 = Tuple.create().set("id", 1);
+        view.upsert(null, Tuple.create().set("id", 1).set("val", "value1"));
+
+        Tuple result = view.get(null, key1);
+        assertEquals("value1", result.stringValue("val"));
+
+        // Drop an recreate with different partition count

Review Comment:
   Typo in comment: 'an' should be 'and'.
   ```suggestion
           // Drop and recreate with different partition count
   ```



##########
modules/runner/src/integrationTest/java/org/apache/ignite/internal/runner/app/client/ItThinClientTablesTest.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * 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.ignite.internal.runner.app.client;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+import org.apache.ignite.client.IgniteClient;
+import org.apache.ignite.lang.TableNotFoundException;
+import org.apache.ignite.sql.IgniteSql;
+import org.apache.ignite.table.RecordView;
+import org.apache.ignite.table.Table;
+import org.apache.ignite.table.Tuple;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests for thin client table operations.
+ */
+@SuppressWarnings("resource")
+public class ItThinClientTablesTest extends ItAbstractThinClientTest {
+    private static final String TEST_TABLE = "TEST_TABLE";
+    private static final String TEST_ZONE = "TEST_PARTITION_ZONE";
+
+    @AfterEach
+    public void afterEach() {
+        IgniteSql sql = client().sql();
+        sql.execute("DROP TABLE IF EXISTS " + TEST_TABLE);
+        sql.execute("DROP ZONE IF EXISTS " + TEST_ZONE);
+    }
+
+    @Test
+    public void testTablePartitionCountChange() {
+        IgniteClient client = client();
+        IgniteSql sql = client.sql();
+
+        // Create zone and table with 5 partitions
+        sql.execute("CREATE ZONE " + TEST_ZONE + " (REPLICAS 1, PARTITIONS 5) STORAGE PROFILES ['default']");
+        sql.execute("CREATE TABLE " + TEST_TABLE + "(id INT PRIMARY KEY, val VARCHAR) ZONE " + TEST_ZONE);
+
+        // Perform operations to ensure client caches partition info
+        Table table = client.tables().table(TEST_TABLE);
+        assertEquals(5, table.partitionDistribution().partitions().size());
+
+        RecordView<Tuple> view = table.recordView();
+        Tuple key1 = Tuple.create().set("id", 1);
+        view.upsert(null, Tuple.create().set("id", 1).set("val", "value1"));
+
+        Tuple result = view.get(null, key1);
+        assertEquals("value1", result.stringValue("val"));
+
+        // Drop an recreate with different partition count
+        sql.execute("DROP TABLE " + TEST_TABLE);
+        sql.execute("DROP ZONE " + TEST_ZONE);
+        sql.execute("CREATE ZONE " + TEST_ZONE + " (REPLICAS 1, PARTITIONS 10)  STORAGE PROFILES ['default']");

Review Comment:
   There is an extra space before `STORAGE PROFILES` in this SQL string (double space after `10)`), which is inconsistent with the other `CREATE ZONE` statement on line 54. While this is functionally harmless, it should be cleaned up for consistency.
   ```suggestion
           sql.execute("CREATE ZONE " + TEST_ZONE + " (REPLICAS 1, PARTITIONS 10) STORAGE PROFILES ['default']");
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org