Skip to content

Commit

Permalink
Updates to UI and bug fixes
Browse files Browse the repository at this point in the history
- Display overall cluster health
- Identify missing broker nodes
- Show broker partition assignments
- Convert to Bootstrap 3
- Start of integration test suite
  • Loading branch information
dhayha committed Feb 7, 2018
2 parents 7fb5884 + 90695e9 commit 06b42d5
Show file tree
Hide file tree
Showing 30 changed files with 1,267 additions and 130 deletions.
223 changes: 204 additions & 19 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@

<groupId>com.homeadvisor.kafka</groupId>
<artifactId>kafdrop</artifactId>
<version>2.0.0</version>
<version>2.0.6</version>

<description>For when you have a Kaf(ka) cluster to monitor</description>

<properties>
<spring.boot.version>1.3.6.RELEASE</spring.boot.version>
<additionalparam>-Xdoclint:none</additionalparam>
<curator.version>2.10.0</curator.version>

<!-- name of parameter changed in latest mvn javadoc plugin version-->
<additionalOptions>-Xdoclint:none</additionalOptions>

</properties>

<scm>
Expand Down Expand Up @@ -108,7 +112,7 @@
<artifactId>spring-beans</artifactId>
</dependency>

<!-- Swagger API docs -->
<!-- Swagger API docs -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
Expand All @@ -129,6 +133,32 @@
<scope>test</scope>
</dependency>

<!-- Test dependencies -->
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-core</artifactId>
<version>1.0-groovy-2.4</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy.modules.http-builder</groupId>
<artifactId>http-builder</artifactId>
<version>0.7.1</version>
<scope>test</scope>
</dependency>
<!-- Right now only needed by integration tests -->
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.8.2.2</version>
<scope>test</scope>
</dependency>
</dependencies>


Expand Down Expand Up @@ -222,9 +252,6 @@
</goals>
</execution>
</executions>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
</plugins>
<resources>
Expand All @@ -245,20 +272,178 @@
</resources>
</build>

<distributionManagement>
<!-- use the following if you're not using a snapshot version. -->
<repository>
<id>repos</id>
<name>SM Release</name>
<url>http://192.168.9.1:8081/nexus/content/repositories/releases</url>
</repository>
<!-- use the following if you ARE using a snapshot version. -->
<snapshotRepository>
<id>repos</id>
<name>SM Snapshots</name>
<url>http://192.168.9.1:8081/nexus/content/repositories/sm-snap</url>
</snapshotRepository>
</distributionManagement>
<profiles>
<profile>
<id>api-test</id>
<properties>
<test.base.dir>api-test</test.base.dir>
<test.output.dir>api-test-classes</test.output.dir>
<api.test.report.dir>${project.build.directory}/api-surefire-reports</api.test.report.dir>
</properties>
<dependencies>
</dependencies>
<build>
<plugins>

<!-- Create a new goal that starts ZK, Kakfa, and Kafdrop for integration tests -->
<!-- Credit: https://github.com/charithe/kafka-maven-plugin -->

<!-- Start a ZK and Kafka cluster -->
<plugin>
<groupId>com.github.charithe</groupId>
<artifactId>kafka-maven-plugin</artifactId>
<version>1.0.0</version>
<configuration>
<zookeeperPort>2180</zookeeperPort>
<kafkaPort>9092</kafkaPort>
</configuration>

<!-- Override Kafka and ZK versions to match Kafdrop -->
<dependencies>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.8</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.9.2</artifactId>
<version>0.8.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>0.8.2.2</version>
</dependency>
</dependencies>

<!-- Start/stop ZK and Kafka with pre and post integration phases-->
<executions>
<execution>
<id>zk-kafka-pre-integration</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-kafka-broker</goal>
</goals>
</execution>
<execution>
<id>zk-kafka-post-integration</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-kafka-broker</goal>
</goals>
</execution>
</executions>
</plugin>

<!-- Spring Boot build/start -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring.boot.version}</version>

<configuration>
<mainClass>${start-class}</mainClass>
<!-- Don't want to fork Kafdrop or it prevents the subsequent steps -->
<!-- Careful using JVM args or it forces a fork -->
<fork>false</fork>
<arguments>
<argument>--server.port:11017</argument>
<argument>--zookeeper.connect=localhost:2180</argument>
</arguments>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
<execution>
<id>kafdrop-pre-integration</id>
<phase>integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>kafdrop-post-integration</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<testSourceDirectory>${project.basedir}/src/api-test/java</testSourceDirectory>
<includes>
<include>**/*Spec.java</include>
</includes>
<reportsDirectory>${api.test.report.dir}</reportsDirectory>
<argLine>${test.arguments}</argLine>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.18</version>
<configuration>
<outputDirectory>${project.build.directory}/api-test-report</outputDirectory>
<reportsDirectory>${api.report.dir}</reportsDirectory>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmavenplus</groupId>
<artifactId>gmavenplus-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<testSources>
<testSource>
<directory>${project.basedir}/src/${test.base.dir}/groovy</directory>
<includes>
<include>**/*.groovy</include>
</includes>
</testSource>
</testSources>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
32 changes: 32 additions & 0 deletions src/api-test/groovy/com/homeadvisor/kafdrop/KafdropApiSpec.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import spock.lang.Shared
import spock.lang.Specification

import groovyx.net.http.RESTClient

/**
* Spock test that exercises Kafdrop APIs.
*/
class KafdropApiSpec extends Specification
{
@Shared RESTClient restClient = new RESTClient()

def "Cluster APIs"()
{

}

def "Topic APIs"()
{

}

def "Broker APIs"()
{

}

def "Consumer APIs"()
{

}
}
17 changes: 17 additions & 0 deletions src/main/java/com/homeadvisor/kafdrop/KafDrop.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,12 @@
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.context.event.ApplicationEnvironmentPreparedEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Bean;
import org.springframework.core.Ordered;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.core.env.Environment;
import org.springframework.web.servlet.config.annotation.ContentNegotiationConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.io.*;
import java.util.Objects;
Expand Down Expand Up @@ -136,4 +139,18 @@ private IniFilePropertySource readProperties(Environment environment, String nam
return null;
}
}

@Bean
public WebMvcConfigurerAdapter webConfig()
{
return new WebMvcConfigurerAdapter()
{
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer)
{
super.configureContentNegotiation(configurer);
configurer.favorPathExtension(false);
}
};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2017 HomeAdvisor, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
*/

package com.homeadvisor.kafdrop.config;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class InterceptorConfiguration extends WebMvcConfigurerAdapter {

@Autowired
private Environment environment;

@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(new ProfileHandlerInterceptor());
}


public class ProfileHandlerInterceptor extends HandlerInterceptorAdapter {
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
final String[] activeProfiles = environment.getActiveProfiles();
if (modelAndView != null && activeProfiles != null && activeProfiles.length > 0) {
modelAndView.addObject("profile", String.join(",", activeProfiles));
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public ServiceDiscovery curatorServiceDiscovery(
@Value("${curator.discovery.basePath:/homeadvisor/services}") String basePath) throws Exception
{
final Class payloadClass = Object.class;
new EnsurePath(basePath).ensure(curatorFramework.getZookeeperClient());
curatorFramework.createContainers(basePath);
return ServiceDiscoveryBuilder.builder(payloadClass)
.client(curatorFramework)
.basePath(basePath)
Expand Down
Loading

0 comments on commit 06b42d5

Please sign in to comment.