-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[controller] Log request and response body for aggregated stoppable c…
…heck (#1320) Currently, controller logs audit logs for API requests and responses. These audit logs however, do not log the request body. In the aggregated stoppable checks API endpoint, the request and response are JSON objects. This PR logs these objects to get visibility into them.
- Loading branch information
1 parent
92de3d3
commit 18f0d37
Showing
4 changed files
with
193 additions
and
29 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
52 changes: 52 additions & 0 deletions
52
...mmon/src/test/java/com/linkedin/venice/controllerapi/TestStoppableNodeStatusResponse.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,52 @@ | ||
package com.linkedin.venice.controllerapi; | ||
|
||
import static org.testng.Assert.assertEquals; | ||
import static org.testng.Assert.assertTrue; | ||
|
||
import com.fasterxml.jackson.core.JsonProcessingException; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ArrayNode; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
import com.linkedin.venice.utils.ObjectMapperFactory; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
public class TestStoppableNodeStatusResponse { | ||
private static final ObjectMapper OBJECT_MAPPER = ObjectMapperFactory.getInstance(); | ||
|
||
@Test | ||
public void testJsonSerialization() throws JsonProcessingException { | ||
StoppableNodeStatusResponse response = new StoppableNodeStatusResponse(); | ||
response.setStoppableInstances(Arrays.asList("instance1", "instance2")); | ||
response.setNonStoppableInstancesWithReason(new HashMap<String, String>() { | ||
{ | ||
put("instance3", "reason1"); | ||
put("instance4", "reason2"); | ||
} | ||
}); | ||
|
||
String serializedResponse = OBJECT_MAPPER.writeValueAsString(response); | ||
JsonNode deserializedResponse = OBJECT_MAPPER.readTree(serializedResponse); | ||
|
||
assertTrue(deserializedResponse.get("stoppableInstances") instanceof ArrayNode); | ||
assertEquals(deserializedResponse.get("stoppableInstances").get(0).asText(), "instance1"); | ||
assertEquals(deserializedResponse.get("stoppableInstances").get(1).asText(), "instance2"); | ||
assertTrue(deserializedResponse.get("nonStoppableInstancesWithReasons") instanceof ObjectNode); | ||
assertEquals(deserializedResponse.get("nonStoppableInstancesWithReasons").get("instance3").asText(), "reason1"); | ||
assertEquals(deserializedResponse.get("nonStoppableInstancesWithReasons").get("instance4").asText(), "reason2"); | ||
} | ||
|
||
@Test | ||
public void testJsonSerializationForEmptyContent() throws JsonProcessingException { | ||
StoppableNodeStatusResponse response = new StoppableNodeStatusResponse(); | ||
|
||
String serializedResponse = OBJECT_MAPPER.writeValueAsString(response); | ||
JsonNode deserializedResponse = OBJECT_MAPPER.readTree(serializedResponse); | ||
|
||
assertTrue(deserializedResponse.get("stoppableInstances").isEmpty()); | ||
assertTrue(deserializedResponse.get("nonStoppableInstancesWithReasons").isEmpty()); | ||
} | ||
} |
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