Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
wu-sheng committed Nov 6, 2023
1 parent 679c86d commit ae4256c
Show file tree
Hide file tree
Showing 11 changed files with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

package org.apache.skywalking.oap.server.cluster.plugin.zookeeper;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import lombok.Getter;
import org.apache.curator.x.discovery.ServiceDiscovery;
import org.apache.skywalking.oap.server.core.cluster.ClusterCoordinator;
Expand Down Expand Up @@ -45,10 +48,6 @@
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
Expand All @@ -73,7 +72,7 @@ public class ClusterModuleZookeeperProviderFunctionalIT {
@BeforeEach
public void init() {
Mockito.when(telemetryProvider.getService(MetricsCreator.class))
.thenReturn(new MetricsCreatorNoop());
.thenReturn(new MetricsCreatorNoop());
TelemetryModule telemetryModule = Mockito.spy(TelemetryModule.class);
Whitebox.setInternalState(telemetryModule, "loadedProvider", telemetryProvider);
Mockito.when(moduleManager.find(TelemetryModule.NAME)).thenReturn(telemetryModule);
Expand Down Expand Up @@ -229,7 +228,7 @@ private ClusterModuleZookeeperProvider createProvider(String namespace) throws E
}

private ClusterModuleZookeeperProvider createProvider(String namespace, String internalComHost,
int internalComPort) throws Exception {
int internalComPort) throws Exception {
ClusterModuleZookeeperProvider provider = new ClusterModuleZookeeperProvider();
provider.setManager(moduleManager);
ClusterModuleZookeeperConfig moduleConfig = new ClusterModuleZookeeperConfig();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void setUp() throws Exception {
final ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
loadConfig(applicationConfiguration);

final ModuleManager moduleManager = new ModuleManager();
final ModuleManager moduleManager = new ModuleManager("Test");
moduleManager.init(applicationConfiguration);

provider = (ApolloConfigurationTestProvider) moduleManager.find(ApolloConfigurationTestModule.NAME).provider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void setUp() throws Exception {
final ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
loadConfig(applicationConfiguration);

final ModuleManager moduleManager = new ModuleManager();
final ModuleManager moduleManager = new ModuleManager("Test");
moduleManager.init(applicationConfiguration);

provider = (ConsulConfigurationTestProvider) moduleManager.find(ConsulConfigurationTestModule.NAME).provider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void before() throws Exception {
final ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
loadConfig(applicationConfiguration);

final ModuleManager moduleManager = new ModuleManager();
final ModuleManager moduleManager = new ModuleManager("Test");
moduleManager.init(applicationConfiguration);

provider = (EtcdConfigurationTestProvider) moduleManager.find(EtcdConfigurationTestModule.NAME).provider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public void setUp() throws Exception {
final ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
loadConfig(applicationConfiguration);

final ModuleManager moduleManager = new ModuleManager();
final ModuleManager moduleManager = new ModuleManager("Test");
moduleManager.init(applicationConfiguration);

provider = (NacosConfigurationTestProvider) moduleManager.find(NacosConfigurationTestModule.NAME).provider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public void setUp() throws Exception {
final ApplicationConfiguration applicationConfiguration = new ApplicationConfiguration();
loadConfig(applicationConfiguration);

final ModuleManager moduleManager = new ModuleManager();
final ModuleManager moduleManager = new ModuleManager("Test");
moduleManager.init(applicationConfiguration);

provider = (MockZookeeperConfigurationProvider) moduleManager.find(MockZookeeperConfigurationModule.NAME)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public abstract class MockModuleManager extends ModuleManager {
private final Map<String, ModuleProviderHolder> moduleProviderHolderMap = Maps.newHashMap();

public MockModuleManager() {
super("Test");
init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* And each moduleDefine can have one or more implementation, which depends on `application.yml`
*/
public abstract class ModuleProvider implements ModuleServiceHolder {
@Setter(AccessLevel.PACKAGE)
@Setter
private ModuleManager manager;
@Setter(AccessLevel.PACKAGE)
private ModuleDefine moduleDefine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class OpenTelemetryMetricRequestProcessorTest {

@BeforeEach
public void setUp() {
manager = new ModuleManager();
manager = new ModuleManager("Test");
config = new OtelMetricReceiverConfig();
metricRequestProcessor = new OpenTelemetryMetricRequestProcessor(manager, config);
nodeLabels = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public abstract class MockModuleManager extends ModuleManager {
private final Map<String, ModuleProviderHolder> moduleProviderHolderMap = Maps.newHashMap();

public MockModuleManager() {
super("Test");
init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static void export(String[] args) {
= new TerminalFriendlyTable("The key booting parameters of Apache SkyWalking OAP are listed as following.");

ApplicationConfigLoader configLoader = new ApplicationConfigLoader(bootingParameters);
ModuleManager manager = new ModuleManager();
ModuleManager manager = new ModuleManager("Apache SkyWalking OAP Exporter");
try {
// parse config and init
ExporterConfig exporterConfig = ExporterConfig.parse(args);
Expand Down

0 comments on commit ae4256c

Please sign in to comment.