From a34adb2d625c1fa5c3ebc03a0bf5c61014a6152b Mon Sep 17 00:00:00 2001 From: Will Jones Date: Mon, 14 Oct 2024 10:59:00 +0000 Subject: [PATCH] Feature flag parameterized provider support (#1438) Support for parameterized providers (introduced originally in #1398) is now exposed by the engine as a new `parameterized` feature flag. This commit updates the Java SDK to check for support before attempting to register a parameterized package, allowing us to throw a better error message in the event that parameterization is not currently supported. Part of pulumi/pulumi#16906 --- CHANGELOG_PENDING.md | 4 +- pulumi | 2 +- .../deployment/internal/DeploymentImpl.java | 41 ++- .../aws-native-java-s3-folder/.gitignore | 5 + .../aws-native-java-s3-folder/Pulumi.yaml | 3 + .../aws-native-java-s3-folder/README.md | 116 +++++++ .../aws-native-java-s3-folder/pom.xml | 51 ++++ .../src/main/java/s3site/App.java | 76 +++++ .../aws-native-java-s3-folder/www/favicon.ico | Bin 0 -> 13731 bytes .../aws-native-java-s3-folder/www/index.html | 7 + tests/examples/java_examples_test.go | 282 ++++++++++-------- tests/integration/java_integration_test.go | 2 +- tests/integration/util.go | 5 +- tests/internal/pin.go | 4 +- 14 files changed, 456 insertions(+), 142 deletions(-) create mode 100644 tests/examples/aws-native-java-s3-folder/.gitignore create mode 100644 tests/examples/aws-native-java-s3-folder/Pulumi.yaml create mode 100644 tests/examples/aws-native-java-s3-folder/README.md create mode 100644 tests/examples/aws-native-java-s3-folder/pom.xml create mode 100644 tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java create mode 100644 tests/examples/aws-native-java-s3-folder/www/favicon.ico create mode 100644 tests/examples/aws-native-java-s3-folder/www/index.html diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index e3ee41906ed..f05bbfa6404 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -2,4 +2,6 @@ - Update pulumi/pulumi to v3.132.0 -### Bug Fixes +- Feature flag parameterized provider support + +### Bug Fixes \ No newline at end of file diff --git a/pulumi b/pulumi index 487b4a8494e..e34b753f070 160000 --- a/pulumi +++ b/pulumi @@ -1 +1 @@ -Subproject commit 487b4a8494ef556063aaf8335e6bad6317bb1072 +Subproject commit e34b753f070b2862263f80882ceb88ce69a14272 diff --git a/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java b/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java index 05224613263..0ee8aad34b2 100644 --- a/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java +++ b/sdk/java/pulumi/src/main/java/com/pulumi/deployment/internal/DeploymentImpl.java @@ -253,6 +253,11 @@ private CompletableFuture monitorSupportsFeature(String feature) { CompletableFuture monitorSupportsResourceReferences() { return monitorSupportsFeature("resourceReferences"); } + + @InternalUse + CompletableFuture monitorSupportsParameterization() { + return monitorSupportsFeature("parameterization"); + } } @ParametersAreNonnullByDefault @@ -846,21 +851,27 @@ public CompletableFuture registerPackage( String packageVersion, String base64Parameter ) { - var request = RegisterPackageRequest.newBuilder() - .setName(baseProviderName) - .setVersion(baseProviderVersion) - .setDownloadUrl(baseProviderDownloadUrl) - .setParameterization( - Parameterization.newBuilder() - .setName(packageName) - .setVersion(packageVersion) - .setValue(ByteString.copyFrom(Base64.getDecoder().decode(base64Parameter))) - .build() - ) - .build(); - - return this.state.monitor.registerPackageAsync(request) - .thenApply(response -> response.getRef()); + return this.featureSupport.monitorSupportsParameterization().thenCompose(supportsParameterization -> { + if (!supportsParameterization) { + throw new UnsupportedOperationException("The Pulumi CLI does not support parameterization. Please update the Pulumi CLI."); + } + + var request = RegisterPackageRequest.newBuilder() + .setName(baseProviderName) + .setVersion(baseProviderVersion) + .setDownloadUrl(baseProviderDownloadUrl) + .setParameterization( + Parameterization.newBuilder() + .setName(packageName) + .setVersion(packageVersion) + .setValue(ByteString.copyFrom(Base64.getDecoder().decode(base64Parameter))) + .build() + ) + .build(); + + return this.state.monitor.registerPackageAsync(request) + .thenApply(response -> response.getRef()); + }); } private static final class Prepare { diff --git a/tests/examples/aws-native-java-s3-folder/.gitignore b/tests/examples/aws-native-java-s3-folder/.gitignore new file mode 100644 index 00000000000..1b6985c0094 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/.gitignore @@ -0,0 +1,5 @@ +# Ignore Gradle project-specific cache directory +.gradle + +# Ignore Gradle build output directory +build diff --git a/tests/examples/aws-native-java-s3-folder/Pulumi.yaml b/tests/examples/aws-native-java-s3-folder/Pulumi.yaml new file mode 100644 index 00000000000..48dc8bc50d8 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/Pulumi.yaml @@ -0,0 +1,3 @@ +name: aws-java-s3-folder +runtime: java +description: A static website hosted on AWS S3 \ No newline at end of file diff --git a/tests/examples/aws-native-java-s3-folder/README.md b/tests/examples/aws-native-java-s3-folder/README.md new file mode 100644 index 00000000000..c56bbda7e28 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/README.md @@ -0,0 +1,116 @@ +[![Deploy this example with Pulumi](https://get.pulumi.com/new/button.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-native-java-s3-folder/README.md#gh-light-mode-only) +[![Deploy this example with Pulumi](https://get.pulumi.com/new/button-light.svg)](https://app.pulumi.com/new?template=https://github.com/pulumi/examples/blob/master/aws-native-java-s3-folder/README.md#gh-dark-mode-only) + +# Host a Static Website on Amazon S3 with the AWS Native Provider + +A static website that uses [S3's website support](https://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteHosting.html). +For a detailed walkthrough of this example, see the tutorial [Static Website on AWS S3](https://www.pulumi.com/docs/tutorials/aws/s3-website/). + +Note: Some resources are not yet supported by the Native AWS provider, so we are using both the Native +and Classic provider in this example. The resources will be updated to use native resources as they are +available in AWS's Cloud Control API. + +## Deploying and running the program + +Note: some values in this example will be different from run to run. These values are indicated +with `***`. + +1. Set the AWS region: + + Either using an environment variable + ```bash + $ export AWS_REGION=us-west-2 + ``` + + Or with the stack config + ```bash + $ pulumi config set aws:region us-west-2 + $ pulumi config set aws-native:region us-west-2 + ``` + +1. Run `pulumi up` to preview and deploy changes. After the preview is shown you will be + prompted if you want to continue or not. + + ```bash + $ pulumi up + Previewing update (dev) + + View Live: https://app.pulumi.com/***/aws-java-s3-folder/dev/previews/e251093a-d128-4ed3-a230-4e98888aed84 + + Type Name Plan Info + + pulumi:pulumi:Stack aws-java-s3-folder-dev create 6 messages + + ├─ aws-native:s3:Bucket s3-website-bucket create + + ├─ aws:s3:BucketPolicy bucketPolicy create + + ├─ aws:s3:BucketObject index.html create + + └─ aws:s3:BucketObject favicon.ico create + + Diagnostics: + pulumi:pulumi:Stack (aws-java-s3-folder-dev): + > Task :app:compileJava UP-TO-DATE + > Task :app:processResources NO-SOURCE + > Task :app:classes UP-TO-DATE + > Task :app:run + BUILD SUCCESSFUL in 3s + 2 actionable tasks: 1 executed, 1 up-to-date + + + Updating (dev) + + View Live: https://app.pulumi.com/***/aws-java-s3-folder/dev/updates/1 + + Type Name Status Info + + pulumi:pulumi:Stack aws-java-s3-folder-dev created 6 messages + + ├─ aws-native:s3:Bucket s3-website-bucket created + + ├─ aws:s3:BucketPolicy bucketPolicy created + + ├─ aws:s3:BucketObject index.html created + + └─ aws:s3:BucketObject favicon.ico created + + Diagnostics: + pulumi:pulumi:Stack (aws-java-s3-folder-dev): + > Task :app:compileJava UP-TO-DATE + > Task :app:processResources NO-SOURCE + > Task :app:classes UP-TO-DATE + > Task :app:run + BUILD SUCCESSFUL in 1m 5s + 2 actionable tasks: 1 executed, 1 up-to-date + + Outputs: + bucketName: "s3-website-bucket-***" + urn : "***" + websiteUrl: "http://s3-website-bucket-***.s3-website-us-west-2.amazonaws.com" + + Resources: + + 5 created + + Duration: 1m6s + ``` + +1. To see the resources that were created, run `pulumi stack output`: + + ```bash + $ pulumi stack output + Current stack outputs (3): + OUTPUT VALUE + bucketName s3-website-bucket-*** + urn urn:pulumi:dev::aws-java-s3-folder::pulumi:pulumi:Stack::aws-java-s3-folder-dev + websiteUrl http://s3-website-bucket-***.s3-website-us-west-2.amazonaws.com + ``` + +1. To see that the S3 objects exist, you can either use the AWS Console or the AWS CLI: + + ```bash + $ aws s3 ls $(pulumi stack output bucketName) + 2022-02-17 14:11:54 13731 favicon.ico + 2022-02-17 14:11:54 198 index.html + ``` + +1. Open the site URL in a browser to see both the rendered HTML and the favicon: + + ```bash + $ pulumi stack output websiteUrl + http://s3-website-bucket-***.s3-website-us-west-2.amazonaws.com + ``` + + ![Hello S3 example](https://user-images.githubusercontent.com/274700/116912066-9384e300-abfc-11eb-8130-dbcff512a9de.png) + +1. To clean up resources, run `pulumi destroy` and answer the confirmation question at the prompt. diff --git a/tests/examples/aws-native-java-s3-folder/pom.xml b/tests/examples/aws-native-java-s3-folder/pom.xml new file mode 100644 index 00000000000..1dd26793316 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/pom.xml @@ -0,0 +1,51 @@ + + + 4.0.0 + + com.pulumi + aws-native-java-s3-folder + 1.0-SNAPSHOT + + + UTF-8 + 17 + 17 + 17 + s3site.App + + + + + + com.pulumi + pulumi + (,1.0] + + + com.pulumi + aws + (6.0.2,6.99] + + + com.pulumi + aws-native + (,1.0] + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.0.0 + + ${mainClass} + ${mainArgs} + + + + + diff --git a/tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java b/tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java new file mode 100644 index 00000000000..ee3625f257f --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/src/main/java/s3site/App.java @@ -0,0 +1,76 @@ +// from https://github.com/pulumi/examples/blob/8cc8b1a4384c8b33f70ba65c701e19daecfa6399/aws-ts-s3-folder/index.ts +package s3site; + +import com.pulumi.Context; +import com.pulumi.Pulumi; +import com.pulumi.asset.FileAsset; +import com.pulumi.aws.s3.BucketObject; +import com.pulumi.aws.s3.BucketObjectArgs; +import com.pulumi.aws.s3.BucketPolicy; +import com.pulumi.aws.s3.BucketPolicyArgs; +import com.pulumi.awsnative.s3.Bucket; +import com.pulumi.awsnative.s3.BucketArgs; +import com.pulumi.awsnative.s3.inputs.BucketWebsiteConfigurationArgs; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.function.BiConsumer; + +public class App { + public static void main(String[] args) { + Pulumi.run(App::stack); + } + + private static void stack(Context ctx) { + final var siteBucket = new Bucket("s3-website-bucket", + BucketArgs.builder().websiteConfiguration(BucketWebsiteConfigurationArgs.builder() + .indexDocument("index.html") + .build()).build()); + + final String siteDir = "www/"; + forEachFileInTree(siteDir, (path, contentType) -> { + new BucketObject(path.toString().replace(siteDir, ""), + BucketObjectArgs.builder().bucket(siteBucket.getId()) + .source(new FileAsset(path.toAbsolutePath().toString())) + .contentType(contentType).build() + ); + }); + + final var bucketPolicy = new BucketPolicy("bucketPolicy", + BucketPolicyArgs.builder().bucket(siteBucket.getId()) + .policy(siteBucket.arn() + .applyValue(bucketArn -> """ + { + "Version":"2012-10-17", + "Statement":[{ + "Effect":"Allow", + "Principal":"*", + "Action":["s3:GetObject"], + "Resource":["%s/*"] + }] + } + """.formatted(bucketArn)) + ).build()); + + ctx.export("bucketName", siteBucket.bucketName()); + ctx.export("websiteUrl", siteBucket.websiteUrl()); + } + + private static void forEachFileInTree(String siteDir, BiConsumer consumer) { + try (var paths = Files.walk(Paths.get(siteDir)).filter(Files::isRegularFile)) { + paths.forEach(path -> { + final String contentType; + try { + contentType = Files.probeContentType(path); + } catch (IOException e) { + throw new RuntimeException(String.format("Failed to probeContentType for path: '%s'", path), e); + } + consumer.accept(path, contentType); + }); + } catch (IOException e) { + throw new RuntimeException(String.format("Failed to walk a path: '%s'", siteDir), e); + } + } +} diff --git a/tests/examples/aws-native-java-s3-folder/www/favicon.ico b/tests/examples/aws-native-java-s3-folder/www/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..ad4baeb6fd3df3a99e06099e7a94b2715eaad419 GIT binary patch literal 13731 zcmW+-1yoay8{Np!-8n)^k?!t>(J0a&A>G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xuqYU03uQ6d)1@rgqG)UyGb_vmzEqo8;bW*E)BI-fqV(Y-pc5L#sZ0coVCZr6{Bo zOzDaV2HndGcbX?`wVJ;nGv~UTM5evHtYVFbl%M_mn_5KS#A_gJr`_S<`UF@!hVwJR zWd3r^oKe^}1)}c4n7M6G-hKMEF!yH{2h32VGK~$Qop^R$K|~CFp38Z)Q_O~xumn3i zK9zi5O2y3S|V==XQ53 zplob*<12Y%3bnvAy;7%2BFY#=fbRIGON8rt;iENRcKFf)&cqi@U1+UY)%)!Bun{r% z3QX&bsia_{T3H#Bn=1x{Ytn>_PLw3sS^r1jNLo${@iR(ccyU(5ibu`9BkIrEusy2ofwEN)shB0iy`}$o*rir=yX2*8{TSM zh0%CQrl|NuazCczA1dBsP4zS1k-w0nJJakbZuiQ`is_5-c5>ufjZCgoa3&~LE7K3chOkc`h$tk1h8pC6y`>sx z({SR=&*qI{(|BsO0rn=Z;4x2j`1z5Wdw3Fwfh25FC*!TMsU{{keqO`Bvicr{aP)+* tIlSoCln7pTX_%u;^Qlu##o5&h7|#m*&z7PN`+wh+Qj}Gbsg*Jb`5)Yh=^ literal 0 HcmV?d00001 diff --git a/tests/examples/aws-native-java-s3-folder/www/index.html b/tests/examples/aws-native-java-s3-folder/www/index.html new file mode 100644 index 00000000000..db1c4d3f525 --- /dev/null +++ b/tests/examples/aws-native-java-s3-folder/www/index.html @@ -0,0 +1,7 @@ + + + Hello, Pulumi! + +

Hello, S3!

+

Made with ❤️ with Pulumi

+ diff --git a/tests/examples/java_examples_test.go b/tests/examples/java_examples_test.go index cc29bed86ad..df1cb907aaf 100644 --- a/tests/examples/java_examples_test.go +++ b/tests/examples/java_examples_test.go @@ -30,34 +30,41 @@ const previewOnly = true func TestExamples(t *testing.T) { t.Run("random", func(t *testing.T) { - test := getJavaBase(t, "random", integration.ProgramTestOptions{ - ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { - o := stackInfo.Outputs - assert.Greater(t, o["randomInteger"].(float64), -0.1) - assert.Len(t, o["randomString"].(string), 10) - assert.Len(t, o["randomUuid"].(string), 36) - assert.Len(t, o["randomIdHex"].(string), 20) - - for _, s := range o["shuffled"].([]interface{}) { - s := s.(string) - assert.Contains(t, []string{"A", "B", "C"}, s) - } - - hasCipherText := false - for k := range o["randomPassword"].(map[string]interface{}) { - if k == "ciphertext" { - hasCipherText = true + test := makeJavaProgramTestOptions( + t, + "tests/examples/random", + []string{"random"}, + integration.ProgramTestOptions{ + ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { + o := stackInfo.Outputs + assert.Greater(t, o["randomInteger"].(float64), -0.1) + assert.Len(t, o["randomString"].(string), 10) + assert.Len(t, o["randomUuid"].(string), 36) + assert.Len(t, o["randomIdHex"].(string), 20) + + for _, s := range o["shuffled"].([]interface{}) { + s := s.(string) + assert.Contains(t, []string{"A", "B", "C"}, s) } - } - assert.True(t, hasCipherText) + + hasCipherText := false + for k := range o["randomPassword"].(map[string]interface{}) { + if k == "ciphertext" { + hasCipherText = true + } + } + assert.True(t, hasCipherText) + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("azure-java-static-website", func(t *testing.T) { - test := getJavaBaseNew(t, - "azure-java-static-website", + test := makeJavaProgramTestOptions( + t, + "examples/azure-java-static-website", []string{"azure-native"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -70,13 +77,15 @@ func TestExamples(t *testing.T) { assert.True(t, strings.HasPrefix(cdnEndpoint, "https")) assert.True(t, strings.HasPrefix(staticEndpoint, "https")) }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("aws-java-webserver", func(t *testing.T) { - test := getJavaBaseNew(t, - "aws-java-webserver", + test := makeJavaProgramTestOptions(t, + "examples/aws-java-webserver", []string{"aws"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -89,38 +98,44 @@ func TestExamples(t *testing.T) { assert.True(t, strings.Contains(publicIp, ".")) assert.True(t, strings.Contains(publicHostName, ".")) }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("azure-java-appservice-sql", func(t *testing.T) { - test := getJavaBaseNew(t, - "azure-java-appservice-sql", + test := makeJavaProgramTestOptions(t, + "examples/azure-java-appservice-sql", []string{"azure-native"}, integration.ProgramTestOptions{ Config: map[string]string{ "azure-native:location": "westus", "azure-java-appservice-sql:sqlPassword": "not-a-real-password", }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("aws-java-eks-minimal", func(t *testing.T) { - test := getJavaBaseNew(t, - "aws-java-eks-minimal", + test := makeJavaProgramTestOptions(t, + "examples/aws-java-eks-minimal", []string{"eks", "aws", "kubernetes"}, integration.ProgramTestOptions{ Config: map[string]string{ "aws:region": "us-west-1", }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("gcp-java-gke-hello-world", func(t *testing.T) { - test := getJavaBaseNew(t, - "gcp-java-gke-hello-world", + test := makeJavaProgramTestOptions(t, + "examples/gcp-java-gke-hello-world", []string{"gcp"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -128,70 +143,88 @@ func TestExamples(t *testing.T) { "gcp:project": "pulumi-ci-gcp-provider", "gcp:zone": "us-west1-a", }, - }) + }, + ) integration.ProgramTest(t, &test) }) t.Run("kubernetes", func(t *testing.T) { t.SkipNow() - test := getJavaBase(t, "kubernetes", integration.ProgramTestOptions{ - Config: map[string]string{}, - }) + test := makeJavaProgramTestOptions( + t, + "tests/examples/kubernetes", + []string{"kubernetes"}, + integration.ProgramTestOptions{ + Config: map[string]string{}, + }, + ) + integration.ProgramTest(t, &test) }) t.Run("minimal", func(t *testing.T) { - test := getJavaBase(t, "minimal", integration.ProgramTestOptions{ - PrepareProject: func(info *engine.Projinfo) error { - cmd := exec.Command(filepath.Join(info.Root, "mvnw"), - "--no-transfer-progress", "package") - cmd.Dir = info.Root - var buf bytes.Buffer - cmd.Stdout = &buf - cmd.Stderr = &buf - err := cmd.Run() - - if err != nil { - t.Logf("mvwn --no-transfer-progress package: %v", err) - t.Log(buf.String()) - } + test := makeJavaProgramTestOptions( + t, + "tests/examples/minimal", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + PrepareProject: func(info *engine.Projinfo) error { + cmd := exec.Command(filepath.Join(info.Root, "mvnw"), + "--no-transfer-progress", "package") + cmd.Dir = info.Root + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + err := cmd.Run() + if err != nil { + t.Logf("mvwn --no-transfer-progress package: %v", err) + t.Log(buf.String()) + } - return err - }, - Config: map[string]string{ - "name": "Pulumi", - }, - Secrets: map[string]string{ - "secret": "this is my secret message", - }, - ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { - // Simple runtime validation that just ensures the checkpoint was written and read. - assert.NotNil(t, stackInfo.Deployment) + return err + }, + Config: map[string]string{ + "name": "Pulumi", + }, + Secrets: map[string]string{ + "secret": "this is my secret message", + }, + ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { + // Simple runtime validation that just ensures the checkpoint was written and read. + assert.NotNil(t, stackInfo.Deployment) + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("minimalsbt", func(t *testing.T) { - test := getJavaBase(t, "minimalsbt", integration.ProgramTestOptions{ - Config: map[string]string{ - "name": "Pulumi", - }, - Secrets: map[string]string{ - "secret": "this is my secret message", - }, - ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { - // Simple runtime validation that just ensures the checkpoint was written and read. - assert.NotNil(t, stackInfo.Deployment) + test := makeJavaProgramTestOptions( + t, + "tests/examples/minimalsbt", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + Config: map[string]string{ + "name": "Pulumi", + }, + Secrets: map[string]string{ + "secret": "this is my secret message", + }, + ExtraRuntimeValidation: func(t *testing.T, stackInfo integration.RuntimeValidationStackInfo) { + // Simple runtime validation that just ensures the checkpoint was written and read. + assert.NotNil(t, stackInfo.Deployment) + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("aws-native-java-s3-folder", func(t *testing.T) { - test := getJavaBaseNew(t, - "aws-native-java-s3-folder", + test := makeJavaProgramTestOptions(t, + "tests/examples/aws-native-java-s3-folder", []string{"aws", "aws-native"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -203,13 +236,15 @@ func TestExamples(t *testing.T) { // provider bug. We need to recheck // after upgrading to latest. SkipRefresh: true, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("azure-java-function-graal-spring", func(t *testing.T) { - test := getJavaBaseNew(t, - "azure-java-function-graal-spring", + test := makeJavaProgramTestOptions(t, + "examples/azure-java-function-graal-spring", []string{"azure-native"}, integration.ProgramTestOptions{ Config: map[string]string{ @@ -238,41 +273,66 @@ func TestExamples(t *testing.T) { } return err }, - }) + }, + ) + integration.ProgramTest(t, &test) }) t.Run("minimal-jbang", func(t *testing.T) { - test := getJavaBase(t, "minimal-jbang", integration.ProgramTestOptions{ - Config: map[string]string{ - "minimal:name": "minimal-name", - "minimal:secret": "minimal-secret", + test := makeJavaProgramTestOptions( + t, + "tests/examples/minimal-jbang", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + Config: map[string]string{ + "minimal:name": "minimal-name", + "minimal:secret": "minimal-secret", + }, }, - }) + ) + integration.ProgramTest(t, &test) }) t.Run("testing-unit-java", func(t *testing.T) { - test := getJavaBase(t, "testing-unit-java", integration.ProgramTestOptions{ - Config: map[string]string{ - "aws:region": "us-east-2", + test := makeJavaProgramTestOptions( + t, + "tests/examples/testing-unit-java", + []string{}, /*providers*/ + integration.ProgramTestOptions{ + Config: map[string]string{ + "aws:region": "us-east-2", + }, }, - }) + ) + integration.ProgramTest(t, &test) }) } -func getJavaBaseNew( +// Constructs a set of integration.ProgramTestOptions for running a Java example test. The supplied directory will be +// resolved relative to the repository root, and is typically one of the following: +// +// - tests/examples/ if the example being tested is vendored into this repository. +// - examples/ if the example being tested is in the Pulumi examples repository, which is cloned into this one +// as part of running this test suite. +func makeJavaProgramTestOptions( t *testing.T, dir string, providers []string, - testSpecificOptions integration.ProgramTestOptions, + overrides integration.ProgramTestOptions, ) integration.ProgramTestOptions { repoRoot, err := filepath.Abs(filepath.Join("..", "..")) if err != nil { panic(err) } + prepareProject := func(info *engine.Projinfo) error { + if len(providers) == 0 { + return nil + } + deps, err := jtests.ParsePinVersionsFromEnv(t, providers) if err != nil { return err @@ -280,17 +340,17 @@ func getJavaBaseNew( _, err = jtests.Pin(info.Root, deps) return err } - opts := integration.ProgramTestOptions{ - Dir: filepath.Join(repoRoot, "examples", dir), - } - opts = opts.With(getBaseOptions()). - With(testSpecificOptions). + + opts := integration.ProgramTestOptions{Dir: filepath.Join(repoRoot, dir)}. + With(getBaseOptions()). + With(overrides). With(integration.ProgramTestOptions{ PrepareProject: combinePrepareProject( prepareProject, - testSpecificOptions.PrepareProject, + overrides.PrepareProject, ), }) + if previewOnly { opts = opts.With(integration.ProgramTestOptions{ SkipRefresh: true, @@ -300,6 +360,7 @@ func getJavaBaseNew( }) opts.ExtraRuntimeValidation = nil } + return opts } @@ -317,26 +378,6 @@ func combinePrepareProject(f1, f2 func(info *engine.Projinfo) error) func(info * } } -func getJavaBase(t *testing.T, dir string, testSpecificOptions integration.ProgramTestOptions) integration.ProgramTestOptions { - opts := integration.ProgramTestOptions{ - Dir: filepath.Join(getCwd(t), dir), - PrepareProject: func(*engine.Projinfo) error { - return nil // needed because defaultPrepareProject does not know about java - }, - } - opts = opts.With(getBaseOptions()).With(testSpecificOptions) - if previewOnly { - opts = opts.With(integration.ProgramTestOptions{ - SkipRefresh: true, - SkipEmptyPreviewUpdate: true, - SkipExportImport: true, - SkipUpdate: true, - }) - opts.ExtraRuntimeValidation = nil - } - return opts -} - // Copied from: https://github.com/pulumi/examples/blob/4fb1f146409ace4af1945f84ee9c90c643430e9d/misc/test/examples_test.go func assertHTTPResult(t *testing.T, output interface{}, headers map[string]string, check func(string) bool) bool { @@ -348,7 +389,8 @@ func assertHTTPResultWithRetry(t *testing.T, output interface{}, headers map[str } func assertHTTPResultShapeWithRetry(t *testing.T, output interface{}, headers map[string]string, maxWait time.Duration, - ready func(string) bool, check func(string) bool) bool { + ready func(string) bool, check func(string) bool, +) bool { hostname, ok := output.(string) if !assert.True(t, ok, fmt.Sprintf("expected `%s` output", output)) { return false @@ -416,4 +458,4 @@ func assertHTTPResultShapeWithRetry(t *testing.T, output interface{}, headers ma } return false -} +} \ No newline at end of file diff --git a/tests/integration/java_integration_test.go b/tests/integration/java_integration_test.go index c231a5077a9..4f72c509843 100644 --- a/tests/integration/java_integration_test.go +++ b/tests/integration/java_integration_test.go @@ -25,7 +25,7 @@ func TestIntegrations(t *testing.T) { DebugLogLevel: 0, // Stack references will change on refresh due to steps changing outputs and self stack // references. - SkipRefresh: true, + SkipRefresh: true, Env: []string{ "PULUMI_EXCESSIVE_DEBUG_OUTPUT=false", }, diff --git a/tests/integration/util.go b/tests/integration/util.go index 589f02e0a86..3405d70ff4b 100644 --- a/tests/integration/util.go +++ b/tests/integration/util.go @@ -3,10 +3,11 @@ package integration import ( - "github.com/pulumi/pulumi/pkg/v3/engine" - "github.com/pulumi/pulumi/pkg/v3/testing/integration" "os" "testing" + + "github.com/pulumi/pulumi/pkg/v3/engine" + "github.com/pulumi/pulumi/pkg/v3/testing/integration" ) func getCwd(t *testing.T) string { diff --git a/tests/internal/pin.go b/tests/internal/pin.go index 9af9e8eab38..f49db35db6d 100644 --- a/tests/internal/pin.go +++ b/tests/internal/pin.go @@ -173,7 +173,7 @@ func editFile(path string, edit func([]byte) []byte) (FileEdit, error) { if err != nil { return nil, err } - err = ioutil.WriteFile(path, edit(bytes), 0600) + err = ioutil.WriteFile(path, edit(bytes), 0o600) return revertFile{path, bytes}, err } @@ -183,5 +183,5 @@ type revertFile struct { } func (rf revertFile) Revert() error { - return ioutil.WriteFile(rf.path, rf.bytes, 0600) + return ioutil.WriteFile(rf.path, rf.bytes, 0o600) }