Skip to content
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

Duplicate labels regression tests #1854

Merged
merged 6 commits into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions examples/examples_py_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,13 @@ func TestAccWebserverPy(t *testing.T) {
})
}
}

func TestRegress1843(t *testing.T) {
skipIfShort(t)
test := getPythonBaseOptions(t).
With(integration.ProgramTestOptions{
Dir: filepath.Join(getCwd(t), "regress-1843"),
})

integration.ProgramTest(t, &test)
}
2 changes: 2 additions & 0 deletions examples/regress-1843/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*.pyc
venv/
10 changes: 10 additions & 0 deletions examples/regress-1843/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: regress-1843
runtime:
name: python
options:
virtualenv: venv
description: A minimal Google Cloud Python Pulumi program
config:
pulumi:tags:
value:
pulumi:template: gcp-python
45 changes: 45 additions & 0 deletions examples/regress-1843/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
"""A Google Cloud Python Pulumi program"""

import pulumi_gcp as gcp

gcp.cloudrun.Service(
resource_name="test-gcr",
args=gcp.cloudrun.ServiceArgs(
location="us-west1",
template=gcp.cloudrun.ServiceTemplateArgs(
spec=gcp.cloudrun.ServiceTemplateSpecArgs(
containers=[
gcp.cloudrun.ServiceTemplateSpecContainerArgs(
image="us-docker.pkg.dev/cloudrun/container/hello",
resources=gcp.cloudrun.ServiceTemplateSpecContainerResourcesArgs(
limits={
"memory": "512Mi",
"cpu": "1",
}
),
)
],
timeout_seconds=60,
container_concurrency=30,
),
metadata=gcp.cloudrun.ServiceTemplateMetadataArgs(
annotations={
"autoscaling.knative.dev/maxScale": "100",
},
),
),
autogenerate_revision_name=True,
metadata=gcp.cloudrun.ServiceMetadataArgs(
labels={"env": "dev"},
annotations={
"run.googleapis.com/ingress": "all",
},
),
traffics=[
gcp.cloudrun.ServiceTrafficArgs(
percent=100,
latest_revision=True,
)
],
),
)
2 changes: 2 additions & 0 deletions examples/regress-1843/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
pulumi>=3.0.0,<4.0.0
pulumi-gcp>=7.0.0,<8.0.0
8 changes: 8 additions & 0 deletions provider/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ const (
testProject = "pulumi-development"
)

func getProject() string {
proj := os.Getenv("GOOGLE_PROJECT")
if proj == "" {
proj = testProject
}
return proj
}

func TestUpgradeCoverage(t *testing.T) {
providertest.ReportUpgradeCoverage(t)
}
Expand Down
245 changes: 236 additions & 9 deletions provider/provider_yaml_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func TestNoGlobalProjectWarning(t *testing.T) {
}
cwd, err := os.Getwd()
require.NoError(t, err)
proj := os.Getenv("GOOGLE_PROJECT")
proj := getProject()
t.Setenv("GOOGLE_PROJECT", "")

