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

Remove more side effects from application config testing #1684

Merged
merged 3 commits into from
Mar 20, 2023

Conversation

wagoodman
Copy link
Contributor

@wagoodman wagoodman commented Mar 20, 2023

Follow up to #1640 with a few adjustments:

  • remove the symlink during testing since this is writing to paths in the repo (which is not ideal)
  • uses the t.Cleanup facility for each test instead of defer calls
  • removes a side effect against the xdg package based on XDG_CONFIG_PATH env var that persists after the test in the xdg package
  • the homedir package has its own cache which needs to be disabled during testing (since the definition of HOME changes)
  • for users that have a config in the home directory we change HOME to always point to a different (bogus) location so that never enters the equation.
  • restores the application name from .syft to syft when using the XDG_CONFIG_DIRS path (the original behavior)
  • nit: changes t.Fatal to require.NoError calls instead

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
@github-actions
Copy link

github-actions bot commented Mar 20, 2023

Benchmark Test Results

Benchmark results from the latest changes vs base branch
goos: linux
goarch: amd64
pkg: github.com/anchore/syft/test/integration
cpu: Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
                                                          │ ./.tmp/benchmark-76bb978.txt │
                                                          │            sec/op            │
ImagePackageCatalogers/alpmdb-cataloger-2                                   11.83m ± 23%
ImagePackageCatalogers/ruby-gemspec-cataloger-2                             866.0µ ±  1%
ImagePackageCatalogers/python-package-cataloger-2                           3.072m ±  2%
ImagePackageCatalogers/php-composer-installed-cataloger-2                   699.7µ ±  1%
ImagePackageCatalogers/javascript-package-cataloger-2                       364.3µ ±  2%
ImagePackageCatalogers/dpkgdb-cataloger-2                                   530.5µ ±  3%
ImagePackageCatalogers/rpm-db-cataloger-2                                   511.5µ ±  2%
ImagePackageCatalogers/java-cataloger-2                                     11.18m ±  1%
ImagePackageCatalogers/graalvm-native-image-cataloger-2                     8.636µ ±  2%
ImagePackageCatalogers/apkdb-cataloger-2                                    573.7µ ±  3%
ImagePackageCatalogers/go-module-binary-cataloger-2                         19.82µ ±  3%
ImagePackageCatalogers/dotnet-deps-cataloger-2                              1.000m ±  2%
ImagePackageCatalogers/portage-cataloger-2                                  332.4µ ±  2%
ImagePackageCatalogers/sbom-cataloger-2                                     107.3µ ±  1%
ImagePackageCatalogers/binary-cataloger-2                                   187.6µ ±  1%
geomean                                                                     478.9µ

                                                          │ ./.tmp/benchmark-76bb978.txt │
                                                          │             B/op             │
ImagePackageCatalogers/alpmdb-cataloger-2                                   5.061Mi ± 0%
ImagePackageCatalogers/ruby-gemspec-cataloger-2                             123.9Ki ± 0%
ImagePackageCatalogers/python-package-cataloger-2                           947.1Ki ± 0%
ImagePackageCatalogers/php-composer-installed-cataloger-2                   155.9Ki ± 0%
ImagePackageCatalogers/javascript-package-cataloger-2                       90.79Ki ± 0%
ImagePackageCatalogers/dpkgdb-cataloger-2                                   144.9Ki ± 0%
ImagePackageCatalogers/rpm-db-cataloger-2                                   170.2Ki ± 0%
ImagePackageCatalogers/java-cataloger-2                                     2.724Mi ± 0%
ImagePackageCatalogers/graalvm-native-image-cataloger-2                     1.555Ki ± 0%
ImagePackageCatalogers/apkdb-cataloger-2                                    129.1Ki ± 0%
ImagePackageCatalogers/go-module-binary-cataloger-2                         3.133Ki ± 0%
ImagePackageCatalogers/dotnet-deps-cataloger-2                              314.8Ki ± 0%
ImagePackageCatalogers/portage-cataloger-2                                  75.43Ki ± 0%
ImagePackageCatalogers/sbom-cataloger-2                                     13.06Ki ± 0%
ImagePackageCatalogers/binary-cataloger-2                                   29.02Ki ± 0%
geomean                                                                     108.4Ki

                                                          │ ./.tmp/benchmark-76bb978.txt │
                                                          │          allocs/op           │
ImagePackageCatalogers/alpmdb-cataloger-2                                    86.71k ± 0%
ImagePackageCatalogers/ruby-gemspec-cataloger-2                              2.049k ± 0%
ImagePackageCatalogers/python-package-cataloger-2                            15.49k ± 0%
ImagePackageCatalogers/php-composer-installed-cataloger-2                    3.458k ± 0%
ImagePackageCatalogers/javascript-package-cataloger-2                        1.214k ± 0%
ImagePackageCatalogers/dpkgdb-cataloger-2                                    2.646k ± 0%
ImagePackageCatalogers/rpm-db-cataloger-2                                    3.759k ± 0%
ImagePackageCatalogers/java-cataloger-2                                      38.27k ± 0%
ImagePackageCatalogers/graalvm-native-image-cataloger-2                       40.00 ± 0%
ImagePackageCatalogers/apkdb-cataloger-2                                     3.437k ± 0%
ImagePackageCatalogers/go-module-binary-cataloger-2                           101.0 ± 0%
ImagePackageCatalogers/dotnet-deps-cataloger-2                               5.011k ± 0%
ImagePackageCatalogers/portage-cataloger-2                                   1.487k ± 0%
ImagePackageCatalogers/sbom-cataloger-2                                       392.0 ± 0%
ImagePackageCatalogers/binary-cataloger-2                                     872.0 ± 0%
geomean                                                                      2.219k

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
@wagoodman wagoodman requested a review from a team March 20, 2023 20:50
@wagoodman wagoodman enabled auto-merge (squash) March 20, 2023 20:51
@wagoodman wagoodman merged commit 100cf10 into main Mar 20, 2023
@wagoodman wagoodman deleted the tweak-config-tests branch March 20, 2023 20:53
GijsCalis pushed a commit to GijsCalis/syft that referenced this pull request Feb 19, 2024
* remove a few side effects from config testing

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* fix xdg config app name prefix

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

* account for restoring and protecting xdg state throughout testing

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>

---------

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants