Skip to content

Commit

Permalink
fix: run provider tests in parallel
Browse files Browse the repository at this point in the history
Also skip provider tests if -short flag is used.
  • Loading branch information
wallyworld committed Jul 4, 2024
1 parent ca1da69 commit 11ae8dc
Show file tree
Hide file tree
Showing 17 changed files with 248 additions and 2 deletions.
10 changes: 10 additions & 0 deletions internal/provider/data_source_machine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func TestAcc_DataSourceMachine_Edge(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-datasource-machine-test-model")

resource.Test(t, resource.TestCase{
Expand All @@ -35,6 +40,11 @@ func TestAcc_DataSourceMachine_Stable(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-datasource-machine-test-model")

resource.Test(t, resource.TestCase{
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
)

func TestAcc_DataSourceModel_Edge(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-datasource-model-test")

resource.Test(t, resource.TestCase{
Expand All @@ -30,6 +35,11 @@ func TestAcc_DataSourceModel_Edge(t *testing.T) {
}

func TestAcc_DataSourceModel_Stable(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-datasource-model-test")

resource.Test(t, resource.TestCase{
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/data_source_offer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ import (
)

func TestAcc_DataSourceOffer(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-datasource-offer-test-model")
// ...-test-[0-9]+ is not a valid offer name, need to remove the dash before numbers
offerName := fmt.Sprintf("tf-datasource-offer-test%d", acctest.RandInt())
Expand All @@ -32,6 +37,11 @@ func TestAcc_DataSourceOffer(t *testing.T) {
}

func TestAcc_DataSourceOffer_UpgradeProvider(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-datasource-offer-test-model")
// ...-test-[0-9]+ is not a valid offer name, need to remove the dash before numbers
offerName := fmt.Sprintf("tf-datasource-offer-test%d", acctest.RandInt())
Expand Down
5 changes: 5 additions & 0 deletions internal/provider/data_source_secrets_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import (
// blocked on the lack of schema for secret access.

func TestAcc_DataSourceSecret(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

version := os.Getenv("JUJU_AGENT_VERSION")
if version == "" || internaltesting.CompareVersions(version, "3.3.0") < 0 {
t.Skip("JUJU_AGENT_VERSION is not set or is below 3.3.0")
Expand Down
4 changes: 2 additions & 2 deletions internal/provider/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ package provider
// in the testing phase.

import (
"errors"
"fmt"
"net"
"os"
"strings"
Expand Down Expand Up @@ -59,7 +59,7 @@ func TypeTestingCloudFromString(from string) (CloudTesting, error) {
case string(MicroK8sTesting):
return MicroK8sTesting, nil
default:
return "", errors.New("unknown cloud type")
return "", fmt.Errorf("unknown cloud type %q", from)
}
}

Expand Down
9 changes: 9 additions & 0 deletions internal/provider/resource_access_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ import (
)

func TestAcc_ResourceAccessModel(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

userName := acctest.RandomWithPrefix("tfuser")
userPassword := acctest.RandomWithPrefix("tf-test-user")
userName2 := acctest.RandomWithPrefix("tfuser")
Expand Down Expand Up @@ -70,6 +75,10 @@ func TestAcc_ResourceAccessModel_UpgradeProvider(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

userName := acctest.RandomWithPrefix("tfuser")
userPassword := acctest.RandomWithPrefix("tf-test-user")
Expand Down
10 changes: 10 additions & 0 deletions internal/provider/resource_access_secret_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ import (
// the applications used don't actually require a user secret.
// TODO(anvial): Add a test that uses a secret that is actually required by the application.
func TestAcc_ResourceAccessSecret_GrantRevoke(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

agentVersion := os.Getenv(TestJujuAgentVersion)
if agentVersion == "" {
t.Errorf("%s is not set", TestJujuAgentVersion)
Expand Down Expand Up @@ -58,6 +63,11 @@ func TestAcc_ResourceAccessSecret_GrantRevoke(t *testing.T) {
}

func TestAcc_ResourceAccessSecret_Import(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

agentVersion := os.Getenv(TestJujuAgentVersion)
if agentVersion == "" {
t.Errorf("%s is not set", TestJujuAgentVersion)
Expand Down
60 changes: 60 additions & 0 deletions internal/provider/resource_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ import (
)

func TestAcc_ResourceApplication(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application")
appName := "test-app"

Expand Down Expand Up @@ -89,6 +94,11 @@ func TestAcc_ResourceApplication(t *testing.T) {
}

func TestAcc_ResourceApplication_Updates(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application")
appName := "jameinel-ubuntu-lite"
if testingCloud != LXDCloudTesting {
Expand Down Expand Up @@ -155,6 +165,11 @@ func TestAcc_ResourceApplication_UpdatesRevisionConfig(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application")
appName := "github-runner"
configParamName := "runner-storage"
Expand Down Expand Up @@ -183,6 +198,11 @@ func TestAcc_ResourceApplication_UpdatesRevisionConfig(t *testing.T) {
}

func TestAcc_CharmUpdates(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-charmupdates")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -217,6 +237,11 @@ func TestAcc_ResourceRevisionUpdatesLXD(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-resource-revision-updates-lxd")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -251,6 +276,11 @@ func TestAcc_ResourceRevisionAddedToPlanLXD(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-resource-revision-updates-lxd")

resource.Test(t, resource.TestCase{
Expand All @@ -277,6 +307,11 @@ func TestAcc_ResourceRevisionRemovedFromPlanLXD(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-resource-revision-updates-lxd")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -305,6 +340,11 @@ func TestAcc_ResourceRevisionUpdatesMicrok8s(t *testing.T) {
if testingCloud != MicroK8sTesting {
t.Skip(t.Name() + " only runs with Microk8s")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-resource-revision-updates-microk8s")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -336,6 +376,11 @@ func TestAcc_ResourceRevisionUpdatesMicrok8s(t *testing.T) {
}

func TestAcc_ResourceApplication_Minimal(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application")
var charmName string
if testingCloud == LXDCloudTesting {
Expand Down Expand Up @@ -373,6 +418,11 @@ func TestAcc_ResourceApplication_Minimal(t *testing.T) {
}

func TestAcc_ResourceApplication_UpgradeProvider(t *testing.T) {
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application")
appName := "test-app"

Expand Down Expand Up @@ -410,6 +460,11 @@ func TestAcc_ResourceApplication_EndpointBindings(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application-bindings")
appName := "test-app"

Expand Down Expand Up @@ -445,6 +500,11 @@ func TestAcc_ResourceApplication_UpdateEndpointBindings(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-application-bindings-update")
appName := "test-app-update"

Expand Down
10 changes: 10 additions & 0 deletions internal/provider/resource_credential_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ func TestAcc_ResourceCredential(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

credentialName := acctest.RandomWithPrefix("tf-test-credential")
authType := "certificate"
token := "123abc"
Expand Down Expand Up @@ -57,6 +62,11 @@ func TestAcc_ResourceCredential_UpgradeProvider(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

credentialName := acctest.RandomWithPrefix("tf-test-credential")
authType := "certificate"

Expand Down
20 changes: 20 additions & 0 deletions internal/provider/resource_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ func TestAcc_ResourceIntegration(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-integration")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -54,6 +59,11 @@ func TestAcc_ResourceIntegrationWithViaCIDRs(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

srcModelName := acctest.RandomWithPrefix("tf-test-integration")
dstModelName := acctest.RandomWithPrefix("tf-test-integration-dst")
via := "127.0.0.1/32,127.0.0.3/32"
Expand Down Expand Up @@ -81,6 +91,11 @@ func TestAcc_ResourceIntegration_UpgradeProvider(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

modelName := acctest.RandomWithPrefix("tf-test-integration")

resource.Test(t, resource.TestCase{
Expand Down Expand Up @@ -216,6 +231,11 @@ func TestAcc_ResourceIntegrationWithMultipleConsumers(t *testing.T) {
if testingCloud != LXDCloudTesting {
t.Skip(t.Name() + " only runs with LXD")
}
if testing.Short() {
t.Skip()
}
t.Parallel()

srcModelName := acctest.RandomWithPrefix("tf-test-integration")
dstModelName := acctest.RandomWithPrefix("tf-test-integration-dst")

Expand Down
Loading

0 comments on commit 11ae8dc

Please sign in to comment.