@@ -39,17 +39,33 @@ class IgniteTxTestSuiteFixture
3939public:
4040 IgniteTxTestSuiteFixture ()
4141 {
42- serverNode = ignite_test::StartCrossPlatformServerNode (" cache.xml" , " ServerNode" );
42+ node1 = ignite_test::StartCrossPlatformServerNode (" cache.xml" , " node1" );
43+ node2 = ignite_test::StartCrossPlatformServerNode (" cache.xml" , " node2" );
4344 }
4445
4546 ~IgniteTxTestSuiteFixture ()
4647 {
4748 ignite::Ignition::StopAll (false );
4849 }
4950
51+ /* *
52+ * Start client.
53+ */
54+ static IgniteClient StartClient ()
55+ {
56+ IgniteClientConfiguration cfg;
57+
58+ cfg.SetEndPoints (" 127.0.0.1:11110,127.0.0.1:11111" );
59+
60+ return IgniteClient::Start (cfg);
61+ }
62+
5063private:
51- /* * Server node. */
52- ignite::Ignite serverNode;
64+ /* * Server node #1. */
65+ ignite::Ignite node1;
66+
67+ /* * Server node #2. */
68+ ignite::Ignite node2;
5369};
5470
5571BOOST_FIXTURE_TEST_SUITE (IgniteTxTestSuite, IgniteTxTestSuiteFixture)
@@ -75,11 +91,7 @@ bool checkTxTimeoutMessage(const ignite::IgniteError& ex)
7591
7692BOOST_AUTO_TEST_CASE (TestCacheOpsWithTx)
7793{
78- IgniteClientConfiguration cfg;
79-
80- cfg.SetEndPoints (" 127.0.0.1:11110" );
81-
82- IgniteClient client = IgniteClient::Start (cfg);
94+ IgniteClient client = StartClient ();
8395
8496 cache::CacheClient<int , int > cache =
8597 client.GetCache <int , int >(" partitioned" );
@@ -190,7 +202,7 @@ BOOST_AUTO_TEST_CASE(TestCacheOpsWithTx)
190202
191203 tx.Rollback ();
192204
193- BOOST_CHECK_EQUAL (cache.GetSize (cache::CachePeekMode::ALL ), 1 );
205+ BOOST_CHECK_EQUAL (cache.GetSize (cache::CachePeekMode::PRIMARY ), 1 );
194206
195207 // ---
196208
@@ -241,11 +253,7 @@ BOOST_AUTO_TEST_CASE(TestCacheOpsWithTx)
241253
242254void startAnotherClientAndTx (SharedPointer<SingleLatch>& l)
243255{
244- IgniteClientConfiguration cfg;
245-
246- cfg.SetEndPoints (" 127.0.0.1:11110" );
247-
248- IgniteClient client = IgniteClient::Start (cfg);
256+ IgniteClient client = IgniteTxTestSuiteFixture::StartClient ();
249257
250258 cache::CacheClient<int , int > cache =
251259 client.GetCache <int , int >(" partitioned" );
@@ -263,11 +271,7 @@ void startAnotherClientAndTx(SharedPointer<SingleLatch>& l)
263271
264272BOOST_AUTO_TEST_CASE (TestTxOps)
265273{
266- IgniteClientConfiguration cfg;
267-
268- cfg.SetEndPoints (" 127.0.0.1:11110" );
269-
270- IgniteClient client = IgniteClient::Start (cfg);
274+ IgniteClient client = StartClient ();
271275
272276 cache::CacheClient<int , int > cache =
273277 client.GetCache <int , int >(" partitioned" );
@@ -347,11 +351,7 @@ bool checkTxLabel1Message(const ignite::IgniteError& ex)
347351
348352BOOST_AUTO_TEST_CASE (TestTxWithLabel)
349353{
350- IgniteClientConfiguration cfg;
351-
352- cfg.SetEndPoints (" 127.0.0.1:11110" );
353-
354- IgniteClient client = IgniteClient::Start (cfg);
354+ IgniteClient client = StartClient ();
355355
356356 cache::CacheClient<int , int > cache =
357357 client.GetCache <int , int >(" partitioned" );
@@ -397,4 +397,41 @@ BOOST_AUTO_TEST_CASE(TestTxWithLabel)
397397 tx.Close ();
398398}
399399
400+ BOOST_AUTO_TEST_CASE (ManyTransactions)
401+ {
402+ IgniteClient client = StartClient ();
403+
404+ cache::CacheClient<int , int > cache =
405+ client.GetCache <int , int >(" partitioned" );
406+
407+ transactions::ClientTransactions transactions = client.ClientTransactions ();
408+ const int32_t key = 42 ;
409+
410+ for (int32_t val = 0 ; val < 100 ; ++val) {
411+ transactions::ClientTransaction tx = transactions.TxStart ();
412+
413+ cache.Put (key, val);
414+
415+ tx.Commit ();
416+
417+ BOOST_CHECK_EQUAL (val, cache.Get (key));
418+ }
419+
420+ const int32_t expected = -42 ;
421+
422+ cache.Put (key, expected);
423+
424+ BOOST_CHECK_EQUAL (expected, cache.Get (key));
425+
426+ for (int32_t val = 0 ; val < 100 ; ++val) {
427+ transactions::ClientTransaction tx = transactions.TxStart ();
428+
429+ cache.Put (key, val);
430+
431+ tx.Rollback ();
432+
433+ BOOST_CHECK_EQUAL (expected, cache.Get (key));
434+ }
435+ }
436+
400437BOOST_AUTO_TEST_SUITE_END ()
0 commit comments