Skip to content

Can't find dynamic generated plan output for recipes/modules running in parallel #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Excoriate opened this issue Apr 8, 2024 · 0 comments
Labels
bug Something is not working fine 🐛.
Milestone

Comments

@Excoriate
Copy link
Owner

🪲 Describe the Bug

When running in parallel, different subdirectories under the 'recipes' or examples directories, it can't find the dynamically generated plan output file

=== RUN   TestRecipesLifecycle/advanced
=== PAUSE TestRecipesLifecycle/advanced
=== CONT  TestRecipesLifecycle/advanced
    dirs.go:24: The git repo root is /Users/[email protected]/@code/@mambu-gitlab/@clonned/mambucom/product/sre/infrastructure/builder-experience/iac-framework/brainiac-iac-catalog/granular-aws-db
    client.go:200: Setting Terraform variable files: [fixtures/fixtures.tfvars]
    stage.go:43: 
        	Error Trace:	/Users/[email protected]/go/pkg/mod/github.com/!excoriate/[email protected]/pkg/scenario/stage.go:43
        	            				/Users/[email protected]/@code/@mambu-gitlab/@clonned/mambucom/product/sre/infrastructure/builder-experience/iac-framework/brainiac-iac-catalog/granular-aws-db/tests/db-subnet-group/recipes/recipes_lifecycle_test.go:21
        	Error:      	Received unexpected error:
        	            	FatalError{Underlying: error while running command: exit status 1; 
        	            	Error: Failed to load "plan.out" as a plan file
        	            	
        	            	Error: stat plan.out: no such file or directory}
        	Test:       	TestRecipesLifecycle/advanced
        	Messages:   	Failed to apply terraform: 
        	            	Error: Failed to load "plan.out" as a plan file
        	            	
        	            	Error: stat plan.out: no such file or directory
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: - Installed hashicorp/aws v4.67.0 (signed by HashiCorp)
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: 
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: Terraform has been successfully initialized!
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: 
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: You may now begin working with Terraform. Try running "terraform plan" to see
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: any changes that are required for your infrastructure. All Terraform commands
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: should now work.
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: 
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: If you ever set or change modules or backend configuration for Terraform,
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: rerun this command to reinitialize your working directory. If you forget, other
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: commands will detect it and remind you to do so if necessary.
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 retry.go:91: terraform [apply -input=false -auto-approve -no-color -lock=false plan.out]
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: Running command terraform with args [apply -input=false -auto-approve -no-color -lock=false plan.out]
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: 
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: Error: Failed to load "plan.out" as a plan file
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: 
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 logger.go:66: Error: stat plan.out: no such file or directory
TestRecipesLifecycle/elasticache-filtered-subnets 2024-04-08T11:25:17+02:00 retry.go:99: Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; 
Error: Failed to load "plan.out" as a plan file

Error: stat plan.out: no such file or directory}
    --- FAIL: TestRecipesLifecycle/advanced (9.11s)

Example code

func TestRecipesLifecycle(t *testing.T) {
	for _, recipe := range recipes {
		t.Run(recipe, func(t *testing.T) {
			tfVarFile := filepath.Join(fixtureDir, "fixtures.tfvars")
			t.Parallel()
			workdir := filepath.Join(recipeDir, recipe)
			s, err := scenario.NewWithOptions(t, workdir, scenario.WithVarFiles(workdir, tfVarFile), scenario.WithParallel())

			assert.NoErrorf(t, err, "Failed to create scenario: %s", err)

			s.Stg.ApplyStage(t, s.GetTerraformOptions())
		})
	}
}

With a configuration that iterates over multiple recipes.

@Excoriate Excoriate added the bug Something is not working fine 🐛. label Apr 8, 2024
@Excoriate Excoriate changed the title [Bug Title] Can't find dynamic generated plan output for recipes/modules running in parallel Apr 16, 2024
@Excoriate Excoriate added this to the next🚨 milestone Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working fine 🐛.
Projects
Status: No status
Development

No branches or pull requests

1 participant