pulumi/examples/examples_test.go
pat@pulumi.com 6b66437fae Track resources that are pending deletion in checkpoints.
During the course of a `pulumi update`, it is possible for a resource to
become slated for deletion. In the case that this deletion is part of a
replacement, another resource with the same URN as the to-be-deleted
resource will have been created earlier. If the `update` fails after the
replacement resource is created but before the original resource has been
deleted, the snapshot must capture that the original resource still exists
and should be deleted in a future update without losing track of the order
in which the deletion must occur relative to other deletes. Currently, we
are unable to track this information because the our checkpoints require
that no two resources have the same URN.

To fix this, these changes introduce to the update engine the notion of a
resource that is pending deletion and change checkpoint serialization to
use an array of resources rather than a map. The meaning of the former is
straightforward: a resource that is pending deletion should be deleted
during the next update.

This is a fairly major breaking change to our checkpoint files, as the
map of resources is no more. Happily, though, it makes our checkpoint
files a bit more "obvious" to any tooling that might want to grovel
or rewrite them.

Fixes #432, #387.
2017-10-18 17:09:00 -07:00

45 lines
946 B
Go

// Copyright 2016-2017, Pulumi Corporation. All rights reserved.
package examples
import (
"os"
"path"
"testing"
"github.com/stretchr/testify/assert"
"github.com/pulumi/pulumi/pkg/testing/integration"
)
func TestExamples(t *testing.T) {
cwd, err := os.Getwd()
if !assert.NoError(t, err, "expected a valid working directory: %v", err) {
return
}
examples := []integration.LumiProgramTestOptions{
{
Dir: path.Join(cwd, "minimal"),
Dependencies: []string{"pulumi"},
Config: map[string]string{
"minimal:config:name": "Pulumi",
},
},
{
Dir: path.Join(cwd, "dynamic-provider/simple"),
Dependencies: []string{"pulumi"},
Config: map[string]string{
"simple:config:w": "1",
"simple:config:x": "1",
"simple:config:y": "1",
},
},
}
for _, ex := range examples {
example := ex
t.Run(example.Dir, func(t *testing.T) {
integration.LumiProgramTest(t, example)
})
}
}