mirror of
https://github.com/signalapp/Signal-Server
synced 2026-04-21 13:38:04 +01:00
Revert "Count API calls by authentication status"
This reverts commit 9b835633ab.
This commit is contained in:
@@ -9,7 +9,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.mockito.ArgumentMatchers.anyIterable;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
@@ -89,12 +89,6 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
private static final DropwizardAppExtension<Configuration> EXTENSION = new DropwizardAppExtension<>(
|
||||
MetricsHttpChannelListenerIntegrationTest.TestApplication.class);
|
||||
|
||||
@BeforeEach
|
||||
void setUpBefore() {
|
||||
when(METER_REGISTRY.counter(anyString(), anyIterable())).thenReturn(mock(Counter.class));
|
||||
when(METER_REGISTRY.counter(eq(MetricsHttpChannelListener.REQUEST_COUNTER_NAME), anyIterable())).thenReturn(COUNTER);
|
||||
}
|
||||
|
||||
@AfterEach
|
||||
void teardown() {
|
||||
reset(METER_REGISTRY);
|
||||
@@ -110,7 +104,14 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
COUNT_DOWN_LATCH_FUTURE_REFERENCE.set(countDownLatch);
|
||||
|
||||
final Client client = EXTENSION.client();
|
||||
final ArgumentCaptor<Iterable<Tag>> tagCaptor = ArgumentCaptor.forClass(Iterable.class);
|
||||
when(METER_REGISTRY.counter(anyString(), any(Iterable.class)))
|
||||
.thenAnswer(a -> MetricsHttpChannelListener.REQUEST_COUNTER_NAME.equals(a.getArgument(0, String.class))
|
||||
? COUNTER
|
||||
: mock(Counter.class))
|
||||
.thenReturn(COUNTER);
|
||||
|
||||
Client client = EXTENSION.client();
|
||||
|
||||
final Supplier<String> request = () -> client.target(
|
||||
String.format("http://localhost:%d%s", EXTENSION.getLocalPort(), requestPath))
|
||||
@@ -139,7 +140,6 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
|
||||
assertTrue(countDownLatch.await(1000, TimeUnit.MILLISECONDS));
|
||||
|
||||
@SuppressWarnings("unchecked") final ArgumentCaptor<Iterable<Tag>> tagCaptor = ArgumentCaptor.forClass(Iterable.class);
|
||||
verify(METER_REGISTRY).counter(eq(MetricsHttpChannelListener.REQUEST_COUNTER_NAME), tagCaptor.capture());
|
||||
verify(COUNTER).increment();
|
||||
|
||||
@@ -185,6 +185,13 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
final CountDownLatch countDownLatch = new CountDownLatch(1);
|
||||
COUNT_DOWN_LATCH_FUTURE_REFERENCE.set(countDownLatch);
|
||||
|
||||
final ArgumentCaptor<Iterable<Tag>> tagCaptor = ArgumentCaptor.forClass(Iterable.class);
|
||||
when(METER_REGISTRY.counter(anyString(), any(Iterable.class)))
|
||||
.thenAnswer(a -> MetricsHttpChannelListener.REQUEST_COUNTER_NAME.equals(a.getArgument(0, String.class))
|
||||
? COUNTER
|
||||
: mock(Counter.class))
|
||||
.thenReturn(COUNTER);
|
||||
|
||||
client.connect(new WebSocketListener() {
|
||||
@Override
|
||||
public void onWebSocketConnect(final Session session) {
|
||||
@@ -195,7 +202,6 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
|
||||
assertTrue(countDownLatch.await(1000, TimeUnit.MILLISECONDS));
|
||||
|
||||
@SuppressWarnings("unchecked") final ArgumentCaptor<Iterable<Tag>> tagCaptor = ArgumentCaptor.forClass(Iterable.class);
|
||||
verify(METER_REGISTRY).counter(eq(MetricsHttpChannelListener.REQUEST_COUNTER_NAME), tagCaptor.capture());
|
||||
verify(COUNTER).increment();
|
||||
|
||||
@@ -300,7 +306,7 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
@Override
|
||||
public void beanAdded(final Container parent, final Object child) {
|
||||
if (child instanceof Connector connector) {
|
||||
connector.addBean(this);
|
||||
connector.addBean(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -325,7 +331,7 @@ class MetricsHttpChannelListenerIntegrationTest {
|
||||
|
||||
@GET
|
||||
@Path("/greet/{name}")
|
||||
public String testGreetByName(@PathParam("name") String name, @Context ContainerRequestContext ignored) {
|
||||
public String testGreetByName(@PathParam("name") String name, @Context ContainerRequestContext context) {
|
||||
|
||||
if ("exception".equals(name)) {
|
||||
throw new InternalServerErrorException();
|
||||
|
||||
@@ -8,7 +8,6 @@ package org.whispersystems.textsecuregcm.metrics;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyIterable;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -49,15 +48,12 @@ class MetricsHttpChannelListenerTest {
|
||||
requestCounter = mock(Counter.class);
|
||||
requestsByVersionCounter = mock(Counter.class);
|
||||
|
||||
when(meterRegistry.counter(eq(MetricsHttpChannelListener.REQUEST_COUNTER_NAME), anyIterable()))
|
||||
when(meterRegistry.counter(eq(MetricsHttpChannelListener.REQUEST_COUNTER_NAME), any(Iterable.class)))
|
||||
.thenReturn(requestCounter);
|
||||
|
||||
when(meterRegistry.counter(eq(MetricsHttpChannelListener.REQUESTS_BY_VERSION_COUNTER_NAME), anyIterable()))
|
||||
when(meterRegistry.counter(eq(MetricsHttpChannelListener.REQUESTS_BY_VERSION_COUNTER_NAME), any(Iterable.class)))
|
||||
.thenReturn(requestsByVersionCounter);
|
||||
|
||||
when(meterRegistry.counter(eq(MetricsHttpChannelListener.REQUESTS_BY_AUTHENTICATION_COUNTER_NAME), anyIterable()))
|
||||
.thenReturn(mock(Counter.class));
|
||||
|
||||
clientReleaseManager = mock(ClientReleaseManager.class);
|
||||
|
||||
listener = new MetricsHttpChannelListener(meterRegistry, clientReleaseManager, Collections.emptySet());
|
||||
@@ -138,8 +134,8 @@ class MetricsHttpChannelListenerTest {
|
||||
final ArgumentCaptor<Iterable<Tag>> tagCaptor = ArgumentCaptor.forClass(Iterable.class);
|
||||
verify(meterRegistry).counter(eq(MetricsHttpChannelListener.REQUESTS_BY_VERSION_COUNTER_NAME),
|
||||
tagCaptor.capture());
|
||||
|
||||
final Set<Tag> tags = new HashSet<>();
|
||||
tags.clear();
|
||||
for (final Tag tag : tagCaptor.getValue()) {
|
||||
tags.add(tag);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.anyIterable;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -73,8 +71,6 @@ class MetricsRequestEventListenerTest {
|
||||
meterRegistry = mock(MeterRegistry.class);
|
||||
counter = mock(Counter.class);
|
||||
|
||||
when(meterRegistry.counter(anyString(), anyIterable())).thenReturn(mock(Counter.class));
|
||||
|
||||
final ClientReleaseManager clientReleaseManager = mock(ClientReleaseManager.class);
|
||||
when(clientReleaseManager.isVersionActive(any(), any())).thenReturn(false);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user