Skip to content

Commit

Permalink
fix test cases, update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
Crim committed May 19, 2020
1 parent 850a4c3 commit e3ff968
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 36 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## 2.5.1 (05/19/2020)
- [ISSUE-209](https://github.com/SourceLabOrg/kafka-webview/issues/209) Expose HealthCheck and App Info endpoints without requiring authentication.
- Docker image now exposes port 9090 for Actuator end points.
- [ISSUE-161](https://github.com/SourceLabOrg/kafka-webview/issues/161) Add dedicated 'Apply' and 'Reset' button to Partition and Record Filters.
- [ISSUE-212](https://github.com/SourceLabOrg/kafka-webview/issues/212) Bugfix for partition filters being persisted when toggled on from `Stream` page.

Expand Down
5 changes: 4 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,11 @@ RUN echo "${WEBVIEW_SHA1} /tmp/kafka-webview-ui-bin.zip" | sha1sum -c - && \
# Create volume to persist data
VOLUME ${WEBVIEW_HOME}/data

# Expose port
# Expose WebUI Port
EXPOSE 8080

# Expose Acuator Port for health checks.
EXPOSE 9090

# What to run when the container starts
ENTRYPOINT [ "/app/start.sh" ]
4 changes: 4 additions & 0 deletions kafka-webview-ui/src/assembly/distribution/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ server:
## User login session timeout after 1 hour (3600 seconds)
timeout: 3600

# Spring Actuator Port
management:
server:
port: ${ACTUATOR_PORT:9090}

## Various App Configs
app:
Expand Down
2 changes: 1 addition & 1 deletion kafka-webview-ui/src/main/resources/config/base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ spring:
# Spring Actuator - global
management:
server:
port: 9090
port: ${ACUATOR_PORT:9090}
endpoints:
web:
exposure:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,41 +122,41 @@ public void shouldReceiveAMessageFromTheServer() throws Exception {
final String expectedSessionId = "MYSESSIONID";
final String topicName = "TestTopic" + System.currentTimeMillis();

// Sanity test, no active consumers
Assert.assertEquals("Should have no active consumers", 0, webSocketConsumersManager.countActiveConsumers());

// Create a topic
sharedKafkaTestResource
.getKafkaTestUtils()
.createTopic(topicName, 2, (short) 1);

// Create cluster
final Cluster cluster = clusterTestTools
.createCluster("TestCluster", sharedKafkaTestResource.getKafkaConnectString());

// Create view
final View view = viewTestTools
.createViewWithCluster("TestView", cluster);

// Sanity test, no enforced partitions
assertEquals("Partitions Property should be empty string", "", view.getPartitions());

final ConsumeRequest consumeRequest = new ConsumeRequest();
consumeRequest.setAction("head");
consumeRequest.setPartitions("0,1");
consumeRequest.setFilters(new ArrayList<>());
consumeRequest.setResultsPerPartition(10);

final SimpMessageHeaderAccessor mockHeaderAccessor = mock(SimpMessageHeaderAccessor.class);
final Authentication mockPrincipal = mock(Authentication.class);
when(mockHeaderAccessor.getUser())
.thenReturn(mockPrincipal);
when(mockPrincipal.getPrincipal())
.thenReturn(nonAdminUserDetails);
when(mockHeaderAccessor.getSessionId())
.thenReturn(expectedSessionId);

try {
// Sanity test, no active consumers
Assert.assertEquals("Should have no active consumers", 0, webSocketConsumersManager.countActiveConsumers());

// Create a topic
sharedKafkaTestResource
.getKafkaTestUtils()
.createTopic(topicName, 2, (short) 1);

// Create cluster
final Cluster cluster = clusterTestTools
.createCluster("TestCluster", sharedKafkaTestResource.getKafkaConnectString());

// Create view
final View view = viewTestTools
.createViewWithCluster("TestView", cluster);

// Sanity test, no enforced partitions
assertEquals("Partitions Property should be empty string", "", view.getPartitions());

final ConsumeRequest consumeRequest = new ConsumeRequest();
consumeRequest.setAction("head");
consumeRequest.setPartitions("0,1");
consumeRequest.setFilters(new ArrayList<>());
consumeRequest.setResultsPerPartition(10);

final SimpMessageHeaderAccessor mockHeaderAccessor = mock(SimpMessageHeaderAccessor.class);
final Authentication mockPrincipal = mock(Authentication.class);
when(mockHeaderAccessor.getUser())
.thenReturn(mockPrincipal);
when(mockPrincipal.getPrincipal())
.thenReturn(nonAdminUserDetails);
when(mockHeaderAccessor.getSessionId())
.thenReturn(expectedSessionId);

final String result = streamController.newConsumer(
view.getId(),
consumeRequest,
Expand All @@ -174,6 +174,10 @@ public void shouldReceiveAMessageFromTheServer() throws Exception {
} finally {
// Cleanup, disconnect websocket consumers
webSocketConsumersManager.removeConsumersForSessionId(expectedSessionId);

// Remove created data.
viewTestTools.deleteAllViews();
clusterTestTools.deleteAllClusters();
}
}
}

0 comments on commit e3ff968

Please sign in to comment.