Skip to content

Commit

Permalink
lock only when execute init
Browse files Browse the repository at this point in the history
  • Loading branch information
lonegunmanb committed Feb 2, 2023
1 parent f0ae9b7 commit 36c5e97
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion e2etest.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ func RunE2ETest(t *testing.T, moduleRootPath, exampleRelativePath string, option
}

func initAndApply(t terratest.TestingT, options *terraform.Options) string {
tfInit(t, options)
return terraform.InitAndApply(t, options)
}

func tfInit(t terratest.TestingT, options *terraform.Options) {
initLock.Lock()
defer initLock.Unlock()
return terraform.InitAndApply(t, options)
terraform.Init(t, options)
}

func destroy(t *testing.T, option terraform.Options) {
Expand Down
7 changes: 3 additions & 4 deletions upgradetest.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ func sameMajorVersion(majorVersion int) func(i interface{}) bool {
}

func initAndPlanWithExitCode(t terratest.TestingT, options *terraform.Options) int {
initLock.Lock()
defer initLock.Unlock()
return terraform.InitAndPlanWithExitCode(t, options)
}
tfInit(t, options)
return terraform.PlanExitCode(t, options)
}

0 comments on commit 36c5e97

Please sign in to comment.