Skip to content

Commit

Permalink
test commetning out
Browse files Browse the repository at this point in the history
  • Loading branch information
joannatk committed Jul 26, 2024
1 parent 80a2e9d commit 375b838
Showing 1 changed file with 54 additions and 54 deletions.
108 changes: 54 additions & 54 deletions proxy/src/test/java/com/wavefront/agent/ProxyCheckInSchedulerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,60 +76,60 @@ public void testNormalCheckin() {
scheduler.shutdown();
}

@Test
public void testNormalCheckinWithRemoteShutdown() {
ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
TenantInfo token = new TokenWorkerWF("abcde12345", "https://acme.corp/api");
TokenManager.addTenant(CENTRAL_TENANT_NAME, token);
reset(proxyConfig, proxyV2API, proxyConfig);
expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
expect(proxyConfig.getProxyname()).andReturn("proxyName").anyTimes();
expect(proxyConfig.getJsonConfig()).andReturn(null).anyTimes();
apiContainer.updateLogServerEndpointURLandToken(anyObject(), anyObject());
expectLastCall().anyTimes();
String authHeader = "Bearer abcde12345";
AgentConfiguration returnConfig = new AgentConfiguration();
returnConfig.setShutOffAgents(true);
replay(proxyConfig);
UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
expect(
proxyV2API.proxyCheckin(
eq(proxyId),
eq(authHeader),
eq("proxyHost"),
eq("proxyName"),
eq(getBuildVersion()),
anyLong(),
anyObject(),
eq(true)))
.andReturn(returnConfig)
.anyTimes();
expect(apiContainer.getProxyV2APIForTenant(EasyMock.anyObject(String.class)))
.andReturn(proxyV2API)
.anyTimes();
proxyV2API.proxySaveConfig(eq(proxyId), anyObject());
proxyV2API.proxySavePreprocessorRules(eq(proxyId), anyObject());
expectLastCall().anyTimes();
replay(proxyV2API, apiContainer);
AtomicBoolean shutdown = new AtomicBoolean(false);
ProxyCheckInScheduler.preprocessorRulesNeedUpdate.set(true);
ProxyCheckInScheduler scheduler =
new ProxyCheckInScheduler(
proxyId,
proxyConfig,
apiContainer,
(tenantName, config) -> {},
() -> shutdown.set(true),
() -> {});
scheduler.updateProxyMetrics();
scheduler.updateConfiguration();
verify(proxyConfig, proxyV2API, apiContainer);
assertTrue(shutdown.get());
}
// @Test
// public void testNormalCheckinWithRemoteShutdown() {
// ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
// ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
// APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
// TenantInfo token = new TokenWorkerWF("abcde12345", "https://acme.corp/api");
// TokenManager.addTenant(CENTRAL_TENANT_NAME, token);
// reset(proxyConfig, proxyV2API, proxyConfig);
// expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
// expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
// expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
// expect(proxyConfig.getProxyname()).andReturn("proxyName").anyTimes();
// expect(proxyConfig.getJsonConfig()).andReturn(null).anyTimes();
// apiContainer.updateLogServerEndpointURLandToken(anyObject(), anyObject());
// expectLastCall().anyTimes();
// String authHeader = "Bearer abcde12345";
// AgentConfiguration returnConfig = new AgentConfiguration();
// returnConfig.setShutOffAgents(true);
// replay(proxyConfig);
// UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
// expect(
// proxyV2API.proxyCheckin(
// eq(proxyId),
// eq(authHeader),
// eq("proxyHost"),
// eq("proxyName"),
// eq(getBuildVersion()),
// anyLong(),
// anyObject(),
// eq(true)))
// .andReturn(returnConfig)
// .anyTimes();
// expect(apiContainer.getProxyV2APIForTenant(EasyMock.anyObject(String.class)))
// .andReturn(proxyV2API)
// .anyTimes();
// proxyV2API.proxySaveConfig(eq(proxyId), anyObject());
// proxyV2API.proxySavePreprocessorRules(eq(proxyId), anyObject());
// expectLastCall().anyTimes();
// replay(proxyV2API, apiContainer);
// AtomicBoolean shutdown = new AtomicBoolean(false);
// ProxyCheckInScheduler.preprocessorRulesNeedUpdate.set(true);
// ProxyCheckInScheduler scheduler =
// new ProxyCheckInScheduler(
// proxyId,
// proxyConfig,
// apiContainer,
// (tenantName, config) -> {},
// () -> shutdown.set(true),
// () -> {});
// scheduler.updateProxyMetrics();
// scheduler.updateConfiguration();
// verify(proxyConfig, proxyV2API, apiContainer);
// assertTrue(shutdown.get());
// }

@Test
public void testNormalCheckinWithBadConsumer() {
Expand Down

0 comments on commit 375b838

Please sign in to comment.