这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@knqyf263
Copy link
Collaborator

@knqyf263 knqyf263 commented May 4, 2020

Overview

gunzipDB copies a database file to the temporal directory every time. It consumes a lot of disk spaces even if the file is removed by defer os.RemoveAll(cacheDir). This is because the test process is still running, so the removed file can't be seen, but exists until the test process finishes.
ref. https://access.redhat.com/solutions/2316

After all, it reaches the capacity of disk and returns the error "no space left on device". This PR changed tests so that the database file can be copied only once.

Blocker

@knqyf263 knqyf263 added the kind/testing Categorizes issue or PR as related to a unit/integration test. label May 4, 2020
@knqyf263 knqyf263 self-assigned this May 4, 2020
@knqyf263 knqyf263 requested a review from simar7 May 4, 2020 15:55
case tc.expectedError != "":
require.NotNil(t, err)
assert.Contains(t, err.Error(), tc.expectedError, tc.name)
return
Copy link
Member

Choose a reason for hiding this comment

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

Is this needed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, in this case, an error is expected. It means we don't have to compare want and got. The original code is the following.

switch {
case tc.expectedError != "":
    require.NotNil(t, err)
    assert.Contains(t, err.Error(), tc.expectedError, tc.name
default:
    ...
}

if !tc.invalidImage {
    // compare want and got
    ...
}

So, I've changed it to the following

switch {
case tc.expectedError != "":
    require.NotNil(t, err)
    assert.Contains(t, err.Error(), tc.expectedError, tc.name
    return
default:
    ...
}

// compare want and got
compare()

I prefer a shallow nest.

@knqyf263 knqyf263 merged commit 09442d6 into master May 5, 2020
@knqyf263 knqyf263 deleted the github_actions branch May 5, 2020 08:14
masahiro331 pushed a commit to masahiro331/trivy that referenced this pull request May 26, 2020
* fix(standalone): add defer to close databases

* test(client/server): launch a server only once

* test(docker_engine): remove the duplicated case

* test(docker_engine): copy a database only once

* test(standalone): copy a database only once

* test(server): fix tests according to updated mock

* chore(mod): update

* chore(ci): add integration tests to GitHub Actions

* chore(ci): bump up Go to 1.14

* chore(ci): remove integration tests from CircleCI

* chore(ci): add name

* chore(ci): add new lines
GuaoGuao pushed a commit to GuaoGuao/trivy that referenced this pull request Jun 24, 2020
* fix(standalone): add defer to close databases

* test(client/server): launch a server only once

* test(docker_engine): remove the duplicated case

* test(docker_engine): copy a database only once

* test(standalone): copy a database only once

* test(server): fix tests according to updated mock

* chore(mod): update

* chore(ci): add integration tests to GitHub Actions

* chore(ci): bump up Go to 1.14

* chore(ci): remove integration tests from CircleCI

* chore(ci): add name

* chore(ci): add new lines
liamg pushed a commit that referenced this pull request Jun 7, 2022
* fix(standalone): add defer to close databases

* test(client/server): launch a server only once

* test(docker_engine): remove the duplicated case

* test(docker_engine): copy a database only once

* test(standalone): copy a database only once

* test(server): fix tests according to updated mock

* chore(mod): update

* chore(ci): add integration tests to GitHub Actions

* chore(ci): bump up Go to 1.14

* chore(ci): remove integration tests from CircleCI

* chore(ci): add name

* chore(ci): add new lines
liamg pushed a commit that referenced this pull request Jun 7, 2022
liamg pushed a commit that referenced this pull request Jun 7, 2022
josedonizetti pushed a commit to josedonizetti/trivy that referenced this pull request Jun 24, 2022
…init' (aquasecurity#485)

Signed-off-by: Liam Galvin <liam.galvin@aquasec.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/testing Categorizes issue or PR as related to a unit/integration test.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants