Skip to content

Commit

Permalink
added test cases for rpkg push not latest version & render failiure
Browse files Browse the repository at this point in the history
  • Loading branch information
Catalin-Stratulat-Ericsson committed Dec 2, 2024
1 parent ba4187b commit 563a39d
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 0 deletions.
2 changes: 2 additions & 0 deletions test/e2e/cli/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ type Command struct {
Yaml bool `yaml:"yaml,omitempty"`
// IgnoreWhitespace indicates that whitespace differences should be ignored in the output
IgnoreWhitespace bool `yaml:"ignoreWhitespace,omitempty"`
// StdErrTabToWhitespace replaces "\t" (tab) character with whitespace " "
StdErrTabToWhitespace bool `yaml:"stdErrTabToWhitespace,omitempty"`
}

type TestCaseConfig struct {
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/cli/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ func (s *CliTestSuite) RunTestCase(t *testing.T, tc TestCaseConfig) {
command.Stdout = strings.ReplaceAll(command.Stdout, search, replace)
command.Stderr = strings.ReplaceAll(command.Stderr, search, replace)
}

if command.StdErrTabToWhitespace {
stderrStr = strings.ReplaceAll(stderrStr, "\t", " ") // Replace tabs with spaces
}

if command.IgnoreWhitespace {
command.Stdout = normalizeWhitespace(command.Stdout)
Expand Down
79 changes: 79 additions & 0 deletions test/e2e/cli/testdata/rpkg-push/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,3 +188,82 @@ commands:
name: kptfile.kpt.dev
kind: ResourceList
yaml: true
- args:
- porchctl
- rpkg
- push
- --namespace=rpkg-push
- git-efe3d01c68dfdcdd69114c9a7c65cce0d662a46f
stdin: |
apiVersion: config.kubernetes.io/v1
items:
- apiVersion: ""
kind: KptRevisionMetadata
metadata:
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/path: .KptRevisionMetadata
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: .KptRevisionMetadata
name: git-efe3d01c68dfdcdd69114c9a7c65cce0d662a46f
namespace: rpkg-push
uid: 8d61685e-584c-5b89-bd30-a8d8dccb13f9
resourceVersion: "1"
- apiVersion: kpt.dev/v1
info:
description: Updated Test Package Description
kind: Kptfile
metadata:
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/local-config: "true"
config.kubernetes.io/path: Kptfile
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: Kptfile
name: test-package
- apiVersion: v1
data:
name: example
kind: ConfigMap
metadata:
annotations:
config.kubernetes.io/index: "0"
config.kubernetes.io/local-config: "true"
config.kubernetes.io/path: package-context.yaml
internal.config.kubernetes.io/index: "0"
internal.config.kubernetes.io/path: package-context.yaml
name: kptfile.kpt.dev
kind: ResourceList
stderr: |
Error: Internal error occurred: Operation cannot be fulfilled on packagerevisionresources.porch.kpt.dev "git-efe3d01c68dfdcdd69114c9a7c65cce0d662a46f": the object has been modified; please apply your changes to the latest version and try again
exitCode: 1
yaml: true
- args:
- porchctl
- rpkg
- pull
- --namespace=rpkg-push
- git-efe3d01c68dfdcdd69114c9a7c65cce0d662a46f
- /tmp/porch-e2e/testing-invalid-render
- args:
- sh
- -c
- |
echo "pipeline:\n mutators:\n - image: gcr.io/kpt-fn/set-namespace:v0.4.0\n configMap:\n namespace: example-ns\n - image: gcr.io/kpt-fn/set-annotations:v0.1.4\n" >> /tmp/porch-e2e/testing-invalid-render/Kptfile
- args:
- porchctl
- rpkg
- push
- --namespace=rpkg-push
- git-efe3d01c68dfdcdd69114c9a7c65cce0d662a46f
- /tmp/porch-e2e/testing-invalid-render
stderr: |
Error: Internal error occurred: fn.render: pkg /:
pkg.render:
pipeline.run: func eval "gcr.io/kpt-fn/set-annotations:v0.1.4" failed: rpc error: code = Internal desc = Failed to execute function "gcr.io/kpt-fn/set-annotations:v0.1.4": exit status 1 ([error] : failed to configure function: `functionConfig` must be a `ConfigMap` or `SetAnnotations`)
Error occurred rendering package in kpt function pipeline.
Package has NOT been pushed to remote.
Please fix package locally (modify until 'kpt fn render' succeeds) and retry.
stdErrTabToWhitespace: true
exitCode: 1

0 comments on commit 563a39d

Please sign in to comment.