Skip to content

Commit

Permalink
Make behave tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-helmich committed Oct 31, 2016
1 parent 7f1b902 commit 43558aa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 5 additions & 2 deletions features/steps/steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
"upstream-time": '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for" $upstream_response_time'
}

bin_name = './prometheus-nginxlog-exporter'


@given('a running exporter listening on "{filename}" with format')
def run_exporter_impl(context, filename):
filename = '.behave-sandbox/%s' % filename
p = subprocess.Popen(['./nginx-log-exporter', '--format', context.text, filename],
p = subprocess.Popen([bin_name, '--format', context.text, filename],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(.5)

Expand All @@ -25,7 +27,7 @@ def run_exporter_impl(context, filename):
@given('a running exporter listening on "{filename}" with {format} format')
def run_exporter_impl(context, filename, format):
filename = '.behave-sandbox/%s' % filename
p = subprocess.Popen(['./nginx-log-exporter', '--format', formats[format], filename],
p = subprocess.Popen([bin_name, '--format', formats[format], filename],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
time.sleep(.5)

Expand All @@ -41,6 +43,7 @@ def step_impl(context, filename):
filename = '.behave-sandbox/%s' % filename
with open(filename, 'a') as f:
f.write("%s\n" % context.text)
time.sleep(.5)


@then(u'the exporter should report value {val} for metric {metric}')
Expand Down
6 changes: 3 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ func (m *Metrics) Init(opts *StartOptions) {
func main() {
var opts StartOptions

flag.IntVar(&opts.ListenPort, "-listen-port", 4040, "HTTP port to listen on")
flag.StringVar(&opts.Format, "-format", `$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"`, "NGINX access log format")
flag.StringVar(&opts.Namespace, "-namespace", "nginx", "namespace to use for metric names")
flag.IntVar(&opts.ListenPort, "listen-port", 4040, "HTTP port to listen on")
flag.StringVar(&opts.Format, "format", `$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" "$http_x_forwarded_for"`, "NGINX access log format")
flag.StringVar(&opts.Namespace, "namespace", "nginx", "namespace to use for metric names")
flag.Parse()

opts.Filenames = flag.Args()
Expand Down

0 comments on commit 43558aa

Please sign in to comment.