Skip to content

Commit 03acd84

Browse files
author
Daniil Zulin
committed
Add integration test for topic creation
1 parent 87d01fa commit 03acd84

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

topic/src/test/java/tech/ydb/topic/impl/YdbTopicsIntegrationTest.java

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public class YdbTopicsIntegrationTest {
5353
@ClassRule
5454
public final static GrpcTransportRule ydbTransport = new GrpcTransportRule();
5555

56-
private final static String TEST_TOPIC = "integration_test_topic";
56+
private final static String TEST_TOPIC1 = "integration_test_topic";
57+
private final static String TEST_TOPIC2 = "integration_test_other_topic";
5758
private final static String TEST_CONSUMER1 = "consumer";
5859
private final static String TEST_CONSUMER2 = "other_consumer";
5960

@@ -69,10 +70,10 @@ public class YdbTopicsIntegrationTest {
6970

7071
@BeforeClass
7172
public static void initTopic() {
72-
logger.info("Create test topic {} ...", TEST_TOPIC);
73+
logger.info("Create test topic {} ...", TEST_TOPIC1);
7374

7475
client = TopicClient.newClient(ydbTransport).build();
75-
client.createTopic(TEST_TOPIC, CreateTopicSettings.newBuilder()
76+
client.createTopic(TEST_TOPIC1, CreateTopicSettings.newBuilder()
7677
.addConsumer(Consumer.newBuilder().setName(TEST_CONSUMER1).build())
7778
.addConsumer(Consumer.newBuilder().setName(TEST_CONSUMER2).build())
7879
.build()
@@ -81,16 +82,16 @@ public static void initTopic() {
8182

8283
@AfterClass
8384
public static void dropTopic() {
84-
logger.info("Drop test topic {} ...", TEST_TOPIC);
85-
Status dropStatus = client.dropTopic(TEST_TOPIC).join();
85+
logger.info("Drop test topic {} ...", TEST_TOPIC1);
86+
Status dropStatus = client.dropTopic(TEST_TOPIC1).join();
8687
client.close();
8788
dropStatus.expectSuccess("can't drop test topic");
8889
}
8990

9091
@Test
9192
public void step01_writeWithoutDeduplication() throws InterruptedException, ExecutionException, TimeoutException {
9293
WriterSettings settings = WriterSettings.newBuilder()
93-
.setTopicPath(TEST_TOPIC)
94+
.setTopicPath(TEST_TOPIC1)
9495
.build();
9596
SyncWriter writer = client.createSyncWriter(settings);
9697
writer.init();
@@ -110,7 +111,7 @@ public void step01_writeWithoutDeduplication() throws InterruptedException, Exec
110111
@Test
111112
public void step02_readHalfWithoutCommit() throws InterruptedException {
112113
ReaderSettings settings = ReaderSettings.newBuilder()
113-
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC).build())
114+
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC1).build())
114115
.setConsumerName(TEST_CONSUMER1)
115116
.build();
116117

@@ -128,7 +129,7 @@ public void step02_readHalfWithoutCommit() throws InterruptedException {
128129
@Test
129130
public void step03_readHalfWithCommit() throws InterruptedException {
130131
ReaderSettings settings = ReaderSettings.newBuilder()
131-
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC).build())
132+
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC1).build())
132133
.setConsumerName(TEST_CONSUMER1)
133134
.build();
134135

@@ -147,7 +148,7 @@ public void step03_readHalfWithCommit() throws InterruptedException {
147148
@Test
148149
public void step03_readNextHalfWithoutCommit() throws InterruptedException {
149150
ReaderSettings settings = ReaderSettings.newBuilder()
150-
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC).build())
151+
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC1).build())
151152
.setConsumerName(TEST_CONSUMER1)
152153
.build();
153154

