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

integration-cli: DockerPluginSuite: use gotest.tools compare utilities #44316

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

thaJeztah
Copy link
Member

@thaJeztah thaJeztah commented Oct 18, 2022

Some of these tests are failing (but not enabled in CI), but the current output doesn't provide any details on the failure, so this patch is just to improve the test output to allow debugging the actual failure.

Before this, tests would fail like:

make BIND_DIR=. TEST_FILTER=TestPluginInstallImage test-integration
...
=== FAIL: amd64.integration-cli TestDockerPluginSuite/TestPluginInstallImage (15.22s)
    docker_cli_plugins_test.go:220: assertion failed: expression is false: strings.Contains(out, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
    --- FAIL: TestDockerPluginSuite/TestPluginInstallImage (15.22s)

With this patch, tests provide more useful output:

    make BIND_DIR=. TEST_FILTER=TestPluginInstallImage test-integration
    ...
    === FAIL: amd64.integration-cli TestDockerPluginSuite/TestPluginInstallImage (1.15s)
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json"
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json" digest="sha256:bee151d3fef5c1f787e7846efe4fa42b25a02db4e7543e54e8c679cf19d78598"
mediatype=application/vnd.docker.plugin.v1+json size=522
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json"
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json" digest="sha256:bee151d3fef5c1f787e7846efe4fa42b25a02db4e7543e54e8c679cf19d78598"
mediatype=application/vnd.docker.plugin.v1+json size=522
        docker_cli_plugins_test.go:221: assertion failed: string "Error response from daemon: application/vnd.docker.distribution.manifest.v1+prettyjws not supported\n" does not contain "Encountered remote
\"application/vnd.docker.container.image.v1+json\"(image) when fetching"
        --- FAIL: TestDockerPluginSuite/TestPluginInstallImage (1.15s)

- A picture of a cute animal (not mandatory but encouraged)

@thaJeztah thaJeztah added this to the v-next milestone Oct 18, 2022

env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
assert.Assert(c, strings.Contains(strings.TrimSpace(env), mntSrc))
assert.Check(c, is.Contains(strings.TrimSpace(env), mntSrc))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Check(c, is.Contains(strings.TrimSpace(env), mntSrc))
assert.Check(c, is.Contains(env, mntSrc))

dockerCmd(c, "plugin", "set", name, "pmount1.source=bar")

env, _ = dockerCmd(c, "plugin", "inspect", "-f", "{{with $mount := index .Settings.Mounts 0}}{{$mount.Source}}{{end}}", name)
assert.Assert(c, strings.Contains(strings.TrimSpace(env), "bar"))
assert.Check(c, is.Contains(strings.TrimSpace(env), "bar"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert.Check(c, is.Contains(strings.TrimSpace(env), "bar"))
assert.Check(c, is.Contains(env, "bar"))

Some of these tests are failing (but not enabled in CI), but the current output
doesn't provide any details on the failure, so this patch is just to improve the
test output to allow debugging the actual failure.

Before this, tests would fail like:

    make BIND_DIR=. TEST_FILTER=TestPluginInstallImage test-integration
    ...
    === FAIL: amd64.integration-cli TestDockerPluginSuite/TestPluginInstallImage (15.22s)
        docker_cli_plugins_test.go:220: assertion failed: expression is false: strings.Contains(out, `Encountered remote "application/vnd.docker.container.image.v1+json"(image) when fetching`)
        --- FAIL: TestDockerPluginSuite/TestPluginInstallImage (15.22s)

With this patch, tests provide more useful output:

    make BIND_DIR=. TEST_FILTER=TestPluginInstallImage test-integration
    ...
    === FAIL: amd64.integration-cli TestDockerPluginSuite/TestPluginInstallImage (1.15s)
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json"
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json" digest="sha256:bee151d3fef5c1f787e7846efe4fa42b25a02db4e7543e54e8c679cf19d78598"
mediatype=application/vnd.docker.plugin.v1+json size=522
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json"
    time="2022-10-18T10:21:22Z" level=warning msg="reference for unknown type: application/vnd.docker.plugin.v1+json" digest="sha256:bee151d3fef5c1f787e7846efe4fa42b25a02db4e7543e54e8c679cf19d78598"
mediatype=application/vnd.docker.plugin.v1+json size=522
        docker_cli_plugins_test.go:221: assertion failed: string "Error response from daemon: application/vnd.docker.distribution.manifest.v1+prettyjws not supported\n" does not contain "Encountered remote
\"application/vnd.docker.container.image.v1+json\"(image) when fetching"
        --- FAIL: TestDockerPluginSuite/TestPluginInstallImage (1.15s)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@cpuguy83 cpuguy83 merged commit 9fa3843 into moby:master Nov 2, 2022
@thaJeztah thaJeztah deleted the plugin_improve_test_errors branch November 2, 2022 20:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants