Skip to content

Commit

Permalink
Fix flake in regress-4011 test (#4133)
Browse files Browse the repository at this point in the history
The test for regress-4011 is using a static name because it needs to
import a created resource. This can clash with other parallel test runs.

To fix it I added some randomness to the name.
  • Loading branch information
flostadler authored Jun 28, 2024
1 parent 896ae14 commit 8e4e1d9
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 3 additions & 1 deletion examples/examples_nodejs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,8 @@ func TestRegress4011(t *testing.T) {
})

// Disable envRegion mangling
test.Config = nil
test.Config = map[string]string{
"parameterName": "regress-4011-" + randomString(10),
}
integration.ProgramTest(t, &test)
}
11 changes: 11 additions & 0 deletions examples/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package examples
import (
"context"
"io/ioutil"
"math/rand"
"net/http"
"os"
"testing"
Expand Down Expand Up @@ -92,6 +93,16 @@ func replay(t *testing.T, sequence string) {
testutils.ReplaySequence(t, p, sequence)
}

var letterRunes = []rune("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")

func randomString(length int) string {
b := make([]rune, length)
for i := range b {
b[i] = letterRunes[rand.Intn(len(letterRunes))]
}
return string(b)
}

// This replicates the diff when running `pulumi preview` on a aws.rds.Instance with
// pulumi-aws v6.0.0 and state from pulumi-aws 5.42.0.
//
Expand Down
5 changes: 4 additions & 1 deletion examples/regress-4011/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const cfg = new pulumi.Config();
const parameterName = cfg.require("parameterName");

const param = new aws.ssm.Parameter('regress-4011-test-secret', {
name: 'regress-4011-test-secret',
name: parameterName,
type: 'SecureString',
value: "test",
});
Expand Down
7 changes: 5 additions & 2 deletions examples/regress-4011/step1/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const cfg = new pulumi.Config();
const parameterName = cfg.require("parameterName");

const param = new aws.ssm.Parameter('regress-4011-test-secret', {
name: 'regress-4011-test-secret',
name: parameterName,
type: 'SecureString',
value: "test",
});

const retrievedParam = aws.ssm.Parameter.get('retrieved-parameter', 'regress-4011-test-secret:1');
const retrievedParam = aws.ssm.Parameter.get('retrieved-parameter', `${parameterName}:1`);

export const secret = pulumi.output(param).arn;
export const retrievedSecret = pulumi.output(retrievedParam).arn;

0 comments on commit 8e4e1d9

Please sign in to comment.