Skip to content

Commit

Permalink
Partition provider test by language
Browse files Browse the repository at this point in the history
Use inverted Go build flags to not disable test by default.
  • Loading branch information
t0yv0 committed Oct 23, 2023
1 parent 72c2ae0 commit abcfe47
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 63 deletions.
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ test_provider:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_provider:: awsx/node_modules bin/${PROVIDER}
cd awsx && yarn test
@export PATH
cd provider && go test -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd provider && go test -tags=yaml -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt

istanbul_tests::
cd awsx-classic/tests && \
Expand All @@ -178,26 +178,31 @@ istanbul_tests::
test_nodejs:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_nodejs:: bin/${PROVIDER} install_nodejs_sdk
@export PATH
cd provider && go test -tags=nodejs -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -tags=nodejs -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt

test_python:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_python:: bin/${PROVIDER}
@export PATH
cd provider && go test -tags=python -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -tags=python -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt

test_java:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_java:: bin/${PROVIDER}
@export PATH
cd provider && go test -tags=java -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -tags=java -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt

test_go:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_go:: bin/${PROVIDER}
@export PATH
cd provider && go test -tags=go -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -tags=go -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt

test_dotnet:: PATH := $(WORKING_DIR)/bin:$(PATH)
test_dotnet:: bin/${PROVIDER} install_dotnet_sdk
@export PATH
cd provider && go test -tags=dotnet -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt
cd examples && go test -tags=dotnet -v -json -count=1 -cover -timeout 3h -parallel ${TESTPARALLELISM} . 2>&1 | tee /tmp/gotest.log | gotestfmt

test:: PATH := $(WORKING_DIR)/bin:$(PATH)
Expand Down
87 changes: 87 additions & 0 deletions provider/provider_nodejs_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
//go:build !go && !yaml && !python && !java && !dotnet
// +build !go,!yaml,!python,!java,!dotnet

// Copyright 2016-2023, Pulumi Corporation.
//
// 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 provider

import (
"path/filepath"
"testing"

"github.com/pulumi/providertest"
)

// Quick tests to validate the provider behavior against the example programs.
//
// Of specific interest are upgrade tests that check for lack of replacements when upgrading stacks
// from a baseline to the current version of the provider.
func TestExamples(t *testing.T) {
t.Skipf("Skip temporarily")

examples := []string{
"ts-nlb-simple",

// Skipping because recording locally keeps timing out after 20 min; should be possible though?
// "ts-lb-simple",

// Skipping because it does not work on pre-2.x versions, so upgrade tests cannot run.
// "ts-vpc-getDefaultVpc", // Property 'vpc' does not exist
// "ts-ecr-simple",

// Still need to try recording these:
//
// "ts-lb-with-subnets",
// "ts-lb-attach-lambda",
// "ts-lb-attach-ec2",

// NOTE: the automatically picked recording example will be "nodejs" which conflicts
// with "cloudtrail/nodejs", this needs to be fixed in providertests.
"ecs/nodejs",

"cloudtrail/nodejs",

// "vpc/nodejs/custom-provider",
// "vpc/nodejs/specific-vpc-layout",
// "vpc/nodejs/vpc-with-service-endpoint",
"vpc/nodejs/default-args",
// "vpc/nodejs/vpc-multiple-similar-subnet-types",
// "vpc/nodejs/vpc-subnets-with-tags",
}

for _, ex := range examples {
dir := filepath.Join("..", "examples", ex)
t.Run(ex, test(dir).Run)
}

}

func test(dir string, opts ...providertest.Option) *providertest.ProviderTest {
opts = append(opts,
providertest.WithProviderName("awsx"),

providertest.WithSkippedUpgradeTestMode(
providertest.UpgradeTestMode_Quick,
"Quick mode is only supported for providers written in Go at the moment"),

providertest.WithBaselineVersion("1.0.6"),

providertest.WithExtraBaselineDependencies(map[string]string{
"aws": "5.42.0",
}),
)

return providertest.NewProviderTest(dir, opts...)
}
63 changes: 1 addition & 62 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// 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
// 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,
Expand All @@ -15,72 +15,11 @@
package provider

import (
"path/filepath"
"testing"

"github.com/pulumi/providertest"
)

// Quick tests to validate the provider behavior against the example programs.
//
// Of specific interest are upgrade tests that check for lack of replacements when upgrading stacks
// from a baseline to the current version of the provider.
func TestExamples(t *testing.T) {
examples := []string{
"ts-nlb-simple",

// Skipping because recording locally keeps timing out after 20 min; should be possible though?
// "ts-lb-simple",

// Skipping because it does not work on pre-2.x versions, so upgrade tests cannot run.
// "ts-vpc-getDefaultVpc", // Property 'vpc' does not exist
// "ts-ecr-simple",

// Still need to try recording these:
//
// "ts-lb-with-subnets",
// "ts-lb-attach-lambda",
// "ts-lb-attach-ec2",

// NOTE: the automatically picked recording example will be "nodejs" which conflicts
// with "cloudtrail/nodejs", this needs to be fixed in providertests.
"ecs/nodejs",

"cloudtrail/nodejs",

// "vpc/nodejs/custom-provider",
// "vpc/nodejs/specific-vpc-layout",
// "vpc/nodejs/vpc-with-service-endpoint",
"vpc/nodejs/default-args",
// "vpc/nodejs/vpc-multiple-similar-subnet-types",
// "vpc/nodejs/vpc-subnets-with-tags",
}

for _, ex := range examples {
dir := filepath.Join("..", "examples", ex)
t.Run(ex, test(dir).Run)
}

}

func test(dir string, opts ...providertest.Option) *providertest.ProviderTest {
opts = append(opts,
providertest.WithProviderName("awsx"),

providertest.WithSkippedUpgradeTestMode(
providertest.UpgradeTestMode_Quick,
"Quick mode is only supported for providers written in Go at the moment"),

providertest.WithBaselineVersion("1.0.6"),

providertest.WithExtraBaselineDependencies(map[string]string{
"aws": "5.42.0",
}),
)

return providertest.NewProviderTest(dir, opts...)
}

func TestReportUpgradeCoverage(t *testing.T) {
providertest.ReportUpgradeCoverage(t)
}

0 comments on commit abcfe47

Please sign in to comment.