Skip to content
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

Use github action for kfserving controller tests #1056

Merged
merged 9 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Go

on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

jobs:

build:
name: Build
runs-on: ubuntu-latest
steps:

- name: Set up Go 1.x
uses: actions/setup-go@v2
with:
go-version: ^1.14
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2

- name: Get dependencies
yuzisun marked this conversation as resolved.
Show resolved Hide resolved
run: |
go get -v -t -d ./...

- name: Test
run: |
export GOPATH=/home/runner/go
export PATH=$PATH:/usr/local/kubebuilder/bin
make test
17 changes: 15 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ $(shell perl -pi -e 's/memory:.*/memory: $(KFSERVING_CONTROLLER_MEMORY_LIMIT)/'
all: test manager logger batcher

# Run tests
test: fmt vet manifests
go test ./pkg/... ./cmd/... -coverprofile cover.out
test: fmt vet manifests kubebuilder
go test ./pkg/... ./cmd/... -coverprofile coverage.out

# Build manager binary
manager: generate fmt vet lint
Expand Down Expand Up @@ -184,6 +184,19 @@ docker-build-storageInitializer:
docker-push-storageInitializer: docker-build-storageInitializer
docker push ${KO_DOCKER_REPO}/${STORAGE_INIT_IMG}

kubebuilder:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need kb as a dependency? This is for generating controllers, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is for make test which requires local apiserver/etcd which is installed part of kubebuilder

ifeq (, $(shell which kubebuilder))
@{ \
set -e ;\
os=$$(go env GOOS) ; \
arch=$$(go env GOARCH) ;\
curl -L "https://go.kubebuilder.io/dl/2.3.1/$${os}/$${arch}" | tar -xz -C /tmp/ ;\
sudo mkdir -p /usr/local/kubebuilder/bin/ ;\
sudo mv /tmp/kubebuilder_2.3.1_$${os}_$${arch}/bin/* /usr/local/kubebuilder/bin/ ;\
echo "Add /usr/local/kubebuilder/bin/ to your PATH!!" ;\
}
endif

controller-gen:
ifeq (, $(shell which controller-gen))
@{ \
Expand Down
14 changes: 7 additions & 7 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ package main

import (
"flag"
"github.com/kubeflow/kfserving/pkg/apis/serving/v1alpha2"
"github.com/kubeflow/kfserving/pkg/apis/serving/v1beta1"
v1alph2controller "github.com/kubeflow/kfserving/pkg/controller/inferenceservice"
trainedmodelcontroller "github.com/kubeflow/kfserving/pkg/controller/v1beta1/trainedmodel"
"github.com/kubeflow/kfserving/pkg/controller/v1beta1/trainedmodel/reconcilers/modelconfig"
"github.com/kubeflow/kfserving/pkg/webhook/admission/inferenceservice"
"github.com/kubeflow/kfserving/pkg/webhook/admission/pod"
Expand All @@ -26,20 +30,16 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/client-go/kubernetes"
typedcorev1 "k8s.io/client-go/kubernetes/typed/core/v1"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
"k8s.io/client-go/tools/record"
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
"os"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/webhook"
"github.com/kubeflow/kfserving/pkg/apis/serving/v1alpha2"
"github.com/kubeflow/kfserving/pkg/apis/serving/v1beta1"
v1alph2controller "github.com/kubeflow/kfserving/pkg/controller/inferenceservice"
trainedmodelcontroller "github.com/kubeflow/kfserving/pkg/controller/v1beta1/trainedmodel"
_ "k8s.io/client-go/plugin/pkg/client/auth/gcp"
knservingv1 "knative.dev/serving/pkg/apis/serving/v1"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
logf "sigs.k8s.io/controller-runtime/pkg/runtime/log"
"sigs.k8s.io/controller-runtime/pkg/runtime/signals"
"sigs.k8s.io/controller-runtime/pkg/webhook"
)

var (
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5Kwzbycv
github.com/fortytw2/leaktest v1.3.0/go.mod h1:jDsjWgpAGjm2CA7WthBh/CdZYEPF31XHquHwclZch5g=
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
github.com/getkin/kin-openapi v0.2.0 h1:PbHHtYZpjKwZtGlIyELgA2DploRrsaXztoNNx9HjwNY=
github.com/getkin/kin-openapi v0.2.0/go.mod h1:V1z9xl9oF5Wt7v32ne4FmiF1alpS4dM6mNzoywPOXlk=
Expand Down
10 changes: 8 additions & 2 deletions pkg/controller/inferenceservice/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package service

import (
"fmt"
"k8s.io/client-go/util/retry"
"reflect"
"sort"
"time"
Expand Down Expand Up @@ -846,7 +847,9 @@ var _ = Describe("test inference service controller", func() {
// Canary service should be removed during reconcile
canaryUpdate.Spec.Canary = nil
canaryUpdate.Spec.CanaryTrafficPercent = 0
g.Expect(k8sClient.Update(context.TODO(), canaryUpdate)).NotTo(gomega.HaveOccurred())
err := retry.RetryOnConflict(retry.DefaultRetry, func() error {
return k8sClient.Update(context.TODO(), canaryUpdate)
})
// Need to wait for update propagate back to controller before checking
canaryDelete := &kfserving.InferenceService{}
g.Eventually(func() bool {
Expand All @@ -856,7 +859,10 @@ var _ = Describe("test inference service controller", func() {
return canaryDelete.Spec.Canary == nil
}, timeout).Should(gomega.BeTrue())
// Trigger another reconcile
g.Expect(k8sClient.Update(context.TODO(), canaryDelete)).NotTo(gomega.HaveOccurred())
err = retry.RetryOnConflict(retry.DefaultRetry, func() error {
return k8sClient.Update(context.TODO(), canaryDelete)
})
g.Expect(err).NotTo(gomega.HaveOccurred())

defaultService = &knservingv1.Service{}
g.Eventually(func() error { return k8sClient.Get(context.TODO(), defaultPredictor, defaultService) }, timeout).
Expand Down
4 changes: 0 additions & 4 deletions test/workflows/components/workflows.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,6 @@
template: "checkout",
}],
[
{
name: "unit-test",
template: "unit-test",
},
{
name: "sdk-test",
template: "sdk-test",
Expand Down