Commit graph

154 commits

Author SHA1 Message Date
Sean Gillespie 3cf81c0b4c
Serialize package installs in test framework (#2367)
setuptools's "develop" action is not safe to run concurrently when
targeting the same source tree. In order to work around this, this
commit explicitly serializes package installations.
2019-01-17 12:41:53 -08:00
Chris Smith 5619fbce49
Add EngineEvents perf test (#2315)
* Add EngineEvents stress test

* Address PR feedback

* Specify value to config bag

* Don't test run in parallel
2019-01-03 14:18:19 -08:00
CyrusNajmabadi d93e930856
Provide an actual 'table' printing routine so that we can appropriate choose columns widths dynamically. (#2266) 2018-12-02 00:22:07 -08:00
CyrusNajmabadi af9671a4dd
Add test helper function. (#2251) 2018-11-28 11:46:10 -08:00
Matt Ellis e3f8726d0a Do not pass --verbose to yarn install
When the install fails, we end up printing the entire contents of
yarn's stdout to stdout. This output can often be quite long and will
cause Travis to fail in some cases.

The regular error output should be sufficent for us to diagnose any
issues we'll face.
2018-11-25 22:02:28 -08:00
Matt Ellis 872c7661e3 Provide a way to override packages during a test run
Add a new property to ProgramTestOptions, `Overrides` that allows a
test to request a different version of a package is used instead of
what would be listed in the package.json file.

This will be used by our nightly automation to run everything "at head"
2018-11-25 22:02:28 -08:00
CyrusNajmabadi a7d2f10eaf
Allow tests to pass additional flags when doing a preview. (#2232) 2018-11-20 02:05:24 -08:00
Matt Ellis 35215d6a07 Write .yarnrc with both test frameworks
While the lifecycle tests wrote a `.yarnrc` file to ensure that copies
of `yarn` did not race with one another, the more barebones testing
framework did not.

This should address some of the yarn issues we've been seeing in CI
recently
2018-11-19 17:12:18 -08:00
Matt Ellis c398e8ba80 Don't write a lock file when installing test packages
The lockfile is not super interesting when running the lifecycle
tests, since the test project is not a long lived artifact. There was
no real harm in writing it, exepct that in some cases `pipenv` gets
very confused when you have dependencies on pre-release
versions (which is the case right now as we are brining up Python 3).

The packages are still installed correctly, even when we don't write a
lock file.
2018-11-08 12:09:10 -08:00
Sean Gillespie 4ae39b8bec
Ask for the newest Python 3 instead of 3.6 specifically (#2165)
* Ask for the newest Python 3 instead of 3.6 specifically

* Remove PythonVersion from test opts
2018-11-06 10:38:46 -08:00
Sean Gillespie 36c88aab37
Fix Python support in integration test framework (#2158)
* Fix Python support in integration test framework

Update the integratino test framework to use pipenv to bootstrap new
virtual environments for tests and use those virtual environments to run
pulumi update and pulumi preview.

Fixes pulumi/pulumi#2138

* Install packages via 'Dependencies' field

* Remove code for installing packages from Dependencies
2018-11-05 13:52:37 -08:00
Joe Duffy 9aedb234af
Tidy up some data structures (#2135)
In preparation for some workspace restructuring, I decided to scratch a
few itches of my own in the code:

* Change project's RuntimeInfo field to just Runtime, to match the
  serialized name in JSON/YAML.

* Eliminate the no-longer-used Context and NoDefaultIgnores fields on
  project, and all of the associated legacy PPC-related code.

* Eliminate the no-longer-used IgnoreFile constant.

* Remove a bunch of "// nolint: lll" annotations, and simply format
  the structures with comments on dedicated lines, to avoid overly
  lengthy lines and lint suppressions.

* Mark Dependencies and InitErrors as `omitempty` in the JSON
  serialization directives for CheckpointV2 files. This was done for
  the YAML directives, but (presumably accidentally) omitted for JSON.
2018-11-01 08:28:11 -07:00
Chris Smith f324a460e9
Remove references to Pulumi private clouds (#2095)
* Remove TODO for issue since fixed in PPCs.

* Update issue reference to source

* Update comment wording

* Remove --ppc arg of stack init

* Remove PPC references in int. testing fx

* Remove vestigial PPC API types
2018-10-24 13:50:35 -07:00
Joe Duffy 5ed33c6915
Add GitLab CI support (#2013)
This change adds GitLab CI support, by sniffing out the right
variables (equivalent to what we already do for Travis).

I've also restructured the code to share more logic with our
existing CI detection code, now moved to the pkg/util/ciutil
package, and will be fleshing this out more in the days to come.
2018-10-02 16:08:03 -07:00
Pat Gavlin 9c7fff2d7d
Improve integration test usability. (#1960)
Add two command-line options to the test framework, "-dirs" and
"list-dirs". The former accepts a regex that is used to select which
integration tests to run. The latter lists available integration tests
without running them.
2018-09-20 15:08:29 -05:00
joeduffy db48f10412 Update test frameworks to new packages 2018-09-05 08:16:14 -07:00
Luke Hoban b9c64b1e70
Allow skipping refresh step in integration tests (#1852)
Allows working around bugs in refresh (such as https://github.com/pulumi/pulumi-terraform/issues/241).
2018-08-31 11:34:26 -05:00
Luke Hoban 1ebd698a7a
Support for more ProgramTestOptions in With (#1844)
The pattern we are using here is generally prone to error, so I hope we find a way to move away from this more generally - but for now we need to be able to configure more of these in places we are using `With`.

Also remove some `+""` that are tripping up the linter for me locally.
2018-08-30 11:08:19 -05:00
Matt Ellis 8f5def8453 Do not delete failed stacks from integration tests
Often when the test fails, you'll want to use the web console to
investigate the stack, looking at detailed log messages, for
example. But since we always delete the stack today, you often can't.

Stop running `pulumi stack rm` when the test fails, however do run a
`pulumi destroy` so we at least clean up any resources the stack may
have allocated during testing.

Fixes #1722
2018-08-27 13:28:46 -07:00
Pat Gavlin 73f4f2c464
Reimplement refresh. (#1814)
Replace the Source-based implementation of refresh with a phase that
runs as the first part of plan execution and rewrites the snapshot in-memory.

In order to fit neatly within the existing framework for resource operations,
these changes introduce a new kind of step, RefreshStep, to represent
refreshes. RefreshSteps operate similar to ReadSteps but do not imply that
the resource being read is not managed by Pulumi.

In addition to the refresh reimplementation, these changes incorporate those
from #1394 to run refresh in the integration test framework.

Fixes #1598.
Fixes pulumi/pulumi-terraform#165.
Contributes to #1449.
2018-08-22 17:52:46 -07:00
Matt Ellis 7074ae8cf3 Use new native typescript support in many tests
We retain a few tests on the RunBuild plan, with `typescript` set to
false in the runtime options, but for the general case, we remove the
build steps and custom entry points for our programs.
2018-08-06 14:00:58 -07:00
Matt Ellis ce5eaa8343 Support TypeScript in a more first-class way
This change lets us set runtime specific options in Pulumi.yaml, which
will flow as arguments to the language hosts. We then teach the nodejs
host that when the `typescript` is set to `true` that it should load
ts-node before calling into user code. This allows using typescript
natively without an explicit compile step outside of Pulumi.

This works even when a tsconfig.json file is not present in the
application and should provide a nicer inner loop for folks writing
typescript (I'm pretty sure everyone has run into the "but I fixed
that bug!  Why isn't it getting picked up?  Oh, I forgot to run tsc"
problem.

Fixes #958
2018-08-06 14:00:58 -07:00
Joe Duffy 76eea4863a
Prefer "up" over "update" (#1672) 2018-07-31 10:22:16 -07:00
Sean Gillespie 80c28c00d2
Add a migrate package for migrating to and from differently-versioned API types (#1647)
* Add a migrate package for migrating to and from differently-versioned
API types

* travis: gofmt -s deployment_test.go
2018-07-20 13:31:41 -07:00
Luke Hoban 015344ab06
Support SkipBuild in integration test framework (#1603) 2018-07-06 22:06:28 -07:00
Matt Ellis a47babd194 Run export/import rounttrip as part of our lifecycle tests
This allows us to delete the one off export/import test, which is nice
because it failed to run when PULUMI_ACCESS_TOKEN was not set in the
environment (due to an interaction between `pulumi login` and the
bare-bones integration test framework)
2018-06-14 16:01:28 -07:00
Matt Ellis 2669f65b39 Don't dirty work tree when running tests
Because we run our golang integration tests "in tree" (due to
the need to be under $GOPATH and have a vendor folder around), the
"command-output" folder was getting left behind, dirtying the worktree
after building.

This change does two things:

1. On a succecssful run, remove the folder.
2. Ignore the folder via .gitignore (this way if a test fails and you
do `git add .` you don't end up commiting this folder).
2018-06-14 15:58:37 -07:00
Pat Gavlin dc0c604ae7
Enable fork builds. (#1495)
If we're building in CI and do not have an access token, skip any
lifecycle tests.
2018-06-11 16:01:04 -07:00
Joe Duffy b69ad03625
Merge pull request #1491 from pulumi/go_testing
Fix a few things in the Go test harness
2018-06-11 14:44:07 -07:00
joeduffy c81a5152f0 Skip copying to a temp dir for Go projects
Due to the way GOPATH and vendoring works, copying Go tests out to a
random temp directory simply will not work.  This is largely a holdover
to the days of when .pulumi/ directories would pollute the directory,
but is also done for languages like Node.js whose preparatory and build
steps also pollute the working directory (with bin/ and node_modules/
directories).  Go does not have this problem, so we can safely skip.
2018-06-11 14:24:29 -07:00
joeduffy 6599240861 Default to $HOME/go for GOPATH during tests 2018-06-11 13:08:46 -07:00
Matt Ellis 9d4e24c165 Allow tests to be run by users outside of the Pulumi organization
Today we defaulted our tests to create stacks in the `pulumi`
organization. We did this because our tests run with `pulumi-bot` and
we'd rather create the stacks in our shared organization, so any
Pulumi developer can see them.

Of course, as we prepare to have folks outside of the Pulumi
organization write and run tests, this has now become a bad default.

Remove the ability to explicitly set an owner in
ProgramTestOptions (since that would more or less only lead to pain
going forward) and default to just creating the stacks in whatever
account is currently logged in. In CI, we'll set a new environment
variable "PULUMI_TEST_OWNER" which controls the owner of the stacks,
which we'll set to `pulumi`.

Impact to day to day developers is during test runs locally you'll see
stacks in your list of stacks. If any of the tests fail to clean up,
you'll see these lingering stacks (but you can go clean them up).
2018-06-11 11:03:17 -06:00
joeduffy b28f643164 Add integration test support for Go
This adds integration test support framework for Go.

It also adds a test case for the basic empty Pulumi Go program.
2018-06-10 09:17:19 -07:00
Matt Ellis 8a6ffd08b2 Use crypto/rand when generating a stack suffix
math/rand uses a fixed seed, meaning that across runs the Kth call to
`rand.Int63()` will always return the same value.

Given that we want to provide a unique suffix across multiple
concurrent runs, this isn't the behavior we want.

I saw an instance fail in CI where all three legs ran the test
concurrently and they raced on creating the test stack, since they all
generated the same name.
2018-06-05 11:06:01 -07:00
Matt Ellis 4ac1a2f355 Pull tracing and reporting information from the environment
This lets us set these values globaly, in our Travis and AppVeyor
configurations instead of forcing every test to opt-in. It also means
that by default, local builds will not report any of this data (and
will not need access to these endpoints).
2018-06-04 14:28:52 -07:00
Pat Gavlin 38d3b83494
Allow tests to perform changes in empty updates. (#1411)
This may be a useful knob to have.
2018-05-23 09:17:10 -07:00
joeduffy 5967259795 Add license headers 2018-05-22 15:02:47 -07:00
Matt Ellis 0732b05c5d Remove pulumi init
`pulumi init` was part of our old identity model with the service and
is no longer used. We can now delete this code.

Fixes #1241
2018-05-22 13:37:08 -07:00
Pat Gavlin 05ef4fecb9 Validate empty previews and updates in tests.
Fixes #1154.
2018-05-15 18:03:30 -07:00
Pat Gavlin 016ae4acba
Add pre/post-update hooks to the test framework. (#1369)
These changes add support for pre- and post-`pulumi` callbacks to the
integration test framework. These callbacks will be invoked immediately
before and after (respectively) running a `pulumi` command.
2018-05-15 09:48:56 -07:00
joeduffy 7c7f6d3ed7 Bring back preview, swizzle some flags
This changes the CLI interface in a few ways:

* `pulumi preview` is back!  The alternative of saying
  `pulumi update --preview` just felt awkward, and it's a common
  operation to want to perform.  Let's just make it work.

* There are two flags consistent across all update commands,
  `update`, `refresh`, and `destroy`:

    - `--skip-preview` will skip the preview step.  Note that this
      does *not* skip the prompt to confirm that you'd like to proceed.
      Indeed, it will still prompt, with a little warning text about
      the fact that the preview has been skipped.

    * `--yes` will auto-approve the updates.

This lands us in a simpler and more intuitive spot for common scenarios.
2018-05-06 13:55:39 -07:00
joeduffy 6ad785d5c4 Revise the way previews are controlled
I found the flag --force to be a strange name for skipping a preview,
since that name is usually reserved for operations that might be harmful
and yet you're coercing a tool to do it anyway, knowing there's a chance
you're going to shoot yourself in the foot.

I also found that what I almost always want in the situation where
--force was being used is to actually just run a preview and have the
confirmation auto-accepted.  Going straight to --force isn't the right
thing in a CI scenario, where you actually want to run a preview first,
just to ensure there aren't any issues, before doing the update.

In a sense, there are four options here:

1. Run a preview, ask for confirmation, then do an update (the default).
2. Run a preview, auto-accept, and then do an update (the CI scenario).
3. Just run a preview with neither a confirmation nor an update (dry run).
4. Just do an update, without performing a preview beforehand (rare).

This change enables all four workflows in our CLI.

Rather than have an explosion of flags, we have a single flag,
--preview, which can specify the mode that we're operating in.  The
following are the values which correlate to the above four modes:

1. "": default (no --preview specified)
2. "auto": auto-accept preview confirmation
3. "only": only run a preview, don't confirm or update
4. "skip": skip the preview altogether

As part of this change, I redid a bit of how the preview modes
were specified.  Rather than booleans, which had some illegal
combinations, this change introduces a new enum type.  Furthermore,
because the engine is wholly ignorant of these flags -- and only the
backend understands them -- it was confusing to me that
engine.UpdateOptions stored this flag, especially given that all
interesting engine options _also_ accepted a dryRun boolean.  As of
this change, the backend.PreviewBehavior controls the preview options.
2018-05-06 13:55:04 -07:00
Matt Ellis fcefbcb0b8 Remove test token
We now handle test credentials via Travis, so we don't need this
anymore.
2018-05-04 18:02:25 -07:00
Pat Gavlin c0ed11af14 Enable tracing of integration tests.
These changes add a new option to the integration test framework that
allows the specification of a tracing endpoint for Pulumi invocations.
2018-05-03 13:44:21 -07:00
CyrusNajmabadi fd3ddda917
Disable interactive mode for a CI/CD server. (#1297) 2018-04-30 15:27:53 -07:00
CyrusNajmabadi 3b13803c71
Add a hidden --no-interactive flag so that we can reduce interactive noise when running jenkins. (#1262) 2018-04-24 14:23:08 -07:00
Matt Ellis 15e2ad27fe Address code review feedback 2018-04-20 02:34:10 -04:00
Matt Ellis 56d7f8eb24 Support new stack identity for the cloud backend
This change introduces support for using the cloud backend when
`pulumi init` has not been run. When this is the case, we use the new
identity model, where a stack is referenced by an owner and a stack
name only.

There are a few things going on here:

- We add a new `--owner` flag to `pulumi stack init` that lets you
  control what account a stack is created in.

- When listing stacks, we show stacks owned by you and any
  organizations you are a member of. So, for example, I can do:

  * `pulumi stack init my-great-stack`
  * `pulumi stack init --owner pulumi my-great-stack`

  To create a stack owned by my user and one owned by my
  organization. When `pulumi stack ls` is run, you'll see both
  stacks (since they are part of the same project).

- When spelling a stack on the CLI, an owner can be optionally
  specified by prefixing the stack name with an owner name. For
  example `my-great-stack` means the stack `my-great-stack` owned by
  the current logged in user, where-as `pulumi/my-great-stack` would
  be the stack owned by the `pulumi` organization

- `--all` can be passed to `pulumi stack ls` to see *all* stacks you
  have access to, not just stacks tied to the current project.
2018-04-18 04:54:02 -07:00
Matt Ellis 50982e8763 Add some randomness to stack names in our integration tests
To prepare for a world where stack names must be unique across an
owner, add some randomness to the names we use for stacks as part of
our integration tests.
2018-04-18 04:54:02 -07:00
Matt Ellis bac02f1df1 Remove the need to pulumi init for the local backend
This change removes the need to `pulumi init` when targeting the local
backend. A fair amount of the change lays the foundation that the next
set of changes to stop having `pulumi init` be used for cloud stacks
as well.

Previously, `pulumi init` logically did two things:

1. It created the bookkeeping directory for local stacks, this was
stored in `<repository-root>/.pulumi`, where `<repository-root>` was
the path to what we belived the "root" of your project was. In the
case of git repositories, this was the directory that contained your
`.git` folder.

2. It recorded repository information in
`<repository-root>/.pulumi/repository.json`. This was used by the
cloud backend when computing what project to interact with on
Pulumi.com

The new identity model will remove the need for (2), since we only
need an owner and stack name to fully qualify a stack on
pulumi.com, so it's easy enough to stop creating a folder just for
that.

However, for the local backend, we need to continue to retain some
information about stacks (e.g. checkpoints, history, etc). In
addition, we need to store our workspace settings (which today just
contains the selected stack) somehere.

For state stored by the local backend, we change the URL scheme from
`local://` to `local://<optional-root-path>`. When
`<optional-root-path>` is unset, it defaults to `$HOME`. We create our
`.pulumi` folder in that directory. This is important because stack
names now must be unique within the backend, but we have some tests
using local stacks which use fixed stack names, so each integration
test really wants its own "view" of the world.

For the workspace settings, we introduce a new `workspaces` directory
in `~/.pulumi`. In this folder we write the workspace settings file
for each project. The file name is the name of the project, combined
with the SHA1 of the path of the project file on disk, to ensure that
multiple pulumi programs with the same project name have different
workspace settings.

This does mean that moving a project's location on disk will cause the
CLI to "forget" what the selected stack was, which is unfortunate, but
not the end of the world. If this ends up being a big pain point, we
can certianly try to play games in the future (for example, if we saw
a .git folder in a parent folder, we could store data in there).

With respect to compatibility, we don't attempt to migrate older files
to their newer locations. For long lived stacks managed using the
local backend, we can provide information on where to move things
to. For all stacks (regardless of backend) we'll require the user to
`pulumi stack select` their stack again, but that seems like the
correct trade-off vs writing complicated upgrade code.
2018-04-18 04:53:49 -07:00