-
Notifications
You must be signed in to change notification settings - Fork 173
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
test: change e2e tests to use new log format #3318
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
f1d35ed
begin moving things
AustinAbro321 cda7ce3
Merge branch 'main' into move-e2e-log-format
AustinAbro321 2138c70
0,1,2 passsing
AustinAbro321 774c265
skeleton suite working
AustinAbro321 86057da
pass context
AustinAbro321 a78442c
Merge branch 'main' into move-e2e-log-format
AustinAbro321 413ccd1
merge things
AustinAbro321 9581a66
e2e
AustinAbro321 23f125c
tests with slogger
AustinAbro321 954d0a6
context
AustinAbro321 d0939ee
context
AustinAbro321 b9355a4
order
AustinAbro321 14ee3e9
lint testing
AustinAbro321 ac65e60
caps
AustinAbro321 aa00896
add external tests
AustinAbro321 eefd78a
move bin path
AustinAbro321 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
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
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
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
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
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
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 |
---|---|---|
|
@@ -19,9 +19,11 @@ import ( | |
"github.com/stretchr/testify/suite" | ||
"github.com/zarf-dev/zarf/src/api/v1alpha1" | ||
"github.com/zarf-dev/zarf/src/pkg/layout" | ||
"github.com/zarf-dev/zarf/src/pkg/logger" | ||
"github.com/zarf-dev/zarf/src/pkg/transform" | ||
"github.com/zarf-dev/zarf/src/pkg/utils" | ||
"github.com/zarf-dev/zarf/src/pkg/zoci" | ||
"github.com/zarf-dev/zarf/src/test" | ||
"github.com/zarf-dev/zarf/src/test/testutil" | ||
corev1 "k8s.io/api/core/v1" | ||
"oras.land/oras-go/v2/registry" | ||
|
@@ -65,18 +67,15 @@ func (suite *PublishCopySkeletonSuite) Test_0_Publish_Skeletons() { | |
ref := suite.Reference.String() | ||
|
||
helmCharts := filepath.Join("examples", "helm-charts") | ||
_, stdErr, err := e2e.Zarf(suite.T(), "package", "publish", helmCharts, "oci://"+ref, "--plain-http") | ||
_, _, err := e2e.Zarf(suite.T(), "package", "publish", helmCharts, "oci://"+ref, "--plain-http") | ||
suite.NoError(err) | ||
suite.Contains(stdErr, "Published "+ref) | ||
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. 👍 to fewer |
||
|
||
composable := filepath.Join("src", "test", "packages", "09-composable-packages") | ||
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", composable, "oci://"+ref, "--plain-http") | ||
_, _, err = e2e.Zarf(suite.T(), "package", "publish", composable, "oci://"+ref, "--plain-http") | ||
suite.NoError(err) | ||
suite.Contains(stdErr, "Published "+ref) | ||
|
||
_, stdErr, err = e2e.Zarf(suite.T(), "package", "publish", importEverything, "oci://"+ref, "--plain-http") | ||
_, _, err = e2e.Zarf(suite.T(), "package", "publish", importEverything, "oci://"+ref, "--plain-http") | ||
suite.NoError(err) | ||
suite.Contains(stdErr, "Published "+ref) | ||
|
||
_, _, err = e2e.Zarf(suite.T(), "package", "inspect", "oci://"+ref+"/import-everything:0.0.1", "--plain-http", "-a", "skeleton") | ||
suite.NoError(err) | ||
|
@@ -190,6 +189,7 @@ func (suite *PublishCopySkeletonSuite) Test_3_Copy() { | |
dstRegistry := testutil.SetupInMemoryRegistry(testutil.TestContext(t), t, 31890) | ||
dstRef := strings.Replace(ref, suite.Reference.Registry, dstRegistry, 1) | ||
ctx := testutil.TestContext(t) | ||
ctx = logger.WithContext(ctx, test.GetLogger(t)) | ||
|
||
src, err := zoci.NewRemote(ctx, ref, oci.PlatformForArch(e2e.Arch), oci.WithPlainHTTP(true)) | ||
suite.NoError(err) | ||
|
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 |
---|---|---|
|
@@ -44,7 +44,7 @@ func TestZarfInit(t *testing.T) { | |
// We need to use the --architecture flag here to force zarf to find the package. | ||
_, stdErr, err = e2e.Zarf(t, "init", "--architecture", mismatchedArch, "--components=k3s", "--confirm") | ||
require.Error(t, err, stdErr) | ||
require.Contains(t, e2e.StripMessageFormatting(stdErr), expectedErrorMessage) | ||
require.Contains(t, stdErr, expectedErrorMessage) | ||
} | ||
|
||
if !e2e.ApplianceMode { | ||
|
@@ -64,12 +64,8 @@ func TestZarfInit(t *testing.T) { | |
} | ||
|
||
// run `zarf init` | ||
_, initStdErr, err := e2e.Zarf(t, "init", "--components="+initComponents, "--nodeport", "31337", "-l", "trace", "--confirm") | ||
_, _, err = e2e.Zarf(t, "init", "--components="+initComponents, "--nodeport", "31337", "--confirm") | ||
require.NoError(t, err) | ||
require.Contains(t, initStdErr, "an inventory of all software contained in this package") | ||
require.NotContains(t, initStdErr, "This package does NOT contain an SBOM. If you require an SBOM, please contact the creator of this package to request a version that includes an SBOM.") | ||
|
||
logText := e2e.GetLogFileContents(t, e2e.StripMessageFormatting(initStdErr)) | ||
|
||
// Verify that any state secrets were not included in the log | ||
state := types.ZarfState{} | ||
|
@@ -79,7 +75,6 @@ func TestZarfInit(t *testing.T) { | |
require.NoError(t, err) | ||
err = json.Unmarshal(stateJSON, &state) | ||
require.NoError(t, err) | ||
checkLogForSensitiveState(t, logText, state) | ||
|
||
if e2e.ApplianceMode { | ||
// make sure that we upgraded `k3s` correctly and are running the correct version - this should match that found in `packages/distros/k3s` | ||
|
@@ -108,23 +103,6 @@ func TestZarfInit(t *testing.T) { | |
_, _, _ = e2e.Kubectl(t, "scale", "deploy", "-n", "zarf", "agent-hook", "--replicas=1") //nolint:errcheck | ||
} | ||
|
||
func checkLogForSensitiveState(t *testing.T, logText string, zarfState types.ZarfState) { | ||
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. Do we have unit test coverage for zarfState redactions? |
||
t.Helper() | ||
|
||
require.NotContains(t, logText, zarfState.AgentTLS.CA) | ||
require.NotContains(t, logText, string(zarfState.AgentTLS.CA)) | ||
require.NotContains(t, logText, zarfState.AgentTLS.Cert) | ||
require.NotContains(t, logText, string(zarfState.AgentTLS.Cert)) | ||
require.NotContains(t, logText, zarfState.AgentTLS.Key) | ||
require.NotContains(t, logText, string(zarfState.AgentTLS.Key)) | ||
require.NotContains(t, logText, zarfState.ArtifactServer.PushToken) | ||
require.NotContains(t, logText, zarfState.GitServer.PullPassword) | ||
require.NotContains(t, logText, zarfState.GitServer.PushPassword) | ||
require.NotContains(t, logText, zarfState.RegistryInfo.PullPassword) | ||
require.NotContains(t, logText, zarfState.RegistryInfo.PushPassword) | ||
require.NotContains(t, logText, zarfState.RegistryInfo.Secret) | ||
} | ||
|
||
func verifyZarfNamespaceLabels(t *testing.T) { | ||
t.Helper() | ||
|
||
|
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
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
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
Oops, something went wrong.
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.
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.
👍