Skip to content

Commit

Permalink
v0.0.11 - Parallel creation of resources
Browse files Browse the repository at this point in the history
* Update libs to version v0.0.1 with modification to use Mutex to ensure ResourceManager initialization is thread-safe
  • Loading branch information
evanverneyfink committed Apr 8, 2022
1 parent 7924cf4 commit c7a2aea
Show file tree
Hide file tree
Showing 3 changed files with 94 additions and 6 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/ebu/terraform-provider-mcma
go 1.18

require (
github.com/ebu/mcma-libraries-go v0.0.0-20220405141242-616cfd9dac21
github.com/ebu/mcma-libraries-go v0.0.1
github.com/hashicorp/terraform-plugin-docs v0.7.0
github.com/hashicorp/terraform-plugin-sdk/v2 v2.13.0
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/ebu/mcma-libraries-go v0.0.0-20220405141242-616cfd9dac21 h1:cAf1Ut/grsCzjZ5WXG+NI0LXlzff7ITMFexETs43QYI=
github.com/ebu/mcma-libraries-go v0.0.0-20220405141242-616cfd9dac21/go.mod h1:RnT/sTbg7ICp6NHDxyj/xX9xI+bqbcm9SUkPTIJnqs4=
github.com/ebu/mcma-libraries-go v0.0.1 h1:VR5ZuZu9p+vcPug+lfQB88SEQ4UyNbPODT5oTeIscPQ=
github.com/ebu/mcma-libraries-go v0.0.1/go.mod h1:RnT/sTbg7ICp6NHDxyj/xX9xI+bqbcm9SUkPTIJnqs4=
github.com/emirpasic/gods v1.12.0 h1:QAUIPSaCu4G+POclxeqb3F+WPpdKqFGlw36+yOzGlrg=
github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3ymbK86o=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down
96 changes: 91 additions & 5 deletions mcma/resource_job_profile_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
)

func TestAccMcmaJobProfile_basic(t *testing.T) {
var jobProfile mcmamodel.JobProfile
profileName := acctest.RandStringFromCharSet(5, acctest.CharSetAlpha)
createTestCase := func(providerConfig string) resource.TestCase {
return resource.TestCase{
Expand All @@ -25,7 +24,15 @@ func TestAccMcmaJobProfile_basic(t *testing.T) {
{
Config: testAccountMcmaJobProfile(profileName, providerConfig),
Check: resource.ComposeTestCheckFunc(
testAccCheckJobProfileExists("mcma_job_profile.job_profile_"+profileName, &jobProfile),
testAccCheckJobProfileExists("mcma_job_profile.job_profile_" + profileName),
),
},
{
Config: testAccountMcmaJobProfile_multiple(profileName, providerConfig),
Check: resource.ComposeTestCheckFunc(
testAccCheckJobProfileExists("mcma_job_profile.job_profile_"+profileName+"_1"),
testAccCheckJobProfileExists("mcma_job_profile.job_profile_"+profileName+"_2"),
testAccCheckJobProfileExists("mcma_job_profile.job_profile_"+profileName+"_3"),
),
},
},
Expand Down Expand Up @@ -90,7 +97,88 @@ resource "mcma_job_profile" "job_profile_%s" {
`, providerConfig, profileName, profileName)
}

func testAccCheckJobProfileExists(resourceName string, jobProfile *mcmamodel.JobProfile) resource.TestCheckFunc {
func testAccountMcmaJobProfile_multiple(profileName string, providerConfig string) string {
return fmt.Sprintf(`
%s
resource "mcma_job_profile" "job_profile_%s_1" {
name = "%s_1"
input_parameter {
name = "param1"
type = "string"
}
input_parameter {
name = "param2"
type = "number"
optional = true
}
output_parameter {
name = "outparam1"
type = "string"
}
output_parameter {
name = "outparam2"
type = "number"
}
custom_properties = {
customprop1 = "customprop1val"
customprop2 = "customprop2val"
}
}
resource "mcma_job_profile" "job_profile_%s_2" {
name = "%s_2"
input_parameter {
name = "param3"
type = "string"
}
input_parameter {
name = "param4"
type = "number"
optional = true
}
output_parameter {
name = "outparam3"
type = "string"
}
output_parameter {
name = "outparam4"
type = "number"
}
custom_properties = {
customprop1 = "customprop3val"
customprop2 = "customprop4val"
}
}
resource "mcma_job_profile" "job_profile_%s_3" {
name = "%s_3"
input_parameter {
name = "param5"
type = "string"
}
input_parameter {
name = "param6"
type = "number"
optional = true
}
output_parameter {
name = "outparam5"
type = "string"
}
output_parameter {
name = "outparam6"
type = "number"
}
custom_properties = {
customprop1 = "customprop5val"
customprop2 = "customprop6val"
}
}
`, providerConfig, profileName, profileName, profileName, profileName, profileName, profileName)
}

func testAccCheckJobProfileExists(resourceName string) resource.TestCheckFunc {
return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
Expand All @@ -107,8 +195,6 @@ func testAccCheckJobProfileExists(resourceName string, jobProfile *mcmamodel.Job
if p == nil {
return fmt.Errorf("job profile with ID %s not found", rs.Primary.ID)
}
pImpl := p.(mcmamodel.JobProfile)
*jobProfile = pImpl
return nil
}
}

0 comments on commit c7a2aea

Please sign in to comment.