mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
discovery/xds: make each test use separate HTTP resource config
So tests can run in parallel without races. Signed-off-by: Mateusz Gozdek <mgozdekof@gmail.com>
This commit is contained in:
parent
fedcb8999b
commit
4ef8c7c1d8
|
@ -26,7 +26,8 @@ import (
|
||||||
"google.golang.org/protobuf/types/known/anypb"
|
"google.golang.org/protobuf/types/known/anypb"
|
||||||
)
|
)
|
||||||
|
|
||||||
var httpResourceConf = &HTTPResourceClientConfig{
|
func testHTTPResourceConfig() *HTTPResourceClientConfig {
|
||||||
|
return &HTTPResourceClientConfig{
|
||||||
HTTPClientConfig: config.HTTPClientConfig{
|
HTTPClientConfig: config.HTTPClientConfig{
|
||||||
TLSConfig: config.TLSConfig{InsecureSkipVerify: true},
|
TLSConfig: config.TLSConfig{InsecureSkipVerify: true},
|
||||||
},
|
},
|
||||||
|
@ -36,6 +37,7 @@ var httpResourceConf = &HTTPResourceClientConfig{
|
||||||
Server: "http://localhost",
|
Server: "http://localhost",
|
||||||
ClientID: "test-id",
|
ClientID: "test-id",
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func urlMustParse(str string) *url.URL {
|
func urlMustParse(str string) *url.URL {
|
||||||
parsed, err := url.Parse(str)
|
parsed, err := url.Parse(str)
|
||||||
|
@ -106,7 +108,7 @@ func createTestHTTPResourceClient(t *testing.T, conf *HTTPResourceClientConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPResourceClientFetchEmptyResponse(t *testing.T) {
|
func TestHTTPResourceClientFetchEmptyResponse(t *testing.T) {
|
||||||
client, cleanup := createTestHTTPResourceClient(t, httpResourceConf, ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
client, cleanup := createTestHTTPResourceClient(t, testHTTPResourceConfig(), ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
})
|
})
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
@ -117,7 +119,7 @@ func TestHTTPResourceClientFetchEmptyResponse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPResourceClientFetchFullResponse(t *testing.T) {
|
func TestHTTPResourceClientFetchFullResponse(t *testing.T) {
|
||||||
client, cleanup := createTestHTTPResourceClient(t, httpResourceConf, ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
client, cleanup := createTestHTTPResourceClient(t, testHTTPResourceConfig(), ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||||
if request.VersionInfo == "1" {
|
if request.VersionInfo == "1" {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
@ -146,7 +148,7 @@ func TestHTTPResourceClientFetchFullResponse(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestHTTPResourceClientServerError(t *testing.T) {
|
func TestHTTPResourceClientServerError(t *testing.T) {
|
||||||
client, cleanup := createTestHTTPResourceClient(t, httpResourceConf, ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
client, cleanup := createTestHTTPResourceClient(t, testHTTPResourceConfig(), ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||||
return nil, errors.New("server error")
|
return nil, errors.New("server error")
|
||||||
})
|
})
|
||||||
defer cleanup()
|
defer cleanup()
|
||||||
|
|
Loading…
Reference in a new issue