mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-26 00:41:27 -06:00
fee61a44b4
Previously we had no automated testing of whether we can produce a Terraform executable that actually works. Our various functional tests have good coverage of specific Terraform features and whole operations, but we lacked end-to-end testing of actual usage of the generated binary, without any stubbing. This package is intended as a vehicle for such end-to-end testing. When run normally under "go test" it will produce a build of the main Terraform binary and make it available for tests to execute. The harness exposes a flag for whether tests are allowed to reach out to external network services, controlled with our standard TF_ACC environment variable, so that basic local tests can be safely run as part of "make test" while more elaborate tests can be run easily when desired. It also provides a separate mode of operation where the included script make-archive.sh can be used to produce a self-contained test archive that can be copied to another system to run the tests there. This is intended to allow testing of cross-compiled binaries, by shipping them over to the target OS and architecture to run without requiring a full Go compiler installation on the target system. The goal here is not to test again functionality that's already well-covered by our existing tests, but rather to test chains of normal operations against the build binary that are not otherwise tested together.
30 lines
1.3 KiB
Go
30 lines
1.3 KiB
Go
// Package e2etest contains a small number of tests that run against a real
|
|
// Terraform binary, compiled on the fly at the start of the test run.
|
|
//
|
|
// These tests help ensure that key end-to-end Terraform use-cases are working
|
|
// for a real binary, whereas other tests always have at least _some_ amount
|
|
// of test stubbing.
|
|
//
|
|
// The goal of this package is not to duplicate the functional testing done
|
|
// in other packages but rather to fully exercise a few important workflows
|
|
// in a realistic way.
|
|
//
|
|
// These tests can be used in two ways. The simplest way is to just run them
|
|
// with "go test" as normal:
|
|
//
|
|
// go test -v github.com/hashicorp/terraform/command/e2etest
|
|
//
|
|
// This will compile on the fly a Terraform binary and run the tests against
|
|
// it.
|
|
//
|
|
// Alternatively, the make-archive.sh script can be used to produce a
|
|
// self-contained zip file that can be shipped to another machine to run
|
|
// the tests there without needing a locally-installed Go compiler. This
|
|
// is primarily useful for testing cross-compiled builds. For more information,
|
|
// see the commentary in make-archive.sh.
|
|
//
|
|
// The TF_ACC environment variable must be set for the tests to reach out
|
|
// to external network services. Since these are end-to-end tests, only a
|
|
// few very basic tests can execute without this environment variable set.
|
|
package e2etest
|