-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
11052: fix(ci): Split programgen tests over multiple jobs r=AaronFriel a=AaronFriel Attempt to fix ongoing CI issue #11022 where the `pkg/codegen/go` tests seem to hang runners. Applies a similar strategy as was used for `pkg/codegen/nodejs` tests to split them out over multiple jobs, generalized to handle additional languages. Previously, we would split the `pkg` module by package into 3 jobs using `gotestsum`, **except** for the package `pkg/codegen/nodejs` which would be split _by test_ into 4 jobs, for 7 total jobs. With this change, instead of special casing `pkg/codegen/nodejs`, each language's programgen tests are split into 6 packages, and relies on `gotestsum` to divide packages among a combined 7 jobs. The numbers 6 and 7 were chosen arbitrarily. 6 batches per language as this divides the tests fairly evenly, and 7 jobs total as that preserves the total number of jobs. The `test_pkg_$LANG` makefile targets weren't very descriptive and their meaning would change with this PR, there are new targets `test_codegen_$LANG` which replace their use. Co-authored-by: Aaron Friel <mayreply@aaronfriel.com>
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// Copyright 2016-2022, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
//go:generate go run ./generate.go | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
) | ||
|
||
// Split codegen tests into separate packages to extract greater parallelism, breaking up the | ||
// slowest set(s) of tests. | ||
func main() { | ||
template := `// Copyright 2016-2022, Pulumi Corporation. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// Code generated by "codegen/gen_program_test/generate.go"; DO NOT EDIT. | ||
package %s | ||
import ( | ||
"os" | ||
"testing" | ||
codegen "github.com/pulumi/pulumi/pkg/v3/codegen/%s" | ||
"github.com/pulumi/pulumi/pkg/v3/codegen/testing/test" | ||
) | ||
func TestGenerateProgram(t *testing.T) { | ||
os.Chdir("../../../%[2]s") // chdir into codegen/%[2]s | ||
codegen.GenerateProgramBatchTest(t, test.ProgramTestBatch(%d, %d)) | ||
}` | ||
|
||
n := 6 | ||
for _, lang := range []string{"dotnet", "go", "nodejs", "python"} { | ||
os.RemoveAll(filepath.Join("../", lang, "gen_program_test")) | ||
for i := 1; i <= n; i++ { | ||
packageName := fmt.Sprintf("batch%d", i) | ||
dir := filepath.Join("../", lang, "gen_program_test", packageName) | ||
err := os.MkdirAll(dir, 0755) | ||
if err != nil { | ||
panic(fmt.Sprintf("unexpected error generating codegen tests: %v", err)) | ||
} | ||
testPath := filepath.Join(dir, "gen_program_test.go") | ||
|
||
sourceCode := fmt.Sprintf(template, packageName, lang, i, n) | ||
err = os.WriteFile(testPath, []byte(sourceCode), 0755) //nolint:gosec | ||
if err != nil { | ||
panic(fmt.Sprintf("unexpected error generating codegen tests: %v", err)) | ||
} | ||
} | ||
} | ||
|
||
} |