Skip to content

Commit

Permalink
Init Unit Test
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Sep 30, 2018
1 parent ef77f05 commit 4daba2d
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 119 deletions.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
ext {
joobyVersion = "1.5.1"
joobyVersion = "1.5.+"
}

repositories {
Expand Down Expand Up @@ -73,6 +73,8 @@ dependencies {

// test
testCompile "junit:junit:4.12"
testCompile 'com.salesforce.kafka.test:kafka-junit4:3.0.1'
testCompile 'org.apache.kafka:kafka_2.11:2.0.0'
testCompile "io.rest-assured:rest-assured:3.1.0"
}

Expand Down
7 changes: 7 additions & 0 deletions conf/application.test.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
application {
port: 28186
}

server {
join: false
}
9 changes: 9 additions & 0 deletions conf/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,16 @@
</root>

<logger name="org.apache.kafka" level="WARN" />

<!-- Jooby -->
<logger name="io.netty" level="WARN" />
<logger name="org.jooby" level="WARN" />
<logger name="org.jooby.RequestLogger" level="INFO" />

<!-- Test -->
<logger name="org.apache.zookeeper" level="ERROR" />
<logger name="com.salesforce.kafka" level="ERROR" />
<logger name="kafka" level="ERROR" />
<logger name="com.salesforce.kafka" level="INFO" />
<logger name="state.change.logger" level="ERROR" />
</configuration>
111 changes: 111 additions & 0 deletions public/includes/topic.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<#macro data datas>
<!--
<nav class="navbar navbar-expand-lg navbar-light bg-light mr-auto data-filter">
<button class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#topic-data"
aria-controls="topic-data"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<nav>
<ul class="pagination mb-0 ml-sm-2">
<li class="page-item">
<a class="page-link" href="#" aria-label="Previous">
<span aria-hidden="true">&laquo;</span>
<span class="sr-only">Previous</span>
</a>
</li>
<li class="page-item">
<a class="page-link" href="#" aria-label="Next">
<span aria-hidden="true">&raquo;</span>
<span class="sr-only">Next</span>
</a>
</li>
</ul>
</nav>
<div class="collapse navbar-collapse" id="topic-data">
<ul class="navbar-nav mr-auto">
<li class="nav-item dropdown">
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Count (20)
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Partition (All)
</a>
<div class="dropdown-menu">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
<li class="nav-item ml-md-2">
<form class="form-inline">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
</li>
</ul>
</div>
</nav>
-->
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover mb-0">
<thead class="thead-dark">
<tr>
<th>Key</th>
<th>Date</th>
<th>Partition</th>
<th>Offset</th>
</tr>
</thead>
<tbody>
<#if datas?size == 0>
<tr>
<td colspan="5">
<div class="alert alert-info mb-0" role="alert">
No data available
</div>
</td>
</tr>
</#if>
<#list datas as data>
<tr>
<td><code>${data.key()!'null'}</code></td>
<td>${data.timestamp()?number_to_datetime?string.medium_short}</td>
<td>${data.partition()}</td>
<td>${data.offset()}</td>
</tr>
<tr>
<td colspan="4">
<pre class="mb-0"><code>${data.value()!'null'}</code></pre>
</td>
</tr>
</#list>
</tbody>
</table>
</div>
</#macro>
75 changes: 46 additions & 29 deletions public/static/template.scss
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ a, button, input[type="submit"] {
transition-duration: 200ms;
}

body {
min-width: 320px;

}

.title {
display: flex;
position: relative;
Expand Down Expand Up @@ -149,45 +154,47 @@ h1 {
}
}
}
}

a {
&[aria-expanded="true"] {
color: #fff;
background: $tertiary;
}
&[data-toggle="collapse"] {
position: relative;

a {
&[aria-expanded="true"] {
color: #fff;
background: $tertiary;
}
&[data-toggle="collapse"] {
position: relative;
}
}
}

.dropdown-toggle::after {
display: block;
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
}
.dropdown-toggle::after {
display: block;
position: absolute;
top: 50%;
right: 20px;
transform: translateY(-50%);
}

ul ul a {
font-size: 0.9em !important;
padding-left: 30px !important;
background: $tertiary;
}
ul ul a {
font-size: 0.9em !important;
padding-left: 30px !important;
background: $tertiary;
}


@media (max-width: 768px) {
#sidebar {
margin-left: -250px;
&.active {
margin-left: 0;
@media (max-width: 768px) {
& {
margin-left: -250px;
&.active {
margin-left: 0;
}
}
#sidebar-collapse span {
display: none;
}
}
#sidebar-collapse span {
display: none;
}
}


/* ----------------------------------------------------------------------------------------------------------------- *\
Turbolinks
\* ----------------------------------------------------------------------------------------------------------------- */
Expand Down Expand Up @@ -220,4 +227,14 @@ table {
word-break: break-all;
}
}
}

/* ----------------------------------------------------------------------------------------------------------------- *\
Data
\* ----------------------------------------------------------------------------------------------------------------- */
.data-filter {
> nav {
display: flex;
order: 2;
}
}
38 changes: 2 additions & 36 deletions public/topic.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<#import "/includes/node.ftl" as nodeTemplate>
<#import "/includes/group.ftl" as groupTemplate>
<#import "/includes/functions.ftl" as functions>
<#import "/includes/topic.ftl" as topicTemplate>

<@template.header "Topic: " + topic.getName(), "topic" />

Expand All @@ -32,42 +33,7 @@
<div class="tab-content">
<#if tab == "data">
<div class="tab-pane active" role="tabpanel">
<div class="table-responsive">
<table class="table table-bordered table-striped table-hover mb-0">
<thead class="thead-dark">
<tr>
<th>Key</th>
<th>Date</th>
<th>Partition</th>
<th>Offset</th>
</tr>
</thead>
<tbody>
<#if datas?size == 0>
<tr>
<td colspan="5">
<div class="alert alert-info mb-0" role="alert">
No data available
</div>
</td>
</tr>
</#if>
<#list datas as data>
<tr>
<td><code>${data.key()!'null'}</code></td>
<td>${data.timestamp()?number_to_datetime?string.medium_short}</td>
<td>${data.partition()}</td>
<td>${data.offset()}</td>
</tr>
<tr>
<td colspan="4">
<pre class="mb-0"><code>${data.value()!'null'}</code></pre>
</td>
</tr>
</#list>
</tbody>
</table>
</div>
<@topicTemplate.data datas />
</div>
</#if>

Expand Down
9 changes: 8 additions & 1 deletion src/main/java/org/kafkahq/models/Partition.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
@ToString
@EqualsAndHashCode
public class Partition {
public Partition(TopicPartitionInfo partitionInfo, LogDir logDir, Offsets offsets) {
public Partition(String topic, TopicPartitionInfo partitionInfo, LogDir logDir, Offsets offsets) {
this.id = partitionInfo.partition();
this.topic = topic;
this.logDir = logDir;
this.firstOffset = offsets.getFirstOffset();
this.lastOffset = offsets.getLastOffset();
Expand All @@ -31,6 +32,12 @@ public int getId() {
return id;
}

private final String topic;

public String getTopic() {
return topic;
}

private final List<Node.Partition> nodes;

public List<Node.Partition> getNodes() {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/org/kafkahq/models/Topic.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public Topic(

for (TopicPartitionInfo partition : description.partitions()) {
this.partitions.add(new Partition(
description.name(),
partition,
logDirs.stream()
.filter(logDir -> logDir.getPartition() == partition.partition())
Expand Down
Loading

0 comments on commit 4daba2d

Please sign in to comment.