-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from EladLeev/gen-chart
feat: generate pie chart from results
- Loading branch information
Showing
11 changed files
with
246 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ | |
|
||
# Dependency directories (remove the comment below to include it) | ||
# vendor/ | ||
|
||
# Don't push pie.html | ||
pie.html |
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
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
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,27 @@ | ||
package main | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/eladleev/schema-registry-statistics/utils" | ||
) | ||
|
||
type appConfig struct { | ||
bootstrapServers, version, group, topic string | ||
user, password string | ||
tls bool | ||
caCert string | ||
path string | ||
limit int | ||
oldest bool | ||
verbose bool | ||
store bool | ||
chart bool | ||
} | ||
|
||
type Consumer struct { | ||
ready chan bool | ||
stats utils.ResultStats | ||
config appConfig | ||
consumerLock sync.RWMutex | ||
} |
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,97 @@ | ||
package main | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
"time" | ||
|
||
"github.com/eladleev/schema-registry-statistics/utils" | ||
"gotest.tools/assert" | ||
) | ||
|
||
func TestConsumerInitialization(t *testing.T) { | ||
config := appConfig{ | ||
bootstrapServers: "localhost:9092", | ||
version: "2.6.0", | ||
group: "my-group", | ||
topic: "my-topic", | ||
user: "my-user", | ||
password: "my-password", | ||
tls: true, | ||
caCert: "ca.pem", | ||
path: "/tmp", | ||
limit: 1000, | ||
oldest: true, | ||
verbose: true, | ||
store: true, | ||
chart: true, | ||
} | ||
|
||
consumer := Consumer{ | ||
ready: make(chan bool), | ||
stats: utils.ResultStats{}, | ||
config: config, | ||
consumerLock: sync.RWMutex{}, | ||
} | ||
|
||
assert.Equal(t, config.bootstrapServers, consumer.config.bootstrapServers) | ||
assert.Equal(t, config.version, consumer.config.version) | ||
assert.Equal(t, config.group, consumer.config.group) | ||
assert.Equal(t, config.topic, consumer.config.topic) | ||
assert.Equal(t, config.user, consumer.config.user) | ||
assert.Equal(t, config.password, consumer.config.password) | ||
assert.Equal(t, config.tls, consumer.config.tls) | ||
assert.Equal(t, config.caCert, consumer.config.caCert) | ||
assert.Equal(t, config.path, consumer.config.path) | ||
assert.Equal(t, config.limit, consumer.config.limit) | ||
assert.Equal(t, config.oldest, consumer.config.oldest) | ||
assert.Equal(t, config.verbose, consumer.config.verbose) | ||
assert.Equal(t, config.store, consumer.config.store) | ||
assert.Equal(t, config.chart, consumer.config.chart) | ||
} | ||
|
||
func TestConsumerLocking(t *testing.T) { | ||
config := appConfig{ | ||
bootstrapServers: "localhost:9092", | ||
version: "2.6.0", | ||
group: "my-group", | ||
topic: "my-topic", | ||
user: "my-user", | ||
password: "my-password", | ||
tls: true, | ||
caCert: "ca.pem", | ||
path: "/tmp", | ||
limit: 1000, | ||
oldest: true, | ||
verbose: true, | ||
store: true, | ||
chart: true, | ||
} | ||
|
||
consumer := Consumer{ | ||
ready: make(chan bool), | ||
stats: utils.ResultStats{}, | ||
config: config, | ||
consumerLock: sync.RWMutex{}, | ||
} | ||
|
||
var wg sync.WaitGroup | ||
wg.Add(2) | ||
|
||
go func() { | ||
consumer.consumerLock.Lock() | ||
defer consumer.consumerLock.Unlock() | ||
|
||
time.Sleep(time.Millisecond * 100) | ||
wg.Done() | ||
}() | ||
|
||
go func() { | ||
consumer.consumerLock.Lock() | ||
defer consumer.consumerLock.Unlock() | ||
|
||
wg.Done() | ||
}() | ||
|
||
wg.Wait() | ||
} |
Oops, something went wrong.