|
17 | 17 |
|
18 | 18 | package org.apache.doris.cloud.alter; |
19 | 19 |
|
| 20 | +import org.apache.doris.catalog.BinlogConfig; |
20 | 21 | import org.apache.doris.catalog.Database; |
21 | 22 | import org.apache.doris.catalog.Env; |
22 | 23 | import org.apache.doris.catalog.KeysType; |
@@ -155,6 +156,44 @@ public void testUpdateTablePropertiesNotifiesAllAliveBackendsInBatches() throws |
155 | 156 | Assertions.assertEquals(Arrays.asList(103L), syncRequests.get(3).getTabletIdsList()); |
156 | 157 | } |
157 | 158 |
|
| 159 | + @Test |
| 160 | + public void testUpdateBinlogConfigUsesCloudTabletMeta() throws Exception { |
| 161 | + CloudSchemaChangeHandler handler = new CloudSchemaChangeHandler(); |
| 162 | + Database db = createMockDatabaseWithThreeTablets(); |
| 163 | + BinlogConfig binlogConfig = new BinlogConfig(true, 3600L, 4096L, 7L, |
| 164 | + BinlogConfig.BinlogFormat.ROW, true); |
| 165 | + |
| 166 | + MetaServiceProxy metaServiceProxy = Mockito.mock(MetaServiceProxy.class); |
| 167 | + Mockito.when(metaServiceProxy.updateTablet(Mockito.any())).thenReturn(okUpdateTabletResponse()); |
| 168 | + Config.enable_debug_points = true; |
| 169 | + DebugPointUtil.addDebugPoint("CloudSchemaChangeHandler.notifyBackendsToSyncTabletMeta.skip"); |
| 170 | + |
| 171 | + try (MockedStatic<MetaServiceProxy> metaProxyMock = Mockito.mockStatic(MetaServiceProxy.class)) { |
| 172 | + metaProxyMock.when(MetaServiceProxy::getInstance).thenReturn(metaServiceProxy); |
| 173 | + handler.updatePartitionProperties(db, "tbl", "p1", -1, -1, binlogConfig, |
| 174 | + null, null, -1, -1, -1); |
| 175 | + } |
| 176 | + |
| 177 | + ArgumentCaptor<Cloud.UpdateTabletRequest> updateCaptor = |
| 178 | + ArgumentCaptor.forClass(Cloud.UpdateTabletRequest.class); |
| 179 | + Mockito.verify(metaServiceProxy, Mockito.times(2)).updateTablet(updateCaptor.capture()); |
| 180 | + List<Cloud.TabletMetaInfoPB> tabletMetaInfos = updateCaptor.getAllValues().stream() |
| 181 | + .flatMap(request -> request.getTabletMetaInfosList().stream()) |
| 182 | + .collect(Collectors.toList()); |
| 183 | + Assertions.assertEquals(Arrays.asList(101L, 102L, 103L), tabletMetaInfos.stream() |
| 184 | + .map(Cloud.TabletMetaInfoPB::getTabletId).collect(Collectors.toList())); |
| 185 | + for (Cloud.TabletMetaInfoPB tabletMetaInfo : tabletMetaInfos) { |
| 186 | + Assertions.assertTrue(tabletMetaInfo.hasBinlogConfig()); |
| 187 | + Assertions.assertTrue(tabletMetaInfo.getBinlogConfig().getEnable()); |
| 188 | + Assertions.assertEquals(3600L, tabletMetaInfo.getBinlogConfig().getTtlSeconds()); |
| 189 | + Assertions.assertEquals(4096L, tabletMetaInfo.getBinlogConfig().getMaxBytes()); |
| 190 | + Assertions.assertEquals(7L, tabletMetaInfo.getBinlogConfig().getMaxHistoryNums()); |
| 191 | + Assertions.assertEquals(org.apache.doris.proto.OlapFile.BinlogFormatPB.ROW, |
| 192 | + tabletMetaInfo.getBinlogConfig().getBinlogFormat()); |
| 193 | + Assertions.assertTrue(tabletMetaInfo.getBinlogConfig().getNeedHistoricalValue()); |
| 194 | + } |
| 195 | + } |
| 196 | + |
158 | 197 | @Test |
159 | 198 | public void testUpdateCompactionPolicyExcludesRowBinlogTablets() throws Exception { |
160 | 199 | CloudSchemaChangeHandler handler = new CloudSchemaChangeHandler(); |
|
0 commit comments