mirror of https://github.com/knative/func.git
test improvements remove deprecates avoid nils, bump go version 1.20.x (#2032)
* test: improvements on e2e extended test: remove deprecates, avoid nils and improve match conditions * update go version on ci to 1.20.x
This commit is contained in:
parent
788f18c61f
commit
3641bfe5d0
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Build
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Check Source
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -11,7 +11,7 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "1.20.2"
|
||||
go-version: "1.20.x"
|
||||
- name: Lint
|
||||
run: make check && make check-templates
|
||||
- name: Check that 'func.yaml schema' is up-to-date
|
||||
|
@ -22,7 +22,7 @@ jobs:
|
|||
test-unit:
|
||||
strategy:
|
||||
matrix:
|
||||
go: [ 1.20.2 ]
|
||||
go: [ 1.20.x ]
|
||||
java: [ 17 ]
|
||||
os: [ "ubuntu-latest", "windows-latest", "macos-latest" ]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
@ -50,7 +50,7 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "1.20.2"
|
||||
go-version: "1.20.x"
|
||||
- name: Install Binaries
|
||||
run: ./hack/binaries.sh
|
||||
- name: Allocate Cluster
|
||||
|
@ -67,7 +67,7 @@ jobs:
|
|||
e2e-test:
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
@ -91,7 +91,7 @@ jobs:
|
|||
e2e-on-cluster-test:
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
@ -126,7 +126,7 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "1.20.2"
|
||||
go-version: "1.20.x"
|
||||
# Standard build tasks
|
||||
- name: Build
|
||||
run: make cross-platform
|
||||
|
@ -167,6 +167,6 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: "1.20.2"
|
||||
go-version: "1.20.x"
|
||||
- uses: imjasonh/setup-ko@v0.6
|
||||
- run: ko build --platform=linux/ppc64le,linux/s390x,linux/amd64,linux/arm64 -B ./cmd/func
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Check Schema
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -8,7 +8,7 @@ jobs:
|
|||
continue-on-error: true
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
func_builder: ["pack", "s2i"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: On Cluster Test
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -18,7 +18,7 @@ jobs:
|
|||
- uses: actions/checkout@v3
|
||||
- uses: actions/setup-go@v3
|
||||
with:
|
||||
go-version: 1.20.2
|
||||
go-version: 1.20.x
|
||||
- name: Install Binaries
|
||||
run: ./hack/binaries.sh
|
||||
- name: Allocate Cluster
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: E2E Test
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Func Embedded FS Test
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Integration Test
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Podman Test
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
os: ["ubuntu-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
|
|
|
@ -7,7 +7,7 @@ jobs:
|
|||
name: Unit Test
|
||||
strategy:
|
||||
matrix:
|
||||
go: [1.20.2]
|
||||
go: [1.20.x]
|
||||
java: [17]
|
||||
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
|
|
@ -131,6 +131,7 @@ networking() {
|
|||
|
||||
echo "Install load balancer."
|
||||
kubectl apply -f "https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml"
|
||||
sleep 5
|
||||
kubectl wait --namespace metallb-system \
|
||||
--for=condition=ready pod \
|
||||
--selector=app=metallb \
|
||||
|
|
|
@ -14,6 +14,10 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/docker/docker/api/types/filters"
|
||||
"github.com/docker/docker/api/types/volume"
|
||||
"github.com/docker/docker/client"
|
||||
|
||||
"knative.dev/func/pkg/builders/buildpacks"
|
||||
"knative.dev/func/pkg/docker"
|
||||
fn "knative.dev/func/pkg/functions"
|
||||
|
@ -530,6 +534,27 @@ func del(t *testing.T, c *fn.Client, name string) {
|
|||
if err := c.Remove(context.Background(), fn.Function{Name: name}, false); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
cli, _, err := docker.NewClient(client.DefaultDockerHost)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer cli.Close()
|
||||
opts := volume.ListOptions{
|
||||
Filters: filters.NewArgs(
|
||||
filters.Arg("name", fmt.Sprintf("pack-cache-func_%s_*", name)),
|
||||
),
|
||||
}
|
||||
resp, err := cli.VolumeList(context.Background(), opts)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, vol := range resp.Volumes {
|
||||
t.Log("deleting volume:", vol.Name)
|
||||
err = cli.VolumeRemove(context.Background(), vol.Name, true)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// waitFor the named function to become available in List output.
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -8,7 +9,7 @@ import (
|
|||
)
|
||||
|
||||
func WaitForFunctionReady(t *testing.T, functionName string) (revisionName string, functionUrl string) {
|
||||
err := wait.PollImmediate(5*time.Second, 1*time.Minute, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, 1*time.Minute, true, func(ctx context.Context) (done bool, err error) {
|
||||
revisionName, functionUrl = GetKnativeServiceRevisionAndUrl(t, functionName)
|
||||
t.Logf("Waiting function to get ready (revision [%v])", revisionName)
|
||||
return revisionName != "", nil
|
||||
|
@ -21,7 +22,7 @@ func WaitForFunctionReady(t *testing.T, functionName string) (revisionName strin
|
|||
|
||||
// NewRevisionCheck waits for a new revision to report as ready
|
||||
func WaitForNewRevisionReady(t *testing.T, previousRevision string, functionName string) (newRevision string) {
|
||||
err := wait.PollImmediate(5*time.Second, 1*time.Minute, func() (done bool, err error) {
|
||||
err := wait.PollUntilContextTimeout(context.Background(), 5*time.Second, 1*time.Minute, true, func(ctx context.Context) (done bool, err error) {
|
||||
newRevision = GetCurrentServiceRevision(t, functionName)
|
||||
t.Logf("Waiting for new revision deployment (previous revision [%v], current revision [%v])", previousRevision, newRevision)
|
||||
return newRevision != "" && newRevision != previousRevision, nil
|
||||
|
|
|
@ -60,11 +60,19 @@ func TestFunctionExtendedFlow(t *testing.T) {
|
|||
funcPort, attempts := "", 0
|
||||
for funcPort == "" && attempts < 10 {
|
||||
t.Logf("----Function Output:\n%v\n", stdout.String())
|
||||
matches := regexp.MustCompile("Running on host port (.*)").FindStringSubmatch(stdout.String())
|
||||
findPort := func(exp string, msg string) (port string) {
|
||||
matches := regexp.MustCompile(exp).FindStringSubmatch(msg)
|
||||
if len(matches) > 1 {
|
||||
port = matches[1]
|
||||
}
|
||||
return
|
||||
}
|
||||
funcPort = findPort("Running on host port (.*)", stdout.String())
|
||||
if funcPort == "" {
|
||||
funcPort = findPort("Function started on port (.*)", stdout.String())
|
||||
}
|
||||
attempts++
|
||||
if len(matches) > 1 {
|
||||
funcPort = matches[1]
|
||||
} else {
|
||||
if funcPort == "" {
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
}
|
||||
|
@ -92,7 +100,7 @@ func TestFunctionExtendedFlow(t *testing.T) {
|
|||
time.Sleep(time.Second)
|
||||
|
||||
// GET Function HTTP Endpoint
|
||||
_, bodyResp := testhttp.TestGet(t, "http://:"+funcPort+"?message=local")
|
||||
_, bodyResp := testhttp.TestGet(t, "http://localhost:"+funcPort+"?message=local")
|
||||
assert.Assert(t, strings.Contains(bodyResp, `{"message":"local"}`), "function response does not contain expected body.")
|
||||
|
||||
// ---------------------------
|
||||
|
|
|
@ -77,7 +77,7 @@ func TestFunctionRunWithoutContainer(t *testing.T) {
|
|||
time.Sleep(time.Second)
|
||||
|
||||
// Assert Function endpoint responds
|
||||
_, bodyResp := testhttp.TestGet(t, "http://:"+funcPort+"?message=run-on-host")
|
||||
_, bodyResp := testhttp.TestGet(t, "http://localhost:"+funcPort+"?message=run-on-host")
|
||||
assert.Assert(t, strings.Contains(bodyResp, `GET /?message=run-on-host`), "function response does not contain expected body.")
|
||||
|
||||
// Assert Func were not built
|
||||
|
|
Loading…
Reference in New Issue