This repository was archived by the owner on Sep 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
appliance: golden/snapshot testing #62034
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8aa9183
appliance: golden/snapshot testing
84b0fde
fixup! appliance: golden/snapshot testing
c030346
Update internal/appliance/kubernetes_test.go
98b7cd7
Update internal/appliance/kubernetes_test.go
f811a0f
squashme: add appliance image default with TODO
b69e5b7
squashme: consistent receiver name
59317ef
go fmt
e01cda6
squashme: make exportloopref happy
d3855b4
Bazel integration for appliance tests
5d4b0a2
Fix deps.bzl
e968c63
Forward test kube stdio to debug failure
4d57d7d
Give network to test
d64128f
Revert "Give network to test"
3278322
Try binding localhost only with no test network
82fd013
Incorporate golden file changes from rebase
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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 +1,46 @@ | ||
package appliance | ||
|
||
import ( | ||
"time" | ||
) | ||
|
||
// Simple test cases in which we want to assert that a given configmap causes a | ||
// certain set of resources to be deployed can go here. sg and golden fixtures | ||
// are in testdata/ and named after the test case name. | ||
func (suite *ApplianceTestSuite) TestDeployBlobstore() { | ||
for _, tc := range []struct { | ||
name string | ||
}{ | ||
{ | ||
name: "blobstore-default", | ||
}, | ||
} { | ||
suite.Run(tc.name, func() { | ||
namespace := suite.createConfigMap(tc.name) | ||
|
||
// Wait for reconciliation to be finished. | ||
suite.Require().Eventually(func() bool { | ||
return suite.getConfigMapReconcileEventCount(namespace) > 0 | ||
}, time.Second*10, time.Millisecond*200) | ||
|
||
suite.makeGoldenAssertions(namespace, tc.name) | ||
}) | ||
} | ||
} | ||
Comment on lines
+7
to
+29
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. Example of what I am guessing 80% of appliance tests will be: deploy some config, assert on the resultant resource set. Adding new cases is as simple as:
Failing tests print golden file diffs, and reconciler logs. |
||
|
||
// More complex test cases involving updates to the configmap can have their own | ||
// test blocks | ||
func (suite *ApplianceTestSuite) TestBlobstoreResourcesDeletedWhenDisabled() { | ||
namespace := suite.createConfigMap("blobstore-default") | ||
suite.Require().Eventually(func() bool { | ||
return suite.getConfigMapReconcileEventCount(namespace) > 0 | ||
}, time.Second*10, time.Millisecond*200) | ||
|
||
eventsSeenSoFar := suite.getConfigMapReconcileEventCount(namespace) | ||
suite.updateConfigMap(namespace, "everything-disabled") | ||
suite.Require().Eventually(func() bool { | ||
return suite.getConfigMapReconcileEventCount(namespace) > eventsSeenSoFar | ||
}, time.Second*10, time.Millisecond*200) | ||
|
||
suite.makeGoldenAssertions(namespace, "blobstore-subsequent-disable") | ||
} | ||
Comment on lines
+31
to
+46
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. Example of a more bespoke test that updates the configmap after creating it. If we ever find we need to do complex k8s resource upgrades (not just bumping versions), we can hopefully test that in this way. |
This file contains hidden or 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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Appliance development | ||
|
||
## Running tests | ||
|
||
To (re)generate golden fixtures, pass the following argument to `go test`: | ||
|
||
``` | ||
go test -args appliance-update-golden-files | ||
``` | ||
|
||
In order to run `go test` (with or without arguments), you must have | ||
`setup-envtest` available: | ||
|
||
``` | ||
go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest | ||
``` | ||
|
||
This is not a requirement for the Bazel environment (`bazel test | ||
:appliance_test` in this module). |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.