use of com.wavefront.api.ProxyV2API in project java by wavefrontHQ.
the class ProxyCheckInSchedulerTest method testRetryCheckinOnMisconfiguredUrl.
@Test
public void testRetryCheckinOnMisconfiguredUrl() {
ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
reset(proxyConfig, proxyV2API, proxyConfig);
expect(proxyConfig.getServer()).andReturn("https://acme.corp/zzz").anyTimes();
expect(proxyConfig.getToken()).andReturn("abcde12345").anyTimes();
expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
String authHeader = "Bearer abcde12345";
AgentConfiguration returnConfig = new AgentConfiguration();
returnConfig.setPointsPerBatch(1234567L);
replay(proxyConfig);
UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new ClientErrorException(Response.status(404).build())).once();
expect(apiContainer.getProxyV2API()).andReturn(proxyV2API).anyTimes();
apiContainer.updateServerEndpointURL("https://acme.corp/zzz/api/");
expectLastCall().once();
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andReturn(returnConfig).once();
replay(proxyV2API, apiContainer);
ProxyCheckInScheduler scheduler = new ProxyCheckInScheduler(proxyId, proxyConfig, apiContainer, x -> assertEquals(1234567L, x.getPointsPerBatch().longValue()), () -> {
}, () -> {
});
verify(proxyConfig, proxyV2API, apiContainer);
}
use of com.wavefront.api.ProxyV2API in project java by wavefrontHQ.
the class ProxyCheckInSchedulerTest method testRetryCheckinOnMisconfiguredUrlFailsTwiceTerminates.
@Test
public void testRetryCheckinOnMisconfiguredUrlFailsTwiceTerminates() {
ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
reset(proxyConfig, proxyV2API, proxyConfig);
expect(proxyConfig.getServer()).andReturn("https://acme.corp/zzz").anyTimes();
expect(proxyConfig.getToken()).andReturn("abcde12345").anyTimes();
expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
String authHeader = "Bearer abcde12345";
AgentConfiguration returnConfig = new AgentConfiguration();
returnConfig.setPointsPerBatch(1234567L);
replay(proxyConfig);
UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new ClientErrorException(Response.status(404).build())).times(2);
expect(apiContainer.getProxyV2API()).andReturn(proxyV2API).anyTimes();
apiContainer.updateServerEndpointURL("https://acme.corp/zzz/api/");
expectLastCall().once();
replay(proxyV2API, apiContainer);
try {
ProxyCheckInScheduler scheduler = new ProxyCheckInScheduler(proxyId, proxyConfig, apiContainer, x -> fail("We are not supposed to get here"), () -> {
}, () -> {
});
fail();
} catch (RuntimeException e) {
//
}
verify(proxyConfig, proxyV2API, apiContainer);
}
use of com.wavefront.api.ProxyV2API in project java by wavefrontHQ.
the class ProxyCheckInSchedulerTest method testNetworkErrors.
@Test
public void testNetworkErrors() {
ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
reset(proxyConfig, proxyV2API, proxyConfig);
expect(proxyConfig.getServer()).andReturn("https://acme.corp/zzz").anyTimes();
expect(proxyConfig.getToken()).andReturn("abcde12345").anyTimes();
expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
String authHeader = "Bearer abcde12345";
AgentConfiguration returnConfig = new AgentConfiguration();
returnConfig.setPointsPerBatch(1234567L);
replay(proxyConfig);
UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
expect(apiContainer.getProxyV2API()).andReturn(proxyV2API).anyTimes();
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new ProcessingException(new UnknownHostException())).once();
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new ProcessingException(new SocketTimeoutException())).once();
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new ProcessingException(new ConnectException())).once();
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new ProcessingException(new NullPointerException())).once();
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andThrow(new NullPointerException()).once();
replay(proxyV2API, apiContainer);
ProxyCheckInScheduler scheduler = new ProxyCheckInScheduler(proxyId, proxyConfig, apiContainer, x -> fail("We are not supposed to get here"), () -> {
}, () -> {
});
scheduler.updateConfiguration();
scheduler.updateConfiguration();
scheduler.updateConfiguration();
scheduler.updateConfiguration();
verify(proxyConfig, proxyV2API, apiContainer);
}
use of com.wavefront.api.ProxyV2API in project java by wavefrontHQ.
the class ProxyCheckInSchedulerTest method testNormalCheckinWithBadConsumer.
@Test
public void testNormalCheckinWithBadConsumer() {
ProxyConfig proxyConfig = EasyMock.createMock(ProxyConfig.class);
ProxyV2API proxyV2API = EasyMock.createMock(ProxyV2API.class);
APIContainer apiContainer = EasyMock.createMock(APIContainer.class);
reset(proxyConfig, proxyV2API, proxyConfig);
expect(proxyConfig.getServer()).andReturn("https://acme.corp/api/").anyTimes();
expect(proxyConfig.getToken()).andReturn("abcde12345").anyTimes();
expect(proxyConfig.getHostname()).andReturn("proxyHost").anyTimes();
expect(proxyConfig.isEphemeral()).andReturn(true).anyTimes();
expect(proxyConfig.getAgentMetricsPointTags()).andReturn(Collections.emptyMap()).anyTimes();
String authHeader = "Bearer abcde12345";
AgentConfiguration returnConfig = new AgentConfiguration();
replay(proxyConfig);
UUID proxyId = ProxyUtil.getOrCreateProxyId(proxyConfig);
expect(proxyV2API.proxyCheckin(eq(proxyId), eq(authHeader), eq("proxyHost"), eq(getBuildVersion()), anyLong(), anyObject(), eq(true))).andReturn(returnConfig).anyTimes();
expect(apiContainer.getProxyV2API()).andReturn(proxyV2API).anyTimes();
replay(proxyV2API, apiContainer);
try {
ProxyCheckInScheduler scheduler = new ProxyCheckInScheduler(proxyId, proxyConfig, apiContainer, x -> {
throw new NullPointerException("gotcha!");
}, () -> {
}, () -> {
});
scheduler.updateProxyMetrics();
;
scheduler.updateConfiguration();
verify(proxyConfig, proxyV2API, apiContainer);
fail("We're not supposed to get here");
} catch (NullPointerException e) {
// NPE caught, we're good
}
}
Aggregations