test := pulumitest.NewPulumiTest(t, "test-programs/project-bucket",
Expand Down Expand Up @@ -491,10 +491,7 @@ func TestRegress1488(t *testing.T) {

// Test that going from replication.automatic: true (v6-style) to replication.auto: {}
// (v7-style) is not a replacement.
proj := os.Getenv("GOOGLE_PROJECT")
if proj == "" {
proj = "pulumi-development"
}
proj := getProject()
replay.ReplaySequence(t, providerServer(t), fmt.Sprintf(`[
{
"method": "/pulumirpc.ResourceProvider/Configure",
Expand Down Expand Up @@ -583,10 +580,7 @@ func TestEnvTokenNotInState(t *testing.T) {
test := pulumitest.NewPulumiTest(t, filepath.Join("test-programs", "storage-bucket"),
opttest.LocalProviderPath(providerName, filepath.Join(cwd, "..", "bin")),
)
googleProj := os.Getenv("GOOGLE_PROJECT")
if googleProj == "" {
googleProj = testProject
}
googleProj := getProject()
test.SetConfig("gcp:config:project", googleProj)

test.Up()
Expand All @@ -595,3 +589,236 @@ func TestEnvTokenNotInState(t *testing.T) {
require.NoError(t, err)
require.NotContains(t, string(data), "accessToken")
}

//nolint:lll
func TestCloudrunServiceDiffNoErrorLabelsDuplicate(t *testing.T) {
if testing.Short() {
t.Skipf("Skipping in testing.Short() mode, assuming this is a CI run without GCP creds")
}

proj := getProject()
replay.ReplaySequence(t, providerServer(t), fmt.Sprintf(`[
{
"method": "/pulumirpc.ResourceProvider/Configure",
"request": {
"variables": {
"gcp:config:project": %q
},
"args": {
"project": %q,
"version": "7.4.0"
},
"acceptSecrets": true,
"acceptResources": true,
"sendsOldInputs": true,
"sendsOldInputsToDelete": true
},
"response": {
"supportsPreview": true
}
},
{
"method": "/pulumirpc.ResourceProvider/Diff",
"request": {
"id": "locations/us-west1/namespaces/pulumi-development/services/test-gcr-5a4eed9",
"urn": "urn:pulumi:dev::gcp_labels::gcp:cloudrun/service:Service::test-gcr",
"olds": {
"__meta": "{\"e2bfb730-ecaa-11e6-8f88-34363bc7c4c0\":{\"create\":1200000000000,\"delete\":1200000000000,\"update\":1200000000000},\"schema_version\":\"2\"}",
"autogenerateRevisionName": true,
"id": "locations/us-west1/namespaces/pulumi-development/services/test-gcr-5a4eed9",
"location": "us-west1",
"metadata": {
"annotations": {
"run.googleapis.com/ingress": "all"
},
"effectiveAnnotations": {
"run.googleapis.com/ingress": "all"
},
"effectiveLabels": {
"env": "dev"
},
"generation": 0,
"labels": {
"env": "dev"
},
"namespace": "",
"pulumiLabels": {
"env": "dev"
},
"resourceVersion": "",
"selfLink": "",
"uid": ""
},
"name": "test-gcr-5a4eed9",
"project": "pulumi-development",
"template": {
"metadata": {
"annotations": {
"autoscaling.knative.dev/maxScale": "100"
},
"generation": 0,
"labels": {},
"name": "",
"namespace": "",
"resourceVersion": "",
"selfLink": "",
"uid": ""
},
"spec": {
"containerConcurrency": 30,
"containers": [
{
"args": [],
"commands": [],
"envFroms": [],
"envs": [],
"image": "gcr.io/example",
"livenessProbe": null,
"name": "",
"ports": [],
"resources": {
"limits": {
"cpu": "1",
"memory": "512Mi"
},
"requests": {}
},
"startupProbe": null,
"volumeMounts": [],
"workingDir": ""
}
],
"serviceAccountName": "",
"servingState": "",
"timeoutSeconds": 60,
"volumes": []
}
},
"traffics": [
{
"latestRevision": true,
"percent": 100,
"revisionName": "",
"tag": "",
"url": ""
}
]
},
"news": {
"__defaults": [
"name"
],
"autogenerateRevisionName": true,
"location": "us-west1",
"metadata": {
"__defaults": [],
"annotations": {
"run.googleapis.com/ingress": "all"
},
"labels": {
"env": "dev"
}
},
"name": "test-gcr-5a4eed9",
"template": {
"__defaults": [],
"metadata": {
"__defaults": [],
"annotations": {
"autoscaling.knative.dev/maxScale": "100"
}
},
"spec": {
"__defaults": [],
"containerConcurrency": 30,
"containers": [
{
"__defaults": [],
"image": "hello-world",
"resources": {
"__defaults": [],
"limits": {
"cpu": "1",
"memory": "512Mi"
}
}
}
],
"timeoutSeconds": 60
}
},
"traffics": [
{
"__defaults": [],
"latestRevision": true,
"percent": 100
}
]
},
"oldInputs": {
"__defaults": [
"name"
],
"autogenerateRevisionName": true,
"location": "us-west1",
"metadata": {
"__defaults": [],
"annotations": {
"run.googleapis.com/ingress": "all"
},
"labels": {
"env": "dev"
}
},
"name": "test-gcr-5a4eed9",
"template": {
"__defaults": [],
"metadata": {
"__defaults": [],
"annotations": {
"autoscaling.knative.dev/maxScale": "100"
}
},
"spec": {
"__defaults": [],
"containerConcurrency": 30,
"containers": [
{
"__defaults": [],
"image": "gcr.io/example",
"resources": {
"__defaults": [],
"limits": {
"cpu": "1",
"memory": "512Mi"
}
}
}
],
"timeoutSeconds": 60
}
},
"traffics": [
{
"__defaults": [],
"latestRevision": true,
"percent": 100
}
]
}
},
"response": {
"stables": "*",
"changes": "*",
"hasDetailedDiff": "*",
"diffs": "*",
"detailedDiff": "*"
},
"metadata": {
"kind": "resource",
"mode": "client",
"name": "gcp"
}
}
]`, proj, proj))
}
Loading