diff --git a/pkg/app/piped/analysisprovider/metrics/datadog/datadog_test.go b/pkg/app/piped/analysisprovider/metrics/datadog/datadog_test.go index 7a5b0ed09b..9af3bfe510 100644 --- a/pkg/app/piped/analysisprovider/metrics/datadog/datadog_test.go +++ b/pkg/app/piped/analysisprovider/metrics/datadog/datadog_test.go @@ -29,6 +29,8 @@ import ( ) func TestProviderQueryPoints(t *testing.T) { + t.Parallel() + toInt64Pointer := func(i int64) *int64 { return &i } type queryResponse struct { res datadog.MetricsQueryResponse diff --git a/pkg/app/piped/analysisprovider/metrics/prometheus/prometheus_test.go b/pkg/app/piped/analysisprovider/metrics/prometheus/prometheus_test.go index 6fba019938..b4043bb770 100644 --- a/pkg/app/piped/analysisprovider/metrics/prometheus/prometheus_test.go +++ b/pkg/app/piped/analysisprovider/metrics/prometheus/prometheus_test.go @@ -14,11 +14,15 @@ import ( ) func TestType(t *testing.T) { + t.Parallel() + p := Provider{} assert.Equal(t, ProviderType, p.Type()) } func TestProviderQueryPoints(t *testing.T) { + t.Parallel() + testcases := []struct { name string client client diff --git a/pkg/app/piped/apistore/analysisresultstore/BUILD.bazel b/pkg/app/piped/apistore/analysisresultstore/BUILD.bazel index e97527520e..458f59f8b3 100644 --- a/pkg/app/piped/apistore/analysisresultstore/BUILD.bazel +++ b/pkg/app/piped/apistore/analysisresultstore/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -14,10 +14,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["store_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/apistore/analysisresultstore/store_test.go b/pkg/app/piped/apistore/analysisresultstore/store_test.go deleted file mode 100644 index ca5d6fcd75..0000000000 --- a/pkg/app/piped/apistore/analysisresultstore/store_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2021 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package analysisresultstore diff --git a/pkg/app/piped/apistore/applicationstore/BUILD.bazel b/pkg/app/piped/apistore/applicationstore/BUILD.bazel index bc088754b7..f0c4ae3fa5 100644 --- a/pkg/app/piped/apistore/applicationstore/BUILD.bazel +++ b/pkg/app/piped/apistore/applicationstore/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -12,10 +12,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["store_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/apistore/applicationstore/store_test.go b/pkg/app/piped/apistore/applicationstore/store_test.go deleted file mode 100644 index 69ffa9c9a3..0000000000 --- a/pkg/app/piped/apistore/applicationstore/store_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package applicationstore diff --git a/pkg/app/piped/apistore/commandstore/BUILD.bazel b/pkg/app/piped/apistore/commandstore/BUILD.bazel index f34b15e543..ab9f9ef0f6 100644 --- a/pkg/app/piped/apistore/commandstore/BUILD.bazel +++ b/pkg/app/piped/apistore/commandstore/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -12,10 +12,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["store_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/apistore/commandstore/store_test.go b/pkg/app/piped/apistore/commandstore/store_test.go deleted file mode 100644 index 7d94152e36..0000000000 --- a/pkg/app/piped/apistore/commandstore/store_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package commandstore diff --git a/pkg/app/piped/apistore/deploymentstore/BUILD.bazel b/pkg/app/piped/apistore/deploymentstore/BUILD.bazel index c26a131594..83df5e22e6 100644 --- a/pkg/app/piped/apistore/deploymentstore/BUILD.bazel +++ b/pkg/app/piped/apistore/deploymentstore/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -12,10 +12,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["store_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/apistore/deploymentstore/store_test.go b/pkg/app/piped/apistore/deploymentstore/store_test.go deleted file mode 100644 index 815aa6b41c..0000000000 --- a/pkg/app/piped/apistore/deploymentstore/store_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package deploymentstore diff --git a/pkg/app/piped/apistore/eventstore/BUILD.bazel b/pkg/app/piped/apistore/eventstore/BUILD.bazel index f6fd625f5b..ae609b2469 100644 --- a/pkg/app/piped/apistore/eventstore/BUILD.bazel +++ b/pkg/app/piped/apistore/eventstore/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -12,10 +12,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["store_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/apistore/eventstore/store_test.go b/pkg/app/piped/apistore/eventstore/store_test.go deleted file mode 100644 index 3231b0741e..0000000000 --- a/pkg/app/piped/apistore/eventstore/store_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2021 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package eventstore diff --git a/pkg/app/piped/appconfigreporter/appconfigreporter_test.go b/pkg/app/piped/appconfigreporter/appconfigreporter_test.go index e1bd4989c1..210ba06959 100644 --- a/pkg/app/piped/appconfigreporter/appconfigreporter_test.go +++ b/pkg/app/piped/appconfigreporter/appconfigreporter_test.go @@ -34,6 +34,8 @@ func (f *fakeApplicationLister) List() []*model.Application { } func TestReporter_findRegisteredApps(t *testing.T) { + t.Parallel() + type args struct { repoPath string repoID string @@ -162,6 +164,8 @@ spec: } func TestReporter_findUnregisteredApps(t *testing.T) { + t.Parallel() + type args struct { registeredAppPaths map[string]string repoPath, repoID string diff --git a/pkg/app/piped/cloudprovider/cloudrun/client_test.go b/pkg/app/piped/cloudprovider/cloudrun/client_test.go index 75de34e6c7..2b936d102c 100644 --- a/pkg/app/piped/cloudprovider/cloudrun/client_test.go +++ b/pkg/app/piped/cloudprovider/cloudrun/client_test.go @@ -21,6 +21,8 @@ import ( ) func TestMakeCloudRunParent(t *testing.T) { + t.Parallel() + const projectID = "projectID" got := makeCloudRunParent(projectID) want := "namespaces/projectID" @@ -28,6 +30,8 @@ func TestMakeCloudRunParent(t *testing.T) { } func TestMakeCloudRunServiceName(t *testing.T) { + t.Parallel() + const ( projectID = "projectID" serviceID = "serviceID" @@ -38,6 +42,8 @@ func TestMakeCloudRunServiceName(t *testing.T) { } func TestMakeCloudRunRevisionName(t *testing.T) { + t.Parallel() + const ( projectID = "projectID" revisionID = "revisionID" diff --git a/pkg/app/piped/cloudprovider/cloudrun/cloudrun_test.go b/pkg/app/piped/cloudprovider/cloudrun/cloudrun_test.go index 82136f8c38..d1e10f6cd9 100644 --- a/pkg/app/piped/cloudprovider/cloudrun/cloudrun_test.go +++ b/pkg/app/piped/cloudprovider/cloudrun/cloudrun_test.go @@ -24,6 +24,8 @@ import ( ) func TestLoadServiceManifest(t *testing.T) { + t.Parallel() + const ( appDir = "testdata" serviceFile = "new_manifest.yaml" @@ -39,12 +41,16 @@ func TestLoadServiceManifest(t *testing.T) { } func TestMakeManagedByPipedSelector(t *testing.T) { + t.Parallel() + want := "pipecd-dev-managed-by=piped" got := MakeManagedByPipedSelector() assert.Equal(t, want, got) } func TestMakeRevisionNamesSelector(t *testing.T) { + t.Parallel() + names := []string{"test-1", "test-2", "test-3"} got := MakeRevisionNamesSelector(names) want := "pipecd-dev-revision-name in (test-1,test-2,test-3)" @@ -52,6 +58,8 @@ func TestMakeRevisionNamesSelector(t *testing.T) { } func TestService(t *testing.T) { + t.Parallel() + sm, err := ParseServiceManifest([]byte(serviceManifest)) require.NoError(t, err) @@ -75,6 +83,8 @@ func TestService(t *testing.T) { } func TestService_HealthStatus(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifest string @@ -309,6 +319,8 @@ status: } func TestRevision(t *testing.T) { + t.Parallel() + rm, err := ParseRevisionManifest([]byte(revisionManifest)) require.NoError(t, err) require.NotEmpty(t, rm) @@ -323,6 +335,8 @@ func TestRevision(t *testing.T) { } func TestRevision_HealthStatus(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifest string diff --git a/pkg/app/piped/cloudprovider/cloudrun/diff_test.go b/pkg/app/piped/cloudprovider/cloudrun/diff_test.go index 72d1e60eed..f95ae25ec1 100644 --- a/pkg/app/piped/cloudprovider/cloudrun/diff_test.go +++ b/pkg/app/piped/cloudprovider/cloudrun/diff_test.go @@ -22,6 +22,8 @@ import ( ) func TestDiff(t *testing.T) { + t.Parallel() + old, err := loadServiceManifest("testdata/old_manifest.yaml") require.NoError(t, err) require.NotEmpty(t, old) @@ -42,6 +44,8 @@ func TestDiff(t *testing.T) { } func TestDiffResult_NoChange(t *testing.T) { + t.Parallel() + old, err := loadServiceManifest("testdata/old_manifest.yaml") require.NoError(t, err) require.NotEmpty(t, old) @@ -100,6 +104,8 @@ func TestDiffResult_Render(t *testing.T) { } func TestDiffByCommand(t *testing.T) { + t.Parallel() + testcases := []struct { name string command string diff --git a/pkg/app/piped/cloudprovider/cloudrun/revisionmanifest_test.go b/pkg/app/piped/cloudprovider/cloudrun/revisionmanifest_test.go index 3dbb021ac6..c6e2ae5fb9 100644 --- a/pkg/app/piped/cloudprovider/cloudrun/revisionmanifest_test.go +++ b/pkg/app/piped/cloudprovider/cloudrun/revisionmanifest_test.go @@ -86,6 +86,8 @@ status: ` func TestRevisionManifest(t *testing.T) { + t.Parallel() + rm, err := ParseRevisionManifest([]byte(revisionManifest)) require.NoError(t, err) require.NotEmpty(t, rm) diff --git a/pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go b/pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go index 7818155f78..e8135dc50d 100644 --- a/pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go +++ b/pkg/app/piped/cloudprovider/cloudrun/servicemanifest_test.go @@ -82,6 +82,8 @@ status: ` func TestServiceManifest(t *testing.T) { + t.Parallel() + sm, err := ParseServiceManifest([]byte(serviceManifest)) require.NoError(t, err) require.NotEmpty(t, sm) @@ -143,6 +145,8 @@ func TestServiceManifest(t *testing.T) { } func TestParseServiceManifest(t *testing.T) { + t.Parallel() + // Success data := []byte(serviceManifest) sm, err := ParseServiceManifest(data) @@ -156,6 +160,8 @@ func TestParseServiceManifest(t *testing.T) { } func TestDecideRevisionName(t *testing.T) { + t.Parallel() + data := []byte(serviceManifest) sm, err := ParseServiceManifest(data) require.NoError(t, err) @@ -166,6 +172,8 @@ func TestDecideRevisionName(t *testing.T) { } func TestFindImageTag(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifest string diff --git a/pkg/app/piped/cloudprovider/cloudrun/state_test.go b/pkg/app/piped/cloudprovider/cloudrun/state_test.go index 24213045e8..7bdda1b33c 100644 --- a/pkg/app/piped/cloudprovider/cloudrun/state_test.go +++ b/pkg/app/piped/cloudprovider/cloudrun/state_test.go @@ -25,6 +25,8 @@ import ( ) func TestMakeResourceStates(t *testing.T) { + t.Parallel() + sm, err := ParseServiceManifest([]byte(serviceManifest)) require.NoError(t, err) diff --git a/pkg/app/piped/cloudprovider/ecs/servce_test.go b/pkg/app/piped/cloudprovider/ecs/servce_test.go index a76f24fab9..c400f66984 100644 --- a/pkg/app/piped/cloudprovider/ecs/servce_test.go +++ b/pkg/app/piped/cloudprovider/ecs/servce_test.go @@ -23,6 +23,8 @@ import ( ) func TestParseServiceDefinition(t *testing.T) { + t.Parallel() + testcases := []struct { name string input string diff --git a/pkg/app/piped/cloudprovider/ecs/task_test.go b/pkg/app/piped/cloudprovider/ecs/task_test.go index 78f6dc1ee9..979b717641 100644 --- a/pkg/app/piped/cloudprovider/ecs/task_test.go +++ b/pkg/app/piped/cloudprovider/ecs/task_test.go @@ -23,6 +23,8 @@ import ( ) func TestParseTaskDefinition(t *testing.T) { + t.Parallel() + testcases := []struct { name string input string diff --git a/pkg/app/piped/cloudprovider/kubernetes/deployment_test.go b/pkg/app/piped/cloudprovider/kubernetes/deployment_test.go index 825c958b0f..8a6faa18e2 100644 --- a/pkg/app/piped/cloudprovider/kubernetes/deployment_test.go +++ b/pkg/app/piped/cloudprovider/kubernetes/deployment_test.go @@ -24,6 +24,8 @@ import ( ) func TestFindReferencingConfigMapsInDeployment(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifest string @@ -189,6 +191,8 @@ spec: } func TestFindReferencingSecretsInDeployment(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifest string diff --git a/pkg/app/piped/cloudprovider/kubernetes/diff_test.go b/pkg/app/piped/cloudprovider/kubernetes/diff_test.go index db4943e812..9d09529197 100644 --- a/pkg/app/piped/cloudprovider/kubernetes/diff_test.go +++ b/pkg/app/piped/cloudprovider/kubernetes/diff_test.go @@ -24,6 +24,8 @@ import ( ) func TestGroupManifests(t *testing.T) { + t.Parallel() + testcases := []struct { name string olds []Manifest @@ -118,6 +120,8 @@ func TestGroupManifests(t *testing.T) { } func TestDiffByCommand(t *testing.T) { + t.Parallel() + testcases := []struct { name string command string @@ -188,6 +192,8 @@ func TestDiffByCommand(t *testing.T) { } func TestDiff(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests string diff --git a/pkg/app/piped/cloudprovider/kubernetes/hasher_test.go b/pkg/app/piped/cloudprovider/kubernetes/hasher_test.go index ed49262818..0589da5c80 100644 --- a/pkg/app/piped/cloudprovider/kubernetes/hasher_test.go +++ b/pkg/app/piped/cloudprovider/kubernetes/hasher_test.go @@ -23,6 +23,8 @@ import ( ) func TestHashManifests(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests string diff --git a/pkg/app/piped/cloudprovider/kubernetes/helm_test.go b/pkg/app/piped/cloudprovider/kubernetes/helm_test.go index fb20af3db1..18ef3db08e 100644 --- a/pkg/app/piped/cloudprovider/kubernetes/helm_test.go +++ b/pkg/app/piped/cloudprovider/kubernetes/helm_test.go @@ -27,6 +27,8 @@ import ( ) func TestTemplateLocalChart(t *testing.T) { + t.Parallel() + var ( ctx = context.Background() appName = "testapp" @@ -48,6 +50,8 @@ func TestTemplateLocalChart(t *testing.T) { } func TestTemplateLocalChart_WithNamespace(t *testing.T) { + t.Parallel() + var ( ctx = context.Background() appName = "testapp" diff --git a/pkg/app/piped/cloudprovider/kubernetes/kustomize_test.go b/pkg/app/piped/cloudprovider/kubernetes/kustomize_test.go index 467858da04..74e5d642ae 100644 --- a/pkg/app/piped/cloudprovider/kubernetes/kustomize_test.go +++ b/pkg/app/piped/cloudprovider/kubernetes/kustomize_test.go @@ -26,6 +26,8 @@ import ( ) func TestKustomizeTemplate(t *testing.T) { + t.Parallel() + var ( ctx = context.TODO() appName = "testapp" diff --git a/pkg/app/piped/cloudprovider/lambda/client_test.go b/pkg/app/piped/cloudprovider/lambda/client_test.go index 6634217e91..1e25447c4d 100644 --- a/pkg/app/piped/cloudprovider/lambda/client_test.go +++ b/pkg/app/piped/cloudprovider/lambda/client_test.go @@ -21,6 +21,8 @@ import ( ) func TestMakeFlowControlTagsMap(t *testing.T) { + t.Parallel() + testcases := []struct { name string remoteTags map[string]string diff --git a/pkg/app/piped/cloudprovider/lambda/function_test.go b/pkg/app/piped/cloudprovider/lambda/function_test.go index ac7126204b..2805e8c54a 100644 --- a/pkg/app/piped/cloudprovider/lambda/function_test.go +++ b/pkg/app/piped/cloudprovider/lambda/function_test.go @@ -21,6 +21,8 @@ import ( ) func TestparseFunctionManifest(t *testing.T) { + t.Parallel() + testcases := []struct { name string data string diff --git a/pkg/app/piped/cloudprovider/terraform/BUILD.bazel b/pkg/app/piped/cloudprovider/terraform/BUILD.bazel index 083c581140..c0e4339dbc 100644 --- a/pkg/app/piped/cloudprovider/terraform/BUILD.bazel +++ b/pkg/app/piped/cloudprovider/terraform/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -6,10 +6,3 @@ go_library( importpath = "github.com/pipe-cd/pipecd/pkg/app/piped/cloudprovider/terraform", visibility = ["//visibility:public"], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["terraform_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/cloudprovider/terraform/terraform_test.go b/pkg/app/piped/cloudprovider/terraform/terraform_test.go deleted file mode 100644 index b2dcb81a31..0000000000 --- a/pkg/app/piped/cloudprovider/terraform/terraform_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package terraform diff --git a/pkg/app/piped/controller/BUILD.bazel b/pkg/app/piped/controller/BUILD.bazel index 03b52fc43f..5496b55a13 100644 --- a/pkg/app/piped/controller/BUILD.bazel +++ b/pkg/app/piped/controller/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -31,10 +31,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["controller_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/controller/controller_test.go b/pkg/app/piped/controller/controller_test.go deleted file mode 100644 index 13eac88c63..0000000000 --- a/pkg/app/piped/controller/controller_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package controller diff --git a/pkg/app/piped/deploysource/BUILD.bazel b/pkg/app/piped/deploysource/BUILD.bazel index 84daf1a3bb..2ae9cbec62 100644 --- a/pkg/app/piped/deploysource/BUILD.bazel +++ b/pkg/app/piped/deploysource/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -15,10 +15,3 @@ go_library( "//pkg/model:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["deploysource_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/deploysource/deploysource_test.go b/pkg/app/piped/deploysource/deploysource_test.go deleted file mode 100644 index 7fca4871cf..0000000000 --- a/pkg/app/piped/deploysource/deploysource_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package deploysource diff --git a/pkg/app/piped/eventwatcher/eventwatcher_test.go b/pkg/app/piped/eventwatcher/eventwatcher_test.go index 47d887cc19..2e45840dc8 100644 --- a/pkg/app/piped/eventwatcher/eventwatcher_test.go +++ b/pkg/app/piped/eventwatcher/eventwatcher_test.go @@ -21,6 +21,8 @@ import ( ) func TestConvertStr(t *testing.T) { + t.Parallel() + testcases := []struct { name string value interface{} @@ -80,6 +82,8 @@ func TestConvertStr(t *testing.T) { } func TestModifyYAML(t *testing.T) { + t.Parallel() + testcases := []struct { name string path string @@ -119,6 +123,8 @@ func TestModifyYAML(t *testing.T) { } func TestModifyText(t *testing.T) { + t.Parallel() + testcases := []struct { name string path string diff --git a/pkg/app/piped/executor/analysis/mannwhitney/mannwhitney_test.go b/pkg/app/piped/executor/analysis/mannwhitney/mannwhitney_test.go index 6a63ecae71..5d23919504 100644 --- a/pkg/app/piped/executor/analysis/mannwhitney/mannwhitney_test.go +++ b/pkg/app/piped/executor/analysis/mannwhitney/mannwhitney_test.go @@ -21,11 +21,13 @@ package mannwhitney import "testing" func TestMannWhitneyUTest(t *testing.T) { + t.Parallel() + check := func(want, got *MannWhitneyUTestResult) { if want.N1 != got.N1 || want.N2 != got.N2 || - !aeq(want.U, got.U) || + !aeq(t, want.U, got.U) || want.AltHypothesis != got.AltHypothesis || - !aeq(want.P, got.P) { + !aeq(t, want.P, got.P) { t.Errorf("want %+v, got %+v", want, got) } } diff --git a/pkg/app/piped/executor/analysis/mannwhitney/udist_test.go b/pkg/app/piped/executor/analysis/mannwhitney/udist_test.go index a74bae4b1b..b5558f19fa 100644 --- a/pkg/app/piped/executor/analysis/mannwhitney/udist_test.go +++ b/pkg/app/piped/executor/analysis/mannwhitney/udist_test.go @@ -24,7 +24,9 @@ import ( "testing" ) -func aeqTable(a, b [][]float64) bool { +func aeqTable(t *testing.T, a, b [][]float64) bool { + t.Helper() + if len(a) != len(b) { return false } @@ -65,6 +67,8 @@ var udist5 = [][]float64{ } func TestUDist(t *testing.T) { + t.Parallel() + makeTable := func(n int) [][]float64 { out := make([][]float64, 6) for U := 0; U < 6; U++ { @@ -94,12 +98,12 @@ func TestUDist(t *testing.T) { // Compare against tables given in Mann, Whitney (1947). got3 := makeTable(3) - if !aeqTable(got3, udist3) { + if !aeqTable(t, got3, udist3) { t.Errorf("For n=3, want:\n%sgot:\n%s", fmtTable(udist3), fmtTable(got3)) } got5 := makeTable(5) - if !aeqTable(got5, udist5) { + if !aeqTable(t, got5, udist5) { t.Errorf("For n=5, want:\n%sgot:\n%s", fmtTable(udist5), fmtTable(got5)) } } @@ -113,14 +117,16 @@ func BenchmarkUDist(b *testing.B) { } func TestUDistTies(t *testing.T) { - makeTable := func(m, N int, t []int, minx, maxx float64) [][]float64 { + t.Parallel() + + makeTable := func(m, N int, tVar []int, minx, maxx float64) [][]float64 { out := [][]float64{} - dist := UDist{N1: m, N2: N - m, T: t} + dist := UDist{N1: m, N2: N - m, T: tVar} for x := minx; x <= maxx; x += 0.5 { // Convert x from uQt' to uQv'. U := x - float64(m*m)/2 P := dist.CDF(U) - if len(out) == 0 || !aeq(out[len(out)-1][1], P) { + if len(out) == 0 || !aeq(t, out[len(out)-1][1], P) { out = append(out, []float64{x, P}) } } @@ -142,7 +148,7 @@ func TestUDistTies(t *testing.T) { {17.5, 0.071429}, {18.0, 0.087302}, {19.0, 0.134921}, {19.5, 0.138889}, } - if !aeqTable(got, want) { + if !aeqTable(t, got, want) { t.Errorf("Want:\n%sgot:\n%s", fmtTable(want), fmtTable(got)) } @@ -175,7 +181,7 @@ func TestUDistTies(t *testing.T) { {85.5, 0.083498}, {86.0, 0.094079}, {86.5, 0.096693}, {87.0, 0.101132}, } - if !aeqTable(got, want) { + if !aeqTable(t, got, want) { t.Errorf("Want:\n%sgot:\n%s", fmtTable(want), fmtTable(got)) } @@ -188,14 +194,14 @@ func TestUDistTies(t *testing.T) { {48.0, 0.057187}, {50.0, 0.086713}, {52.0, 0.126263}, {54.0, 0.175369}, } - if !aeqTable(got, want) { + if !aeqTable(t, got, want) { t.Errorf("Want:\n%sgot:\n%s", fmtTable(want), fmtTable(got)) } // Check remaining tables from Klotz against the reference // implementation. checkRef := func(n1 int, tie []int) { - wantPMF1, wantCDF1 := udistRef(n1, tie) + wantPMF1, wantCDF1 := udistRef(t, n1, tie) dist := UDist{N1: n1, N2: sumint(tie) - n1, T: tie} gotPMF, wantPMF := [][]float64{}, [][]float64{} @@ -207,10 +213,10 @@ func TestUDistTies(t *testing.T) { wantPMF = append(wantPMF, []float64{U, wantPMF1[int(U*2)]}) wantCDF = append(wantCDF, []float64{U, wantCDF1[int(U*2)]}) } - if !aeqTable(wantPMF, gotPMF) { + if !aeqTable(t, wantPMF, gotPMF) { t.Errorf("For PMF of n1=%v, t=%v, want:\n%sgot:\n%s", n1, tie, fmtTable(wantPMF), fmtTable(gotPMF)) } - if !aeqTable(wantCDF, gotCDF) { + if !aeqTable(t, wantCDF, gotCDF) { t.Errorf("For CDF of n1=%v, t=%v, want:\n%sgot:\n%s", n1, tie, fmtTable(wantCDF), fmtTable(gotCDF)) } } @@ -239,7 +245,7 @@ func BenchmarkUDistTies(b *testing.B) { func XTestPrintUmemo(t *testing.T) { // Reproduce table from Cheung, Klotz. ties := []int{4, 5, 3, 4, 6} - printUmemo(makeUmemo(80, 10, ties), ties) + printUmemo(t, makeUmemo(80, 10, ties), ties) } // udistRef computes the PMF and CDF of the U distribution for two @@ -249,20 +255,21 @@ func XTestPrintUmemo(t *testing.T) { // This uses the "graphical method" of Klotz (1966). It is very slow // (Θ(∏ (t[i]+1)) = Ω(2^|t|)), but very correct, and hence useful as a // reference for testing faster implementations. -func udistRef(n1 int, t []int) (pmf, cdf []float64) { - // Enumerate all u vectors for which 0 <= u_i <= t_i. Count +func udistRef(t *testing.T, n1 int, tVar []int) (pmf, cdf []float64) { + t.Helper() + // Enumerate all u vectors for which 0 <= ui <= tVari. Count // the number of permutations of two samples of sizes n1 and // sum(t)-n1 with tie vector t and accumulate these counts by // their U statistics in count[2*U]. - counts := make([]int, 1+2*n1*(sumint(t)-n1)) + counts := make([]int, 1+2*n1*(sumint(tVar)-n1)) - u := make([]int, len(t)) + u := make([]int, len(tVar)) u[0] = -1 // Get enumeration started. enumu: for { // Compute the next u vector. u[0]++ - for i := 0; i < len(u) && u[i] > t[i]; i++ { + for i := 0; i < len(u) && u[i] > tVar[i]; i++ { if i == len(u)-1 { // All u vectors have been enumerated. break enumu @@ -282,18 +289,18 @@ enumu: // Compute 2*U statistic for this u vector. twoU, vsum := 0, 0 - for i, u_i := range u { - v_i := t[i] - u_i - // U = U + vsum*u_i + u_i*v_i/2 - twoU += 2*vsum*u_i + u_i*v_i - vsum += v_i + for i, ui := range u { + vi := tVar[i] - ui + // U = U + vsum*ui + ui*vi/2 + twoU += 2*vsum*ui + ui*vi + vsum += vi } - // Compute Π choose(t_i, u_i). This is the number of + // Compute Π choose(tVari, ui). This is the number of // ways of permuting the input sample under u. prod := 1 - for i, u_i := range u { - prod *= int(mathChoose(t[i], u_i) + 0.5) + for i, ui := range u { + prod *= int(mathChoose(tVar[i], ui) + 0.5) } // Accumulate the permutations on this u path. @@ -313,7 +320,7 @@ enumu: // Convert counts into probabilities for PMF and CDF. pmf = make([]float64, len(counts)) cdf = make([]float64, len(counts)) - total := int(mathChoose(sumint(t), n1) + 0.5) + total := int(mathChoose(sumint(tVar), n1) + 0.5) for i, count := range counts { pmf[i] = float64(count) / float64(total) if i > 0 { @@ -325,11 +332,13 @@ enumu: } // printUmemo prints the output of makeUmemo for debugging. -func printUmemo(A []map[ukey]float64, t []int) { +func printUmemo(t *testing.T, A []map[ukey]float64, tVar []int) { + t.Helper() + fmt.Printf("K\tn1\t2*U\tpr\n") for K := len(A) - 1; K >= 0; K-- { for i, pr := range A[K] { - _, ref := udistRef(i.n1, t[:K]) + _, ref := udistRef(t, i.n1, tVar[:K]) fmt.Printf("%v\t%v\t%v\t%v\t%v\n", K, i.n1, i.twoU, pr, ref[i.twoU]) } } diff --git a/pkg/app/piped/executor/analysis/mannwhitney/util_test.go b/pkg/app/piped/executor/analysis/mannwhitney/util_test.go index a4f6a8ce96..c1411e8ddb 100644 --- a/pkg/app/piped/executor/analysis/mannwhitney/util_test.go +++ b/pkg/app/piped/executor/analysis/mannwhitney/util_test.go @@ -27,6 +27,8 @@ import ( ) func testDiscreteCDF(t *testing.T, name string, dist DiscreteDist) { + t.Parallel() + // Build the expected CDF out of the PMF. l, h := dist.Bounds() s := dist.Step() @@ -42,6 +44,8 @@ func testDiscreteCDF(t *testing.T, name string, dist DiscreteDist) { } func testInvCDF(t *testing.T, dist Dist, bounded bool) { + t.Parallel() + inv := InvCDF(dist) name := fmt.Sprintf("InvCDF(%+v)", dist) cdfName := fmt.Sprintf("CDF(%+v)", dist) @@ -71,7 +75,7 @@ func testInvCDF(t *testing.T, dist Dist, bounded bool) { // Test points between. vals = map[float64]float64{} - for _, p := range vecLinspace(0, 1, 11) { + for _, p := range vecLinspace(t, 0, 1, 11) { if p == 0 || p == 1 { continue } @@ -87,7 +91,9 @@ func testInvCDF(t *testing.T, dist Dist, bounded bool) { // aeq returns true if expect and got are equal to 8 significant // figures (1 part in 100 million). -func aeq(expect, got float64) bool { +func aeq(t *testing.T, expect, got float64) bool { + t.Helper() + if expect < 0 && got < 0 { expect, got = -expect, -got } @@ -95,6 +101,8 @@ func aeq(expect, got float64) bool { } func testFunc(t *testing.T, name string, f func(float64) float64, vals map[float64]float64) { + t.Parallel() + xs := make([]float64, 0, len(vals)) for x := range vals { xs = append(xs, x) @@ -103,7 +111,7 @@ func testFunc(t *testing.T, name string, f func(float64) float64, vals map[float for _, x := range xs { want, got := vals[x], f(x) - if math.IsNaN(want) && math.IsNaN(got) || aeq(want, got) { + if math.IsNaN(want) && math.IsNaN(got) || aeq(t, want, got) { continue } var label string @@ -118,7 +126,9 @@ func testFunc(t *testing.T, name string, f func(float64) float64, vals map[float // vecLinspace returns num values spaced evenly between lo and hi, // inclusive. If num is 1, this returns an array consisting of lo. -func vecLinspace(lo, hi float64, num int) []float64 { +func vecLinspace(t *testing.T, lo, hi float64, num int) []float64 { + t.Helper() + res := make([]float64, num) if num == 1 { res[0] = lo diff --git a/pkg/app/piped/executor/analysis/metrics_analyzer_test.go b/pkg/app/piped/executor/analysis/metrics_analyzer_test.go index af61042ab3..48dcd6890f 100644 --- a/pkg/app/piped/executor/analysis/metrics_analyzer_test.go +++ b/pkg/app/piped/executor/analysis/metrics_analyzer_test.go @@ -49,6 +49,8 @@ func (l *fakeLogPersister) Errorf(_ string, _ ...interface{}) {} func floatToPointer(n float64) *float64 { return &n } func Test_metricsAnalyzer_analyzeWithThreshold(t *testing.T) { + t.Parallel() + testcases := []struct { name string metricsAnalyzer *metricsAnalyzer @@ -137,6 +139,8 @@ func Test_metricsAnalyzer_analyzeWithThreshold(t *testing.T) { } func Test_compare(t *testing.T) { + t.Parallel() + type args struct { experiment []float64 control []float64 @@ -229,6 +233,8 @@ func Test_compare(t *testing.T) { } func Test_metricsAnalyzer_renderQuery(t *testing.T) { + t.Parallel() + type args struct { queryTemplate string variantCustomArgs map[string]string diff --git a/pkg/app/piped/executor/cloudrun/cloudrun_test.go b/pkg/app/piped/executor/cloudrun/cloudrun_test.go index 1811862c54..fb284683cb 100644 --- a/pkg/app/piped/executor/cloudrun/cloudrun_test.go +++ b/pkg/app/piped/executor/cloudrun/cloudrun_test.go @@ -58,6 +58,8 @@ spec: ` func TestAddBuiltinLabels(t *testing.T) { + t.Parallel() + var ( hash = "commit-hash" pipedID = "piped-id" diff --git a/pkg/app/piped/executor/kubernetes/canary_test.go b/pkg/app/piped/executor/kubernetes/canary_test.go index 69e15e8cc3..9c45178804 100644 --- a/pkg/app/piped/executor/kubernetes/canary_test.go +++ b/pkg/app/piped/executor/kubernetes/canary_test.go @@ -34,6 +34,8 @@ import ( ) func TestEnsureCanaryRollout(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() diff --git a/pkg/app/piped/executor/kubernetes/kubernetes_test.go b/pkg/app/piped/executor/kubernetes/kubernetes_test.go index cc84d8e7b2..344b62b64c 100644 --- a/pkg/app/piped/executor/kubernetes/kubernetes_test.go +++ b/pkg/app/piped/executor/kubernetes/kubernetes_test.go @@ -63,6 +63,8 @@ func (m *fakeMetadataStageStore) Put(_ context.Context, _, _ string) error func (m *fakeMetadataStageStore) PutMulti(_ context.Context, _ map[string]string) error { return nil } func TestGenerateServiceManifests(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifestsFile string @@ -88,6 +90,8 @@ func TestGenerateServiceManifests(t *testing.T) { } func TestGenerateVariantWorkloadManifests(t *testing.T) { + t.Parallel() + const ( variantLabel = "pipecd.dev/variant" canaryVariant = "canary-variant" @@ -146,6 +150,8 @@ func TestGenerateVariantWorkloadManifests(t *testing.T) { } func TestCheckVariantSelectorInWorkload(t *testing.T) { + t.Parallel() + const ( variantLabel = "pipecd.dev/variant" primaryVariant = "primary" @@ -291,6 +297,8 @@ spec: } func TestApplyManifests(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) testcases := []struct { @@ -469,6 +477,8 @@ spec: } func TestDeleteResources(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) testcases := []struct { @@ -535,6 +545,8 @@ func TestDeleteResources(t *testing.T) { } func TestAnnotateConfigHash(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests string @@ -768,6 +780,8 @@ data: } func TestPatchManifest(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests string @@ -877,6 +891,8 @@ func TestPatchManifest(t *testing.T) { } func TestPatchManifests(t *testing.T) { + t.Parallel() + testcases := []struct { name string input []provider.Manifest diff --git a/pkg/app/piped/executor/kubernetes/primary_test.go b/pkg/app/piped/executor/kubernetes/primary_test.go index dc1f598347..d2955b170d 100644 --- a/pkg/app/piped/executor/kubernetes/primary_test.go +++ b/pkg/app/piped/executor/kubernetes/primary_test.go @@ -34,6 +34,8 @@ import ( ) func TestEnsurePrimaryRollout(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -296,6 +298,7 @@ func TestEnsurePrimaryRollout(t *testing.T) { } for _, tc := range testcases { t.Run(tc.name, func(t *testing.T) { + ctx := context.Background() got := tc.executor.ensurePrimaryRollout(ctx) assert.Equal(t, tc.want, got) @@ -304,6 +307,8 @@ func TestEnsurePrimaryRollout(t *testing.T) { } func TestFindRemoveManifests(t *testing.T) { + t.Parallel() + tests := []struct { name string prevs []provider.Manifest diff --git a/pkg/app/piped/executor/kubernetes/sync_test.go b/pkg/app/piped/executor/kubernetes/sync_test.go index 28d39c1e20..465f81d5df 100644 --- a/pkg/app/piped/executor/kubernetes/sync_test.go +++ b/pkg/app/piped/executor/kubernetes/sync_test.go @@ -34,6 +34,8 @@ import ( ) func TestEnsureSync(t *testing.T) { + t.Parallel() + ctrl := gomock.NewController(t) defer ctrl.Finish() @@ -159,6 +161,8 @@ func TestEnsureSync(t *testing.T) { } func TestFindRemoveResources(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests []provider.Manifest diff --git a/pkg/app/piped/executor/kubernetes/traffic_test.go b/pkg/app/piped/executor/kubernetes/traffic_test.go index f30964877f..5851f0a47c 100644 --- a/pkg/app/piped/executor/kubernetes/traffic_test.go +++ b/pkg/app/piped/executor/kubernetes/traffic_test.go @@ -26,6 +26,8 @@ import ( ) func TestGenerateVirtualServiceManifest(t *testing.T) { + t.Parallel() + exec := &deployExecutor{ appCfg: &config.KubernetesApplicationSpec{ VariantLabel: config.KubernetesVariantLabel{ @@ -78,6 +80,8 @@ func TestGenerateVirtualServiceManifest(t *testing.T) { } func TestCheckVariantSelectorInService(t *testing.T) { + t.Parallel() + const ( variantLabel = "pipecd.dev/variant" primaryVariant = "primary" diff --git a/pkg/app/piped/executor/lambda/lambda_test.go b/pkg/app/piped/executor/lambda/lambda_test.go index 165af146a2..c4d8ea988f 100644 --- a/pkg/app/piped/executor/lambda/lambda_test.go +++ b/pkg/app/piped/executor/lambda/lambda_test.go @@ -27,6 +27,8 @@ import ( ) func TestConfigureTrafficRouting(t *testing.T) { + t.Parallel() + testcases := []struct { name string version string @@ -171,6 +173,8 @@ func (g *fakeGitClient) Clone(_ context.Context, _, _, _, _ string) (git.Repo, e } func TestPrepareZipFromSource(t *testing.T) { + t.Parallel() + gc := &fakeGitClient{ repo: &fakeRepo{ source: "testdata/raw", diff --git a/pkg/app/piped/executor/terraform/BUILD.bazel b/pkg/app/piped/executor/terraform/BUILD.bazel index 7ab118a290..6b6b7bc21f 100644 --- a/pkg/app/piped/executor/terraform/BUILD.bazel +++ b/pkg/app/piped/executor/terraform/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -17,10 +17,3 @@ go_library( "//pkg/model:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["terraform_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/executor/terraform/terraform_test.go b/pkg/app/piped/executor/terraform/terraform_test.go deleted file mode 100644 index b2dcb81a31..0000000000 --- a/pkg/app/piped/executor/terraform/terraform_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package terraform diff --git a/pkg/app/piped/executor/waitapproval/waitapproval_test.go b/pkg/app/piped/executor/waitapproval/waitapproval_test.go index 0c7177d456..0d99e372f1 100644 --- a/pkg/app/piped/executor/waitapproval/waitapproval_test.go +++ b/pkg/app/piped/executor/waitapproval/waitapproval_test.go @@ -74,6 +74,8 @@ type fakeNotifier struct{} func (n *fakeNotifier) Notify(_ model.NotificationEvent) {} func TestValidateApproverNum(t *testing.T) { + t.Parallel() + ctx := context.Background() ac := &fakeAPIClient{ diff --git a/pkg/app/piped/livestatestore/kubernetes/reflector_test.go b/pkg/app/piped/livestatestore/kubernetes/reflector_test.go index 7147abda2a..6994396b69 100644 --- a/pkg/app/piped/livestatestore/kubernetes/reflector_test.go +++ b/pkg/app/piped/livestatestore/kubernetes/reflector_test.go @@ -25,6 +25,8 @@ import ( ) func TestResourceMatcher(t *testing.T) { + t.Parallel() + testcases := []struct { name string cfg config.KubernetesAppStateInformer @@ -71,10 +73,14 @@ func TestResourceMatcher(t *testing.T) { } for _, tc := range testcases { + tc := tc m := newResourceMatcher(tc.cfg) for gvk, expected := range tc.gvks { desc := fmt.Sprintf("%s: %v", tc.name, gvk) + gvk, expected := gvk, expected t.Run(desc, func(t *testing.T) { + t.Parallel() + matched := m.Match(gvk) assert.Equal(t, expected, matched) }) diff --git a/pkg/app/piped/logpersister/persister_test.go b/pkg/app/piped/logpersister/persister_test.go index 82e6170bc9..22ef642f6e 100644 --- a/pkg/app/piped/logpersister/persister_test.go +++ b/pkg/app/piped/logpersister/persister_test.go @@ -51,6 +51,8 @@ func (c *fakeAPIClient) NumberOfReportStageLogsFromLastCheckpoint() int { } func TestPersister(t *testing.T) { + t.Parallel() + apiClient := &fakeAPIClient{} p := NewPersister(apiClient, zap.NewNop()) p.stalePeriod = 0 diff --git a/pkg/app/piped/metadatastore/store_test.go b/pkg/app/piped/metadatastore/store_test.go index d50ba61558..51c6bab0ae 100644 --- a/pkg/app/piped/metadatastore/store_test.go +++ b/pkg/app/piped/metadatastore/store_test.go @@ -56,6 +56,8 @@ func (c *fakeAPIClient) SaveStageMetadata(ctx context.Context, req *pipedservice } func TestStore(t *testing.T) { + t.Parallel() + ac := &fakeAPIClient{ shared: make(map[string]string, 0), stages: make(map[string]metadata, 0), diff --git a/pkg/app/piped/notifier/matcher_test.go b/pkg/app/piped/notifier/matcher_test.go index 5b5bc88820..ab127c4058 100644 --- a/pkg/app/piped/notifier/matcher_test.go +++ b/pkg/app/piped/notifier/matcher_test.go @@ -24,6 +24,8 @@ import ( ) func TestMatch(t *testing.T) { + t.Parallel() + testcases := []struct { name string config config.NotificationRoute diff --git a/pkg/app/piped/planner/ecs/pipeline_test.go b/pkg/app/piped/planner/ecs/pipeline_test.go index b273cf7379..489e084798 100644 --- a/pkg/app/piped/planner/ecs/pipeline_test.go +++ b/pkg/app/piped/planner/ecs/pipeline_test.go @@ -10,6 +10,8 @@ import ( ) func TestBuildQuickSyncPipeline(t *testing.T) { + t.Parallel() + tests := []struct { name string wantAutoRollback bool diff --git a/pkg/app/piped/planner/kubernetes/kubernetes_test.go b/pkg/app/piped/planner/kubernetes/kubernetes_test.go index 816864372d..db09eeb813 100644 --- a/pkg/app/piped/planner/kubernetes/kubernetes_test.go +++ b/pkg/app/piped/planner/kubernetes/kubernetes_test.go @@ -13,6 +13,8 @@ import ( ) func TestDecideStrategy(t *testing.T) { + t.Parallel() + tests := []struct { name string olds []provider.Manifest @@ -399,6 +401,8 @@ func TestDecideStrategy(t *testing.T) { } func TestDetermineVersion(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests string @@ -440,6 +444,8 @@ func TestDetermineVersion(t *testing.T) { } func TestDetermineVersions(t *testing.T) { + t.Parallel() + testcases := []struct { name string manifests string @@ -526,6 +532,8 @@ func TestDetermineVersions(t *testing.T) { } func TestCheckImageChange(t *testing.T) { + t.Parallel() + testcases := []struct { name string oldManifests string diff --git a/pkg/app/piped/planner/kubernetes/pipeline_test.go b/pkg/app/piped/planner/kubernetes/pipeline_test.go index 427477d919..78254dc8ef 100644 --- a/pkg/app/piped/planner/kubernetes/pipeline_test.go +++ b/pkg/app/piped/planner/kubernetes/pipeline_test.go @@ -11,6 +11,8 @@ import ( ) func TestBuildQuickSyncPipeline(t *testing.T) { + t.Parallel() + tests := []struct { name string wantAutoRollback bool @@ -39,6 +41,8 @@ func TestBuildQuickSyncPipeline(t *testing.T) { } func TestBuildProgressivePipeline(t *testing.T) { + t.Parallel() + tests := []struct { name string wantAutoRollback bool diff --git a/pkg/app/piped/planpreview/BUILD.bazel b/pkg/app/piped/planpreview/BUILD.bazel index 71c5ce62cc..bfc980516d 100644 --- a/pkg/app/piped/planpreview/BUILD.bazel +++ b/pkg/app/piped/planpreview/BUILD.bazel @@ -37,10 +37,7 @@ go_library( go_test( name = "go_default_test", size = "small", - srcs = [ - "builder_test.go", - "handler_test.go", - ], + srcs = ["handler_test.go"], embed = [":go_default_library"], deps = [ "//pkg/model:go_default_library", diff --git a/pkg/app/piped/planpreview/builder_test.go b/pkg/app/piped/planpreview/builder_test.go deleted file mode 100644 index 471c861fcb..0000000000 --- a/pkg/app/piped/planpreview/builder_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2021 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package planpreview diff --git a/pkg/app/piped/planpreview/handler_test.go b/pkg/app/piped/planpreview/handler_test.go index 914f913495..67f44c6215 100644 --- a/pkg/app/piped/planpreview/handler_test.go +++ b/pkg/app/piped/planpreview/handler_test.go @@ -53,6 +53,8 @@ func (b *testBuilder) Build(ctx context.Context, id string, cmd model.Command_Bu } func TestHandler(t *testing.T) { + t.Parallel() + ctx, cancel := context.WithCancel(context.Background()) defer cancel() diff --git a/pkg/app/piped/sourcedecrypter/decrypter_test.go b/pkg/app/piped/sourcedecrypter/decrypter_test.go index 5d7a0c622b..e6aeee18b0 100644 --- a/pkg/app/piped/sourcedecrypter/decrypter_test.go +++ b/pkg/app/piped/sourcedecrypter/decrypter_test.go @@ -36,10 +36,13 @@ func (d testSecretDecrypter) Decrypt(text string) (string, error) { } func TestDecryptSecrets(t *testing.T) { + t.Parallel() + workspace, err := os.MkdirTemp("", "test-decrypt-secrets") require.NoError(t, err) - defer os.RemoveAll(workspace) - + t.Cleanup(func() { + os.RemoveAll(workspace) + }) dcr := testSecretDecrypter{ prefix: "decrypted-", } diff --git a/pkg/app/piped/statsreporter/BUILD.bazel b/pkg/app/piped/statsreporter/BUILD.bazel index 6af640bb6d..2b3b1fc860 100644 --- a/pkg/app/piped/statsreporter/BUILD.bazel +++ b/pkg/app/piped/statsreporter/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -11,11 +11,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["reporter_test.go"], - data = glob(["testdata/**"]), - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/statsreporter/reporter_test.go b/pkg/app/piped/statsreporter/reporter_test.go deleted file mode 100644 index 1ef9afc9d5..0000000000 --- a/pkg/app/piped/statsreporter/reporter_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package statsreporter diff --git a/pkg/app/piped/toolregistry/BUILD.bazel b/pkg/app/piped/toolregistry/BUILD.bazel index a4cb331c2f..a61a9656d9 100644 --- a/pkg/app/piped/toolregistry/BUILD.bazel +++ b/pkg/app/piped/toolregistry/BUILD.bazel @@ -1,4 +1,4 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") +load("@io_bazel_rules_go//go:def.bzl", "go_library") go_library( name = "go_default_library", @@ -15,10 +15,3 @@ go_library( "@org_uber_go_zap//:go_default_library", ], ) - -go_test( - name = "go_default_test", - size = "small", - srcs = ["registry_test.go"], - embed = [":go_default_library"], -) diff --git a/pkg/app/piped/toolregistry/registry_test.go b/pkg/app/piped/toolregistry/registry_test.go deleted file mode 100644 index 1797605e16..0000000000 --- a/pkg/app/piped/toolregistry/registry_test.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright 2020 The PipeCD Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package toolregistry diff --git a/pkg/app/piped/trigger/determiner_test.go b/pkg/app/piped/trigger/determiner_test.go index 8ad5d19e9c..4e67219dd9 100644 --- a/pkg/app/piped/trigger/determiner_test.go +++ b/pkg/app/piped/trigger/determiner_test.go @@ -21,6 +21,8 @@ import ( ) func TestIsTouchedByChangedFiles(t *testing.T) { + t.Parallel() + testcases := []struct { name string appDir string