56
56
import java .util .Arrays ;
57
57
import java .util .Collections ;
58
58
import java .util .List ;
59
+ import java .util .Random ;
59
60
import java .util .Vector ;
60
61
import java .util .concurrent .CountDownLatch ;
61
62
import java .util .concurrent .TimeUnit ;
@@ -74,6 +75,8 @@ public class ITTransactionTest {
74
75
@ ClassRule public static IntegrationTestEnv env = new IntegrationTestEnv ();
75
76
private static Database db ;
76
77
private static DatabaseClient client ;
78
+ private static Database largeMessageDb ;
79
+ private static DatabaseClient largeMessageClient ;
77
80
78
81
/** Sequence for assigning unique keys to test cases. */
79
82
private static int seq ;
@@ -88,11 +91,31 @@ public static void setUpDatabase() {
88
91
+ " V INT64,"
89
92
+ ") PRIMARY KEY (K)" );
90
93
client = env .getTestHelper ().getDatabaseClient (db );
94
+
95
+ largeMessageDb =
96
+ env .getTestHelper ()
97
+ .createTestDatabase (
98
+ "CREATE TABLE T ("
99
+ + " K STRING(MAX) NOT NULL,"
100
+ + " col0 BYTES(MAX),"
101
+ + " col1 BYTES(MAX),"
102
+ + " col2 BYTES(MAX),"
103
+ + " col3 BYTES(MAX),"
104
+ + " col4 BYTES(MAX),"
105
+ + " col5 BYTES(MAX),"
106
+ + " col6 BYTES(MAX),"
107
+ + " col7 BYTES(MAX),"
108
+ + " col8 BYTES(MAX),"
109
+ + " col9 BYTES(MAX),"
110
+ + ") PRIMARY KEY (K)" );
111
+ largeMessageClient = env .getTestHelper ().getDatabaseClient (largeMessageDb );
91
112
}
92
113
93
114
@ Before
94
115
public void removeTestData () {
95
116
client .writeAtLeastOnce (Collections .singletonList (Mutation .delete ("T" , KeySet .all ())));
117
+ largeMessageClient .writeAtLeastOnce (
118
+ Collections .singletonList (Mutation .delete ("T" , KeySet .all ())));
96
119
}
97
120
98
121
private static String uniqueKey () {
@@ -561,6 +584,25 @@ public void testTxWithUncaughtError() {
561
584
}
562
585
}
563
586
587
+ @ Test
588
+ public void testTxWithLargeMessageSize () {
589
+ int bytesPerColumn = 10000000 ; // 10MB
590
+ String key = uniqueKey ();
591
+ Random random = new Random ();
592
+ List <Mutation > mutations = new ArrayList ();
593
+ Mutation .WriteBuilder builder = Mutation .newInsertOrUpdateBuilder ("T" ).set ("K" ).to (key );
594
+ for (int j = 0 ; j < 7 ; j ++) {
595
+ byte [] data = new byte [bytesPerColumn ];
596
+ random .nextBytes (data );
597
+ builder
598
+ .set ("col" + j )
599
+ .to (com .google .cloud .spanner .Value .bytes (com .google .cloud .ByteArray .copyFrom (data )));
600
+ }
601
+ mutations .add (builder .build ());
602
+ // This large message is under the 100MB limit.
603
+ largeMessageClient .write (mutations );
604
+ }
605
+
564
606
@ Test
565
607
public void testTxWithUncaughtErrorAfterSuccessfulBegin () {
566
608
try {
0 commit comments