-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '47-support-testing-in-live' into 'master'
Resolve "Support testing in live" Closes #47 See merge request pace/go-microservice!37
- Loading branch information
Showing
22 changed files
with
499 additions
and
30 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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright © 2018 by PACE Telematics GmbH. All rights reserved. | ||
// Created at 2019/02/01 by Vincent Landgraf | ||
|
||
// Package livetest implements a set of helpers that ease writing of a | ||
// sidecar that tests the functions of a service. | ||
// | ||
// Assuring the functional correctness of a service is an important | ||
// task for a production grade system. This package aims to provide | ||
// helpers that allow a go test like experience for building functional | ||
// health tests in production. | ||
// | ||
// Test functions need to be written similarly to the regular go test | ||
// function format. Only difference is the use of the testing.TB | ||
// interface. | ||
// | ||
// If a test failed, all other tests are still executed. So tests | ||
// should not build on each other. Sub tests should be used for that | ||
// purpose. | ||
// | ||
// The result for the tests is exposed via prometheus metrics. | ||
// | ||
// The interval is configured using PACE_LIVETEST_INTERVAL (duration format). | ||
package livetest |
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,48 @@ | ||
// Copyright © 2018 by PACE Telematics GmbH. All rights reserved. | ||
// Created at 2019/02/04 by Vincent Landgraf | ||
|
||
package livetest | ||
|
||
import ( | ||
"log" | ||
"time" | ||
|
||
"github.com/caarlos0/env" | ||
"github.com/prometheus/client_golang/prometheus" | ||
) | ||
|
||
type config struct { | ||
Interval time.Duration `env:"PACE_LIVETEST_INTERVAL" envDefault:"1h"` | ||
ServiceName string `env:"JAEGER_SERVICE_NAME" envDefault:"go-microservice"` | ||
} | ||
|
||
var ( | ||
paceLivetestTotal = prometheus.NewCounterVec( | ||
prometheus.CounterOpts{ | ||
Name: "pace_livetest_total", | ||
Help: "Collects stats about the number of live tests made", | ||
}, | ||
[]string{"service", "result"}, | ||
) | ||
paceLivetestDurationSeconds = prometheus.NewHistogramVec( | ||
prometheus.HistogramOpts{ | ||
Name: "pace_livetest_duration_seconds", | ||
Help: "Collect performance metrics for each live test", | ||
Buckets: []float64{.1, .25, .5, 1, 2.5, 5, 10, 60}, | ||
}, | ||
[]string{"service"}, | ||
) | ||
) | ||
|
||
var cfg config | ||
|
||
func init() { | ||
prometheus.MustRegister(paceLivetestTotal) | ||
prometheus.MustRegister(paceLivetestDurationSeconds) | ||
|
||
// parse log config | ||
err := env.Parse(&cfg) | ||
if err != nil { | ||
log.Fatalf("Failed to parse livetest environment: %v", err) | ||
} | ||
} |
Oops, something went wrong.