NSAmelchev commented on code in PR #10647:
URL: https://github.com/apache/ignite/pull/10647#discussion_r1168986346


##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/StartImplicitlyTxOnStopCacheTest.java:
##########
@@ -100,4 +126,69 @@ public void test() throws Exception {
 
         assertNull(client.cache(DEFAULT_CACHE_NAME));
     }
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testTxStartAfterGatewayBlockedOnCacheDestroy() throws 
Exception {
+        IgniteEx crd = (IgniteEx)startGridsMultiThreaded(2);
+        GridCacheSharedContext<Object, Object> cctx = 
crd.context().cache().context();
+
+        // Cache group with multiple caches are important here, partition 
topology will not be stopped on cache destroy.
+        crd.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME + "_1")
+            .setGroupName(GROUP)
+            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
+
+        CountDownLatch txStarted = new CountDownLatch(1);
+        CountDownLatch gatewayStopped = new CountDownLatch(1);
+
+        IgniteTxManager tm = Mockito.spy(cctx.tm());
+        setFieldValue(crd.context().cache().context(), "txMgr", tm);
+
+        Mockito.doAnswer(m -> {
+            // Create tx after gateway was stopped (but not blocked).
+            txStarted.countDown();
+            gatewayStopped.await();
+
+            return m.callRealMethod();
+        }).when(tm).onCreated(Mockito.any(), Mockito.any());
+
+        GridCacheGateway gate = 
Mockito.spy(cctx.cache().cache(DEFAULT_CACHE_NAME).context().gate());
+        
setFieldValue(crd.context().cache().context().cache().cache(DEFAULT_CACHE_NAME).context(),
 "gate", gate);

Review Comment:
   Done, thanks.



##########
modules/core/src/test/java/org/apache/ignite/internal/processors/cache/transactions/StartImplicitlyTxOnStopCacheTest.java:
##########
@@ -100,4 +126,69 @@ public void test() throws Exception {
 
         assertNull(client.cache(DEFAULT_CACHE_NAME));
     }
+
+    /** @throws Exception If failed. */
+    @Test
+    public void testTxStartAfterGatewayBlockedOnCacheDestroy() throws 
Exception {
+        IgniteEx crd = (IgniteEx)startGridsMultiThreaded(2);
+        GridCacheSharedContext<Object, Object> cctx = 
crd.context().cache().context();
+
+        // Cache group with multiple caches are important here, partition 
topology will not be stopped on cache destroy.
+        crd.createCache(new CacheConfiguration<>(DEFAULT_CACHE_NAME + "_1")
+            .setGroupName(GROUP)
+            .setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL));
+
+        CountDownLatch txStarted = new CountDownLatch(1);
+        CountDownLatch gatewayStopped = new CountDownLatch(1);
+
+        IgniteTxManager tm = Mockito.spy(cctx.tm());
+        setFieldValue(crd.context().cache().context(), "txMgr", tm);

Review Comment:
   Done, thanks.



-- 
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