-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add simple external test covering cache verification #118
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
ecfabd4
Add simple external test covering cache verification
30e7a67
Add cached usage test
504785c
Reword cache pre-clearing action
ae752f9
Remove extra output checks on second cache test run
0c12052
Remove caching test timing checks
a591443
Remove only the expected layer for the caching test
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// Copyright 2021 VMware, Inc. | ||
// Copyright 2022 VMware, Inc. | ||
// SPDX-License-Identifier: BSD-2-Clause | ||
|
||
package external_test | ||
|
@@ -19,6 +19,15 @@ import ( | |
. "github.com/onsi/gomega/gbytes" | ||
) | ||
|
||
func saveCacheFolder() string { | ||
return filepath.Join(os.TempDir(), "relok8s-save-cache") | ||
} | ||
|
||
func expectedLayerFile() string { | ||
layerFilename := "sha256-24fb2886d6f6c5d16481dd7608b47e78a8e92a13d6e64d87d57cb16d5f766d63.gz" | ||
return filepath.Join(saveCacheFolder(), layerFilename) | ||
} | ||
|
||
var _ = Describe("External tests", func() { | ||
var ( | ||
customRepoPrefix string | ||
|
@@ -75,13 +84,26 @@ var _ = Describe("External tests", func() { | |
}) | ||
|
||
Scenario("running chart move to intermediate bundle", func() { | ||
steps.When("clear relok8s-save-cache expected layer") | ||
steps.When(fmt.Sprintf("running relok8s chart move -y ../fixtures/testchart --image-patterns ../fixtures/testchart.images.yaml --to-intermediate-bundle %s/testchart-intermediate.tar", tmpDir)) | ||
steps.And("the move is computed") | ||
steps.Then("the command says it will archive the chart") | ||
steps.Then("the command says it is writing the hints file") | ||
steps.Then("the command says it is writing the Helm Chart files") | ||
steps.Then("the command says it is writing the container images") | ||
steps.Then("the command says the intermediate bundle is complete") | ||
steps.Then("relok8s-save-cache contains expected layer") | ||
|
||
info, err := os.Stat(expectedLayerFile()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
modtime := info.ModTime() | ||
steps.When(fmt.Sprintf("running relok8s chart move -y ../fixtures/testchart --image-patterns ../fixtures/testchart.images.yaml --to-intermediate-bundle %s/testchart-intermediate-2.tar", tmpDir)) | ||
steps.And("the move is computed") | ||
steps.Then("the command says the intermediate bundle 2 is complete") | ||
steps.Then("relok8s-save-cache contains expected layer") | ||
info, err = os.Stat(expectedLayerFile()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(info.ModTime()).To(Equal(modtime)) | ||
}) | ||
|
||
Scenario("running chart move from intermediate bundle", func() { | ||
|
@@ -261,13 +283,25 @@ var _ = Describe("External tests", func() { | |
Eventually(test.CommandSession.Out, time.Minute).Should(Say("Intermediate bundle complete at %s/testchart-intermediate.tar\n", tmpDir)) | ||
}) | ||
|
||
define.Then(`^the command says the intermediate bundle 2 is complete$`, func() { | ||
Eventually(test.CommandSession.Out, time.Minute).Should(Say("Intermediate bundle complete at %s/testchart-intermediate-2.tar\n", tmpDir)) | ||
}) | ||
|
||
define.Then(`^the command says it is writing the hints file$`, func() { | ||
Eventually(test.CommandSession.Out, time.Minute).Should(Say("Writing hints.yaml...\n")) | ||
}) | ||
|
||
define.Then(`^remove the archive folder at testchart-intermediate.tar$`, func() { | ||
err := os.Remove("testchart-intermediate.tar") | ||
define.When(`^clear relok8s-save-cache expected layer$`, func() { | ||
err := os.RemoveAll(expectedLayerFile()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nice, thanks! |
||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
|
||
define.Then(`^relok8s-save-cache contains expected layer$`, func() { | ||
info, err := os.Stat(expectedLayerFile()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
Expect(info.IsDir()).To(BeFalse()) | ||
Expect(info.Size()).To(Equal(int64(767322))) | ||
Expect(time.Since(info.ModTime())).To(BeNumerically("<", 5*time.Minute)) | ||
}) | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually deleting the cache that's being used by relok8s itself right? I don't like that running a test has the side-effect of deleting the actual tooling cache.
Could we instead run these tests pointing to an unique, per-test cache path? This might require adding support for our tool via ENV variable or flag to point to the cache directory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not want to add more code to be able to test, we already abandoned a change for that.
Maybe I can remove the specific layer instead for the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nah, don't worry about it, we can live with that side-effect I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done