-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support lossless config from console & support warmup. (#1446)
Co-authored-by: shedfreewu <[email protected]>
- Loading branch information
1 parent
56ad635
commit 5aaf5b6
Showing
14 changed files
with
270 additions
and
113 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
86 changes: 86 additions & 0 deletions
86
...very/src/test/java/com/tencent/cloud/plugin/lossless/config/WarmupConfigModifierTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making Spring Cloud Tencent available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* Licensed under the BSD 3-Clause License (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://opensource.org/licenses/BSD-3-Clause | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed | ||
* under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
* CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package com.tencent.cloud.plugin.lossless.config; | ||
|
||
import com.tencent.cloud.polaris.context.PolarisSDKContextManager; | ||
import com.tencent.polaris.api.config.consumer.WeightAdjustConfig; | ||
import com.tencent.polaris.plugin.lossless.warmup.WarmupWeightAdjuster; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import org.springframework.boot.autoconfigure.AutoConfigurations; | ||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import org.springframework.boot.test.context.runner.ApplicationContextRunner; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
/** | ||
* Test for {@link WarmupConfigModifier}. | ||
* | ||
* @author Shedfree Wu | ||
*/ | ||
public class WarmupConfigModifierTest { | ||
|
||
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner() | ||
.withConfiguration(AutoConfigurations.of(TestApplication.class)) | ||
.withPropertyValues("spring.cloud.nacos.discovery.enabled=false") | ||
.withPropertyValues("spring.cloud.polaris.enabled=true") | ||
.withPropertyValues("spring.cloud.polaris.warmup.enabled=true") | ||
.withPropertyValues("spring.application.name=test") | ||
.withPropertyValues("spring.cloud.gateway.enabled=false"); | ||
private final ApplicationContextRunner disabledContextRunner = new ApplicationContextRunner() | ||
.withConfiguration(AutoConfigurations.of(TestApplication.class)) | ||
.withPropertyValues("spring.cloud.nacos.discovery.enabled=false") | ||
.withPropertyValues("spring.cloud.polaris.enabled=true") | ||
.withPropertyValues("spring.cloud.polaris.warmup.enabled=false") | ||
.withPropertyValues("spring.application.name=test") | ||
.withPropertyValues("spring.cloud.gateway.enabled=false"); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
PolarisSDKContextManager.innerDestroy(); | ||
} | ||
|
||
@Test | ||
void testModify() { | ||
contextRunner.run(context -> { | ||
PolarisSDKContextManager polarisSDKContextManager = context.getBean(PolarisSDKContextManager.class); | ||
WeightAdjustConfig weightAdjustConfig = polarisSDKContextManager.getSDKContext(). | ||
getConfig().getConsumer().getWeightAdjust(); | ||
assertThat(weightAdjustConfig.isEnable()).isTrue(); | ||
assertThat(weightAdjustConfig.getChain().contains(WarmupWeightAdjuster.WARMUP_WEIGHT_ADJUSTER_NAME)).isTrue(); | ||
}); | ||
} | ||
|
||
|
||
@Test | ||
void testDisabled() { | ||
disabledContextRunner.run(context -> { | ||
PolarisSDKContextManager polarisSDKContextManager = context.getBean(PolarisSDKContextManager.class); | ||
WeightAdjustConfig weightAdjustConfig = polarisSDKContextManager.getSDKContext(). | ||
getConfig().getConsumer().getWeightAdjust(); | ||
assertThat(weightAdjustConfig.isEnable()).isTrue(); | ||
assertThat(weightAdjustConfig.getChain().contains(WarmupWeightAdjuster.WARMUP_WEIGHT_ADJUSTER_NAME)).isFalse(); | ||
}); | ||
} | ||
|
||
@SpringBootApplication | ||
protected static class TestApplication { | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
95 changes: 0 additions & 95 deletions
95
...in/src/main/java/com/tencent/cloud/plugin/lossless/SpringCloudLosslessActionProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.