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 a14a1ed commit 8151962
Show file tree
Hide file tree
Showing 17 changed files with 247 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
59 changes: 59 additions & 0 deletions internal/provider/resource_application_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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 @@ -90,6 +95,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 @@ -162,6 +172,10 @@ 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"
Expand Down Expand Up @@ -192,6 +206,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 @@ -226,6 +245,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 @@ -260,6 +284,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 @@ -286,6 +315,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 @@ -314,6 +348,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 @@ -345,6 +384,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 @@ -382,6 +426,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 @@ -419,6 +468,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 @@ -454,6 +508,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 8151962

Please sign in to comment.