@@ -169,7 +170,7 @@ public void step03_readNextHalfWithoutCommit() throws InterruptedException {
169170
@Test
170171
public void step04_readNextHalfWithCommit() throws InterruptedException {
171172
ReaderSettings settings = ReaderSettings.newBuilder()
172-
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC).build())
173+
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC1).build())
173174
.setConsumerName(TEST_CONSUMER1)
174175
.build();
175176

@@ -193,7 +194,7 @@ public void step04_readNextHalfWithCommit() throws InterruptedException {
193194

194195
@Test
195196
public void step05_describeTopic() {
196-
TopicDescription description = client.describeTopic(TEST_TOPIC).join().getValue();
197+
TopicDescription description = client.describeTopic(TEST_TOPIC1).join().getValue();
197198

198199
Assert.assertNull(description.getTopicStats());
199200
List<Consumer> consumers = description.getConsumers();
@@ -206,7 +207,7 @@ public void step05_describeTopic() {
206207
@Test
207208
public void step06_readAllByAsyncReader() throws InterruptedException {
208209
ReaderSettings settings = ReaderSettings.newBuilder()
209-
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC).build())
210+
.addTopic(TopicReadSettings.newBuilder().setPath(TEST_TOPIC1).build())
210211
.setConsumerName(TEST_CONSUMER2)
211212
.build();
212213

@@ -245,7 +246,7 @@ public void onMessages(DataReceivedEvent dre) {
245246

246247
@Test
247248
public void step07_alterTopicWithAutoPartitioning() {
248-
client.alterTopic(TEST_TOPIC, AlterTopicSettings.newBuilder()
249+
client.alterTopic(TEST_TOPIC1, AlterTopicSettings.newBuilder()
249250
.setAlterPartitioningSettings(AlterPartitioningSettings.newBuilder()
250251
.setAutoPartitioningStrategy(AutoPartitioningStrategy.SCALE_UP)
251252
.setMaxActivePartitions(10)
@@ -257,7 +258,7 @@ public void step07_alterTopicWithAutoPartitioning() {
257258
.build())
258259
.build()).join().expectSuccess("can't alter the topic");
259260

260-
TopicDescription description = client.describeTopic(TEST_TOPIC).join().getValue();
261+
TopicDescription description = client.describeTopic(TEST_TOPIC1).join().getValue();
261262

262263
PartitioningSettings actualPartitioningSettings = description.getPartitioningSettings();
263264
PartitioningSettings expectedPartitioningSettings = PartitioningSettings.newBuilder()
@@ -273,4 +274,28 @@ public void step07_alterTopicWithAutoPartitioning() {
273274

274275
Assert.assertEquals(expectedPartitioningSettings, actualPartitioningSettings);
275276
}
277+
278+
@Test
279+
public void step08_createTopicWithAutoPartitioning() {
280+
PartitioningSettings expectedPartitioningSettings = PartitioningSettings.newBuilder()
281+
.setMaxActivePartitions(8)
282+
.setMinActivePartitions(4)
283+
.setAutoPartitioningStrategy(AutoPartitioningStrategy.SCALE_UP)
284+
.setWriteStrategySettings(AutoPartitioningWriteStrategySettings.newBuilder()
285+
.setDownUtilizationPercent(5)
286+
.setUpUtilizationPercent(75)
287+
.setStabilizationWindow(Duration.ofMinutes(2))
288+
.build())
289+
.build();
290+
291+
CompletableFuture<Status> secondaryTopicCreated = client.createTopic(TEST_TOPIC2, CreateTopicSettings.newBuilder()
292+
.setPartitioningSettings(expectedPartitioningSettings)
293+
.build());
294+
295+
secondaryTopicCreated.join().expectSuccess("can't create the topic");
296+
297+
TopicDescription description = client.describeTopic(TEST_TOPIC2).join().getValue();
298+
299+
Assert.assertEquals(expectedPartitioningSettings, description.getPartitioningSettings());
300+
}
276301
}

0 commit comments

Comments
 (0)