pulumi/cmd/pulumi-test-language
dependabot[bot] a09578df98
Bump golang.org/x/crypto from 0.24.0 to 0.31.0 in /sdk in the go_modules group across 1 directory (#18015)
Bumps the go_modules group with 1 update in the /sdk directory:
[golang.org/x/crypto](https://github.com/golang/crypto).

Updates `golang.org/x/crypto` from 0.24.0 to 0.31.0
<details>
<summary>Commits</summary>
<ul>
<li><a
href="b4f1988a35"><code>b4f1988</code></a>
ssh: make the public key cache a 1-entry FIFO cache</li>
<li><a
href="7042ebcbe0"><code>7042ebc</code></a>
openpgp/clearsign: just use rand.Reader in tests</li>
<li><a
href="3e90321ac7"><code>3e90321</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="8c4e668694"><code>8c4e668</code></a>
x509roots/fallback: update bundle</li>
<li><a
href="6018723c74"><code>6018723</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="71ed71b4fa"><code>71ed71b</code></a>
README: don't recommend go get</li>
<li><a
href="750a45fe5e"><code>750a45f</code></a>
sha3: add MarshalBinary, AppendBinary, and UnmarshalBinary</li>
<li><a
href="36b172546b"><code>36b1725</code></a>
sha3: avoid trailing permutation</li>
<li><a
href="80ea76eb17"><code>80ea76e</code></a>
sha3: fix padding for long cSHAKE parameters</li>
<li><a
href="c17aa50fbd"><code>c17aa50</code></a>
sha3: avoid buffer copy</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/crypto/compare/v0.24.0...v0.31.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/crypto&package-manager=go_modules&previous-version=0.24.0&new-version=0.31.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions
You can disable automated security fix PRs for this repo from the
[Security Alerts page](https://github.com/pulumi/pulumi/network/alerts).

</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Justin Van Patten <jvp@justinvp.com>
2024-12-12 01:29:41 +00:00
..
providers Add l2-explicit-parameterized-provider test (#17973) 2024-12-10 23:30:08 +00:00
testdata Add l2-explicit-parameterized-provider test (#17973) 2024-12-10 23:30:08 +00:00
README.md Clean up documentation to support the bridge (#17784) 2024-11-15 14:41:07 +00:00
go.mod Bump golang.org/x/crypto from 0.24.0 to 0.31.0 in /sdk in the go_modules group across 1 directory (#18015) 2024-12-12 01:29:41 +00:00
go.sum Bump golang.org/x/crypto from 0.24.0 to 0.31.0 in /sdk in the go_modules group across 1 directory (#18015) 2024-12-12 01:29:41 +00:00
grpc.go Cover configure (#17508) 2024-10-11 02:23:59 +00:00
interface.go Conformance tests check GetRequiredPackages (#17910) 2024-12-09 15:03:14 +00:00
interface_test.go Fix language conformance tests (#17677) 2024-11-05 12:00:42 +00:00
internal_test.go Parse conformance programs to decide which packages are needed for SDKs (#16872) 2024-08-05 12:07:06 +00:00
l1empty_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
l1main_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
l2continue_on_error_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
l2destroy_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
l2large_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
l2resourceasset_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
l2resourcesimple_test.go Conformance tests check GetRequiredPackages (#17910) 2024-12-09 15:03:14 +00:00
main.go Add matrix testing (#13705) 2023-09-13 15:17:46 +00:00
runtime_options_test.go Bump gRPC dependencies and migrate `grpc.Dial` (#17701) 2024-11-06 18:36:10 +00:00
snapshot_test.go Add asset/archive to conformance tests and fix engine working dir issues (#16100) 2024-05-02 11:32:54 +00:00
snapshots.go Rewrite conformance test snapshots filewise (#17804) 2024-11-19 13:58:51 +00:00
test_host.go Only return providers from gatherPluginsFromProgram (#18008) 2024-12-11 22:04:53 +00:00
testing.go Add a conformance test for parent inheritance (#17935) 2024-12-05 16:05:56 +00:00
tests.go Add l2-explicit-parameterized-provider test (#17973) 2024-12-10 23:30:08 +00:00

README.md

(language-conformance-tests)=

Language conformance tests

Language conformance tests (often just conformance tests) are a class of integration test that assert various properties that should hold true across all language runtimes, in essence providing a specification that language runtimes must conform to. They are structured as follows:

  • The "program under test" is expressed using PCL. The program can specify resources and functions supplied by one or more test resource providers with fixed, known implementations, as well as provider-agnostic entities such as stack outputs.
  • A set of assertions are made about the state of the resources, functions, outputs, etc. in the program before and after it has been executed. These assertions should hold true regardless of the language being used to define and execute the program.

For each test run and language, then:

  • If the test requires one or more providers, SDKs are generated from the relevant test providers, exercising SDK generation for the given language.
  • The PCL program is converted into a program in the target language, exercising program generation for the given language.
  • The generated program is executed using a compiled language host running as a separate process and the assertions are checked, exercising program execution for the given language.
  • Generated code is snapshot tested to ensure that it doesn't change unexpectedly.

Running Language Conformance Tests

To run the language conformance tests, for example for Python, run:

go test github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 -count 1

Note: to run this from the root of the repository, make sure you have an uptodate go.work file by running make work.

The conformance tests are named TestLanguage/${TEST_NAME}, for example TestLanguage/l1-output-string.

Python can generate SDKs in multiple ways, either using setup.py or project.toml to define the python package metadata, as well as using different input types (classes-and-dicts or classes). Python also supports either MyPy or PyRight as typechecker. To ensure we cover all of these options, each test is run in 3 variants (the options are orthogonal to each other, so we don't run all combinations):

  • default (uses setup.py, MyPy and the default input types)
  • toml (uses pyproject.toml, PyRight and classes-and-dicts)
  • classes (uses setup, PyRight and classes)

Test names follow the pattern TestLanguage/${VARIANT}/${TEST_NAME}, for example TestLanguage/classes/l1-output-string.

For Nodejs we have two variants, using TypeScript (forceTsc=false) or plain Javascript (forceTsc=true, so named because the test setup runs tsc on the project so it's runnable as plain Javascript). Tests are named for example TestLanguage/forceTsc=true/l1-output-string or TestLanguage/forceTsc=false/l1-output-string.

To run a single test case:

go test github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 -count 1 -run TestLanguage/classes/l1-output-string

To update the snapshots for generated code, run the tests with the PULUMI_ACCEPT environment variable set to a truthy value:

PULUMI_ACCEPT=1 go test github.com/pulumi/pulumi/sdk/python/cmd/pulumi-language-python/v3 -count 1

Architecture

Test providers are defined in gh-file:pulumi#cmd/pulumi-test-language/providers. PCL programs for language conformance tests are defined in gh-file:pulumi#cmd/pulumi-test-language/testdata. gh-file:pulumi#cmd/pulumi-test-language/tests.go then references these programs and defines the assertions to be made about each. Tests are categorised as follows:

  • L1 tests are those which do not exercise provider code paths and use only the most basic of features (e.g. stack outputs).
  • L2 tests are those which do exercise provider code paths and use things such as custom resources, function invocations, and so on.
  • L3 tests exercise features that require more advanced language support such as first-class functions -- apply is a good example of this.

Each language defines a test function (the language test host) responsible for running its conformance test suite, if it implements one. For core languages whose runtimes are written in Go, this typically lives in a language_test.go file next to the relevant language host executable code -- see for example gh-file:pulumi#sdk/nodejs/cmd/pulumi-language-nodejs/language_test.go for NodeJS/TypeScript and gh-file:pulumi#sdk/python/cmd/pulumi-language-python/language_test.go for Python. This function works as follows:

  • The relevant language runtime (e.g. pulumi-language-nodejs for NodeJS) is booted up as a separate process.
  • The pulumi-test-language executable is booted up, with the language runtime's gRPC server address as a parameter. The test language executable itself exposes a gRPC server which allows clients to e.g. retrieve a list of tests (GetLanguageTests) and execute a test (RunLanguageTest).
  • In preparation for test execution, the language test host retrieves the list of tests from the pulumi-test-language server. It s the core SDK (e.g. @pulumi/pulumi in TypeScript/NodeJS).
  • For each test:
    • SDKs required by the test are generated by calling the language host's method. The generated code is written to a temporary directory where it is ed for use in the test.
    • The method is invoked to convert the test's PCL code into a program in the target language. Dependencies are installed with and the test program is .
    • Assertions are verified and the next test is processed until there are no more remaining.
:caption: The lifecycle of a language conformance test suite
:zoom:

sequenceDiagram
    participant LTH as Language test host
    participant PTL as pulumi-test-language
    participant LH as Language host

    LTH->>+PTL: Start pulumi-test-language process
    PTL-->>-LTH: Return gRPC server address

    note right of LTH: All future calls to<br>pulumi-test-language are via gRPC

    LTH->>+PTL: GetLanguageTests()
    PTL-->>-LTH: List of test names

    LTH->>+LH: Start language host
    LH-->>-LTH: Return gRPC server address

    note right of LTH: All future calls to<br>language host are via gRPC

    LTH->>+PTL: PrepareLanguageTests(Language host)
    PTL->>+LH: Pack(Core SDK)
    LH-->>-PTL: Name of core SDK artifact
    PTL->>-LTH: Token

    loop For each test
        LTH->>+PTL: RunLanguageTest(Token, Language test host)

        loop For each SDK
            PTL->>+LH: GeneratePackage(SDK)
            LH-->>-PTL: Write package code to temporary directory
            PTL->>PTL: Verify SDK snapshot
            PTL->>+LH: Pack(SDK)
            LH-->>-PTL: Name of SDK artifact
        end

        PTL->>+LH: GenerateProject(Test)
        LH-->>-PTL: Write project code to temporary directory
        PTL->>PTL: Verify project snapshot

        PTL->>+LH: InstallDependencies(Project)
        LH-->>-PTL: Dependencies installed

        note right of PTL: Execute test with engine

        PTL->>+LH: Run(Project)
        LH-->>-PTL: Run result
        PTL->>PTL: Check assertions against run result and snapshot

        PTL-->>-LTH: Test result
    end

Meta tests

This module contains a number of _test.go files. These are tests of the conformance test system itself. The actual conformance tests are all defined in tests.go.