zstan commented on a change in pull request #9527:
URL: https://github.com/apache/ignite/pull/9527#discussion_r737355149



##########
File path: 
modules/core/src/test/java/org/apache/ignite/internal/processors/metastorage/DistributedMetaStorageTest.java
##########
@@ -406,84 +417,180 @@ public void testDeactivateActivate() throws Exception {
     public void testOptimizedWriteTwice() throws Exception {
         IgniteEx igniteEx = startGrid(0);
 
-        igniteEx.cluster().active(true);
+        igniteEx.cluster().state(ClusterState.ACTIVE);
 
         metastorage(0).write("key1", "value1");
 
-        assertEquals(1, metastorage(0).getUpdatesCount() - 
initialUpdatesCount);
+        int expUpdatesCnt = 1;
+
+        assertTrue("initialUpdatesCount=" + initialUpdatesCount + ", upd=" + 
metastorage(0).getUpdatesCount(),
+            waitForCondition(() ->
+            (expUpdatesCnt == metastorage(0).getUpdatesCount() - 
initialUpdatesCount), 10_000));
 
         metastorage(0).write("key2", "value2");
 
-        assertEquals(2, metastorage(0).getUpdatesCount() - 
initialUpdatesCount);
+        assertEquals(expUpdatesCnt + 1, metastorage(0).getUpdatesCount() - 
initialUpdatesCount);
 
         metastorage(0).write("key1", "value1");
 
-        assertEquals(2, metastorage(0).getUpdatesCount() - 
initialUpdatesCount);
+        assertEquals(expUpdatesCnt + 1, metastorage(0).getUpdatesCount() - 
initialUpdatesCount);
     }
 
     /** */
     @Test
     public void testClient() throws Exception {
         IgniteEx igniteEx = startGrid(0);
 
-        igniteEx.cluster().active(true);
+        igniteEx.cluster().state(ClusterState.ACTIVE);
 
-        metastorage(0).write("key0", "value0");
+        checkStored(metastorage(0), metastorage(0), "key0", "value0");
 
         startClientGrid(1);
 
         AtomicInteger clientLsnrUpdatesCnt = new AtomicInteger();
 
-        assertEquals(1, metastorage(1).getUpdatesCount() - 
initialUpdatesCount);
+        int expUpdatesCnt = 1;
+
+        assertEquals("initialUpdatesCount=" + initialUpdatesCount + ", upd=" + 
metastorage(1).getUpdatesCount(),
+            expUpdatesCnt, metastorage(1).getUpdatesCount() - 
initialUpdatesCount);
 
         assertEquals("value0", metastorage(1).read("key0"));
 
         metastorage(1).listen(key -> true, (key, oldVal, newVal) -> 
clientLsnrUpdatesCnt.incrementAndGet());
 
-        metastorage(1).write("key1", "value1");
+        checkStored(metastorage(1), metastorage(1), "key1", "value1");
+
+        checkStored(metastorage(1), metastorage(0), "key1", "value1");
 
         assertEquals(1, clientLsnrUpdatesCnt.get());
+    }
 
-        assertEquals("value1", metastorage(1).read("key1"));
+    /** */
+    protected void checkStoredWithPers(
+        DistributedMetaStorage msToStore,
+        IgniteEx instanceToCheck,
+        String key,
+        String value
+    ) throws IgniteCheckedException {
+        assertTrue(isPersistent());
 
-        assertEquals("value1", metastorage(0).read("key1"));
+        final CountDownLatch latch = new CountDownLatch(1);
+
+        final DistributedMetaStorageImpl distrMetaStore =
+            
(DistributedMetaStorageImpl)instanceToCheck.context().distributedMetastorage();
+
+        DmsDataWriterWorker worker = 
GridTestUtils.getFieldValue(distrMetaStore, "worker");
+
+        ReadWriteMetastorage metastorage = GridTestUtils.getFieldValue(worker, 
"metastorage");
+
+        assertNotNull(metastorage);
+
+        IgniteInternalFuture f = GridTestUtils.runAsync(() -> {
+            try {
+                latch.await();
+
+                assertTrue(waitForCondition(() -> {
+                    try {
+                        AtomicBoolean contains = new AtomicBoolean(false);
+                        metastorage.iterate("", (k, v) -> {

Review comment:
       cause in inner implementation it has been appended prefix stuff i don`t 
want to get all these logic here in test.




-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to