Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile.utils
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ LABEL \
org.opencontainers.image.vendor="https://github.com/knative/func" \
org.opencontainers.image.url="https://github.com/knative/func/pkgs/container/func-utils"

USER 0:0
USER 1001:0
75 changes: 75 additions & 0 deletions e2e/e2e_remote_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"
"os"
"os/exec"
"path/filepath"
"testing"
)

Expand Down Expand Up @@ -164,3 +165,77 @@ func TestRemote_Dir(t *testing.T) {
t.Fatal("function did not deploy correctly")
}
}

// TestRemote_Update ensures that a function deployed remotely can be
// updated with a subsequent remote deployment.
//
// func deploy --remote (first)
// func deploy --remote --build (subsequent)
func TestRemote_Update(t *testing.T) {
name := "func-e2e-test-remote-update"
_ = fromCleanEnv(t, name)

// Initialize
if err := newCmd(t, "init", "-l=go").Run(); err != nil {
t.Fatal(err)
}

// First deploy
if err := newCmd(t, "deploy", "--remote", "--builder=pack", fmt.Sprintf("--registry=%s", ClusterRegistry)).Run(); err != nil {
t.Fatal(err)
}
defer func() {
clean(t, name, Namespace)
}()

if !waitFor(t, ksvcUrl(name)) {
t.Fatal("first deploy: function did not deploy correctly")
}

// Subsequent deploy (force rebuild)
if err := newCmd(t, "deploy", "--remote", "--build", "--builder=pack", fmt.Sprintf("--registry=%s", ClusterRegistry)).Run(); err != nil {
t.Fatal(err)
}

if !waitFor(t, ksvcUrl(name)) {
t.Fatal("subsequent deploy: function did not deploy correctly")
}
}

// TestRemote_Update_Python ensures that a Python function deployed remotely
// can be updated with a subsequent remote deployment.
// This test uses s2i builder as pack does not support Python.
// Uses the echo template from testdata since default Python template returns "OK".
//
// func deploy --remote --builder=s2i (first)
// func deploy --remote --builder=s2i --build (subsequent)
func TestRemote_Update_Python(t *testing.T) {
name := "func-e2e-test-remote-update-py"
_ = fromCleanEnv(t, name)

// Initialize Python function with echo template
if err := newCmd(t, "init", "-l=python", "--repository", "file://"+filepath.Join(Testdata, "templates")).Run(); err != nil {
t.Fatal(err)
}

// First deploy
if err := newCmd(t, "deploy", "--remote", "--builder=s2i", fmt.Sprintf("--registry=%s", ClusterRegistry)).Run(); err != nil {
t.Fatal(err)
}
defer func() {
clean(t, name, Namespace)
}()

if !waitFor(t, ksvcUrl(name)) {
t.Fatal("first deploy: function did not deploy correctly")
}

// Subsequent deploy (force rebuild)
if err := newCmd(t, "deploy", "--remote", "--build", "--builder=s2i", fmt.Sprintf("--registry=%s", ClusterRegistry)).Run(); err != nil {
t.Fatal(err)
}

if !waitFor(t, ksvcUrl(name)) {
t.Fatal("subsequent deploy: function did not deploy correctly")
}
}
12 changes: 12 additions & 0 deletions pkg/pipelines/tekton/templates_pack.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ spec:
{{end}}
pipelineRef:
name: {{.PipelineName}}
taskRunTemplate:
podTemplate:
securityContext:
fsGroup: 1001
runAsUser: 1001
runAsGroup: 0
workspaces:
- name: source-workspace
persistentVolumeClaim:
Expand Down Expand Up @@ -173,6 +179,12 @@ spec:
{{end}}
pipelineRef:
name: {{.PipelineName}}
taskRunTemplate:
podTemplate:
securityContext:
fsGroup: 1001
runAsUser: 1001
runAsGroup: 0
workspaces:
- name: source-workspace
persistentVolumeClaim:
Expand Down
12 changes: 12 additions & 0 deletions pkg/pipelines/tekton/templates_s2i.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ spec:
value: {{.TlsVerify}}
pipelineRef:
name: {{.PipelineName}}
taskRunTemplate:
podTemplate:
securityContext:
fsGroup: 1001
runAsUser: 1001
runAsGroup: 0
workspaces:
- name: source-workspace
persistentVolumeClaim:
Expand Down Expand Up @@ -195,6 +201,12 @@ spec:
value: {{.TlsVerify}}
pipelineRef:
name: {{.PipelineName}}
taskRunTemplate:
podTemplate:
securityContext:
fsGroup: 1001
runAsUser: 1001
runAsGroup: 0
workspaces:
- name: source-workspace
persistentVolumeClaim:
Expand Down
Loading