mirror of
https://github.com/prometheus/prometheus.git
synced 2025-11-02 01:11:01 +01:00
test(discovery/xds): speed up tests with t.Parallel()
Signed-off-by: Harsh <harshmastic@gmail.com>
This commit is contained in:
parent
1c58399160
commit
24282f7b44
@ -49,6 +49,8 @@ func urlMustParse(str string) *url.URL {
|
||||
}
|
||||
|
||||
func TestMakeXDSResourceHttpEndpointEmptyServerURLScheme(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
endpointURL, err := makeXDSResourceHTTPEndpointURL(ProtocolV3, urlMustParse("127.0.0.1"), "monitoring")
|
||||
|
||||
require.Empty(t, endpointURL)
|
||||
@ -56,6 +58,8 @@ func TestMakeXDSResourceHttpEndpointEmptyServerURLScheme(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMakeXDSResourceHttpEndpointEmptyServerURLHost(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
endpointURL, err := makeXDSResourceHTTPEndpointURL(ProtocolV3, urlMustParse("grpc://127.0.0.1"), "monitoring")
|
||||
|
||||
require.Empty(t, endpointURL)
|
||||
@ -63,6 +67,8 @@ func TestMakeXDSResourceHttpEndpointEmptyServerURLHost(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestMakeXDSResourceHttpEndpoint(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
endpointURL, err := makeXDSResourceHTTPEndpointURL(ProtocolV3, urlMustParse("http://127.0.0.1:5000"), "monitoring")
|
||||
|
||||
require.NoError(t, err)
|
||||
@ -70,6 +76,8 @@ func TestMakeXDSResourceHttpEndpoint(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestCreateNewHTTPResourceClient(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
c := &HTTPResourceClientConfig{
|
||||
HTTPClientConfig: sdConf.HTTPClientConfig,
|
||||
Name: "test",
|
||||
@ -106,6 +114,8 @@ func createTestHTTPResourceClient(t *testing.T, conf *HTTPResourceClientConfig,
|
||||
}
|
||||
|
||||
func TestHTTPResourceClientFetchEmptyResponse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, cleanup := createTestHTTPResourceClient(t, testHTTPResourceConfig(), ProtocolV3, func(*v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||
return nil, nil
|
||||
})
|
||||
@ -117,6 +127,8 @@ func TestHTTPResourceClientFetchEmptyResponse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPResourceClientFetchFullResponse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, cleanup := createTestHTTPResourceClient(t, testHTTPResourceConfig(), ProtocolV3, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||
if request.VersionInfo == "1" {
|
||||
return nil, nil
|
||||
@ -146,6 +158,8 @@ func TestHTTPResourceClientFetchFullResponse(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestHTTPResourceClientServerError(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client, cleanup := createTestHTTPResourceClient(t, testHTTPResourceConfig(), ProtocolV3, func(*v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||
return nil, errors.New("server error")
|
||||
})
|
||||
|
||||
@ -131,6 +131,8 @@ func newKumaTestHTTPDiscovery(c KumaSDConfig) (*fetchDiscovery, error) {
|
||||
}
|
||||
|
||||
func TestKumaMadsV1ResourceParserInvalidTypeURL(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resources := make([]*anypb.Any, 0)
|
||||
groups, err := kumaMadsV1ResourceParser(resources, "type.googleapis.com/some.api.v1.Monitoring")
|
||||
require.Nil(t, groups)
|
||||
@ -138,6 +140,8 @@ func TestKumaMadsV1ResourceParserInvalidTypeURL(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKumaMadsV1ResourceParserEmptySlice(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
resources := make([]*anypb.Any, 0)
|
||||
groups, err := kumaMadsV1ResourceParser(resources, KumaMadsV1ResourceTypeURL)
|
||||
require.Empty(t, groups)
|
||||
@ -145,6 +149,8 @@ func TestKumaMadsV1ResourceParserEmptySlice(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKumaMadsV1ResourceParserValidResources(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
res, err := getKumaMadsV1DiscoveryResponse(testKumaMadsV1Resources...)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -192,6 +198,8 @@ func TestKumaMadsV1ResourceParserValidResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKumaMadsV1ResourceParserInvalidResources(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
data, err := protoJSONMarshalOptions.Marshal(&MonitoringAssignment_Target{})
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -206,6 +214,8 @@ func TestKumaMadsV1ResourceParserInvalidResources(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNewKumaHTTPDiscovery(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
kd, err := newKumaTestHTTPDiscovery(kumaConf)
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, kd)
|
||||
@ -221,6 +231,8 @@ func TestNewKumaHTTPDiscovery(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestKumaHTTPDiscoveryRefresh(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
s := createTestHTTPServer(t, func(request *v3.DiscoveryRequest) (*v3.DiscoveryResponse, error) {
|
||||
if request.VersionInfo == "1" {
|
||||
return nil, nil
|
||||
|
||||
@ -119,6 +119,8 @@ func (testResourceClient) Close() {
|
||||
}
|
||||
|
||||
func TestPollingRefreshSkipUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
rc := &testResourceClient{
|
||||
fetch: func(context.Context) (*v3.DiscoveryResponse, error) {
|
||||
return nil, nil
|
||||
@ -162,6 +164,8 @@ func TestPollingRefreshSkipUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPollingRefreshAttachesGroupMetadata(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
server := "http://198.161.2.0"
|
||||
source := "test"
|
||||
rc := &testResourceClient{
|
||||
@ -218,6 +222,8 @@ func TestPollingRefreshAttachesGroupMetadata(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPollingDisappearingTargets(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
server := "http://198.161.2.0"
|
||||
source := "test"
|
||||
rc := &testResourceClient{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user