Skip to content

Commit

Permalink
test: e2e test for direct upload on-cluster-build
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Vasek <mvasek@redhat.com>
  • Loading branch information
matejvasek committed Oct 17, 2022
1 parent fea375f commit d61b6b7
Showing 1 changed file with 48 additions and 2 deletions.
50 changes: 48 additions & 2 deletions test/_oncluster/scenario_basic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,57 @@ import (
e2e "knative.dev/func/test/_e2e"
)

// TestBasicUpload check if direct source upload works
func TestBasicUpload(t *testing.T) {

var funcName = "test-func-basic-upload"
var funcPath = filepath.Join(t.TempDir(), funcName)

knFunc := common.NewKnFuncShellCli(t)
knFunc.Exec("create", "-l", "node", funcPath)

// Write an `index.js` that make node func to return 'first revision'
WriteNewSimpleIndexJS(t, funcPath, "first revision")

// Deploy it
knFunc.Exec("deploy",
"-p", funcPath,
"-r", e2e.GetRegistry(),
"--remote",
)
t.Cleanup(func() { _ = knFunc.Exec("delete", "-p", funcPath) })

// Assert "first revision" is returned
result := knFunc.Exec("invoke", "-p", funcPath)
assert.Assert(t, strings.Contains(result.Stdout, "first revision"), "Func body does not contain 'first revision'")

previousServiceRevision := e2e.GetCurrentServiceRevision(t, funcName)

// Update index.js to force node func to return 'new revision'
WriteNewSimpleIndexJS(t, funcPath, "new revision")

// Re-Deploy Func
knFunc.Exec("deploy",
"-r", e2e.GetRegistry(),
"-p", funcPath,
"--remote")
e2e.NewRevisionCheck(t, previousServiceRevision, funcName) // Wait New Service Revision

// -- Assertions --
result = knFunc.Exec("invoke", "-p", funcPath)
assert.Assert(t, strings.Contains(result.Stdout, "new revision"), "Func body does not contain 'new revision'")
AssertThatTektonPipelineRunSucceed(t, funcName)

_ = knFunc.Exec("delete", "-p", funcPath)
AssertThatTektonPipelineResourcesNotExists(t, funcName)

}

// TestDefault covers basic test scenario that ensure on cluster build from a "default branch" and
// code changes (new commits) will be properly built and deployed on new revision
func TestBasicDefault(t *testing.T) {
func TestBasicGit(t *testing.T) {

var funcName = "test-func-basic"
var funcName = "test-func-basic-git"
var funcPath = filepath.Join(t.TempDir(), funcName)

func() {
Expand Down

0 comments on commit d61b6b7

Please sign in to comment.