Skip to content

Commit e281618

Browse files
committed
[ws-manager-mk2] Fix and enable controller tests
1 parent d5e3a5f commit e281618

File tree

6 files changed

+55
-53
lines changed

6 files changed

+55
-53
lines changed

components/ws-manager-api/go/crd/v1/webhook_suite_test.go

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"testing"
1414
"time"
1515

16-
. "github.com/onsi/ginkgo"
16+
. "github.com/onsi/ginkgo/v2"
1717
. "github.com/onsi/gomega"
1818

1919
admissionv1beta1 "k8s.io/api/admission/v1beta1"
@@ -22,7 +22,6 @@ import (
2222
ctrl "sigs.k8s.io/controller-runtime"
2323
"sigs.k8s.io/controller-runtime/pkg/client"
2424
"sigs.k8s.io/controller-runtime/pkg/envtest"
25-
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
2625
logf "sigs.k8s.io/controller-runtime/pkg/log"
2726
"sigs.k8s.io/controller-runtime/pkg/log/zap"
2827
)
@@ -39,9 +38,7 @@ var cancel context.CancelFunc
3938
func TestAPIs(t *testing.T) {
4039
RegisterFailHandler(Fail)
4140

42-
RunSpecsWithDefaultAndCustomReporters(t,
43-
"Webhook Suite",
44-
[]Reporter{printer.NewlineReporter{}})
41+
RunSpecs(t, "Webhook Suite")
4542
}
4643

4744
var _ = BeforeSuite(func() {
@@ -110,7 +107,7 @@ var _ = BeforeSuite(func() {
110107
return nil
111108
}).Should(Succeed())
112109

113-
}, 60)
110+
})
114111

115112
var _ = AfterSuite(func() {
116113
cancel()

components/ws-manager-mk2/BUILD.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ packages:
1616
- components/ws-manager-api/go:lib
1717
config:
1818
packaging: app
19-
dontTest: true
2019
buildCommand: ["go", "build", "-trimpath", "-ldflags", "-buildid= -w -s -X 'github.com/gitpod-io/gitpod/ws-manager-mk2/cmd.Version=commit-${__git_commit}'"]
2120
- name: docker
2221
type: docker

components/ws-manager-mk2/controllers/suite_test.go

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ import (
99
"path/filepath"
1010
"testing"
1111

12-
. "github.com/onsi/ginkgo"
12+
. "github.com/onsi/ginkgo/v2"
1313
. "github.com/onsi/gomega"
1414
"k8s.io/client-go/kubernetes/scheme"
1515
ctrl "sigs.k8s.io/controller-runtime"
1616
"sigs.k8s.io/controller-runtime/pkg/client"
1717
"sigs.k8s.io/controller-runtime/pkg/envtest"
18-
"sigs.k8s.io/controller-runtime/pkg/envtest/printer"
1918
logf "sigs.k8s.io/controller-runtime/pkg/log"
2019
"sigs.k8s.io/controller-runtime/pkg/log/zap"
20+
"sigs.k8s.io/controller-runtime/pkg/metrics"
2121

2222
"github.com/gitpod-io/gitpod/ws-manager/api/config"
2323
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
@@ -34,7 +34,7 @@ var testEnv *envtest.Environment
3434
func TestAPIs(t *testing.T) {
3535
RegisterFailHandler(Fail)
3636

37-
RunSpecsWithDefaultAndCustomReporters(t, "Controller Suite", []Reporter{printer.NewlineReporter{}})
37+
RunSpecs(t, "Controller Suite")
3838
}
3939

4040
var (
@@ -88,30 +88,28 @@ var _ = BeforeSuite(func() {
8888
})
8989
Expect(err).ToNot(HaveOccurred())
9090

91-
err = (&WorkspaceReconciler{
92-
Client: k8sManager.GetClient(),
93-
Scheme: k8sManager.GetScheme(),
94-
Config: config.Configuration{
95-
Namespace: "default",
96-
SeccompProfile: "default.json",
97-
WorkspaceClasses: map[string]*config.WorkspaceClass{
98-
"default": {
99-
Name: "default",
100-
},
91+
wsReconciler, err := NewWorkspaceReconciler(k8sManager.GetClient(), k8sManager.GetScheme(), config.Configuration{
92+
Namespace: "default",
93+
SeccompProfile: "default.json",
94+
WorkspaceClasses: map[string]*config.WorkspaceClass{
95+
"default": {
96+
Name: "default",
10197
},
10298
},
103-
}).SetupWithManager(k8sManager)
99+
}, metrics.Registry)
100+
Expect(err).ToNot(HaveOccurred())
101+
err = wsReconciler.SetupWithManager(k8sManager)
104102
Expect(err).ToNot(HaveOccurred())
105103

106-
ctx, cancel = context.WithCancel(context.TODO())
104+
ctx, cancel = context.WithCancel(context.Background())
107105

108106
go func() {
109107
defer GinkgoRecover()
110108
err = k8sManager.Start(ctx)
111109
Expect(err).ToNot(HaveOccurred(), "failed to run manager")
112110
}()
113111

114-
}, 60)
112+
})
115113

116114
var _ = AfterSuite(func() {
117115
cancel()

components/ws-manager-mk2/controllers/workspace_controller_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ import (
1010
"time"
1111

1212
"github.com/aws/smithy-go/ptr"
13+
csapi "github.com/gitpod-io/gitpod/content-service/api"
1314
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
14-
. "github.com/onsi/ginkgo"
15+
. "github.com/onsi/ginkgo/v2"
1516
. "github.com/onsi/gomega"
17+
"google.golang.org/protobuf/proto"
1618

1719
// . "github.com/onsi/ginkgo/extensions/table"
1820

@@ -37,6 +39,12 @@ var _ = Describe("WorkspaceController", func() {
3739
By("creating a status")
3840

3941
ctx := context.Background()
42+
initializer := &csapi.WorkspaceInitializer{
43+
Spec: &csapi.WorkspaceInitializer_Empty{Empty: &csapi.EmptyInitializer{}},
44+
}
45+
initializerBytes, err := proto.Marshal(initializer)
46+
Expect(err).ToNot(HaveOccurred())
47+
4048
workspace := &workspacev1.Workspace{
4149
TypeMeta: metav1.TypeMeta{
4250
APIVersion: "workspace.gitpod.io/v1",
@@ -62,7 +70,7 @@ var _ = Describe("WorkspaceController", func() {
6270
},
6371
},
6472
Ports: []workspacev1.PortSpec{},
65-
Initializer: []byte("abc"),
73+
Initializer: initializerBytes,
6674
Admission: workspacev1.AdmissionSpec{
6775
Level: workspacev1.AdmissionLevelEveryone,
6876
},

components/ws-manager-mk2/go.mod

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ go 1.19
55
require (
66
github.com/aws/smithy-go v1.13.3
77
github.com/gitpod-io/gitpod/common-go v0.0.0-00010101000000-000000000000
8+
github.com/gitpod-io/gitpod/content-service/api v0.0.0-00010101000000-000000000000
89
github.com/gitpod-io/gitpod/registry-facade/api v0.0.0-00010101000000-000000000000
910
github.com/gitpod-io/gitpod/ws-manager/api v0.0.0-00010101000000-000000000000
11+
github.com/go-logr/logr v1.2.3
1012
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
1113
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
14+
github.com/hashicorp/golang-lru v0.5.1
1215
github.com/imdario/mergo v0.3.13
1316
github.com/mwitkow/grpc-proxy v0.0.0-20220126150247-db34e7bfee32
14-
github.com/onsi/ginkgo v1.16.5
15-
github.com/onsi/gomega v1.19.0
17+
github.com/onsi/ginkgo/v2 v2.8.0
18+
github.com/onsi/gomega v1.25.0
1619
github.com/opentracing/opentracing-go v1.2.0
20+
github.com/prometheus/client_golang v1.13.0
1721
golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f
1822
google.golang.org/grpc v1.49.0
1923
google.golang.org/protobuf v1.28.1
@@ -47,8 +51,6 @@ require (
4751
github.com/davecgh/go-spew v1.1.1 // indirect
4852
github.com/emicklei/go-restful v2.9.5+incompatible // indirect
4953
github.com/fsnotify/fsnotify v1.5.4 // indirect
50-
github.com/gitpod-io/gitpod/content-service/api v0.0.0-00010101000000-000000000000 // indirect
51-
github.com/go-logr/logr v1.2.3 // indirect
5254
github.com/go-logr/zapr v1.2.3 // indirect
5355
github.com/go-openapi/jsonpointer v0.19.5 // indirect
5456
github.com/go-openapi/jsonreference v0.20.0 // indirect
@@ -57,11 +59,10 @@ require (
5759
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5860
github.com/golang/protobuf v1.5.2 // indirect
5961
github.com/google/gnostic v0.5.7-v3refs // indirect
60-
github.com/google/go-cmp v0.5.8 // indirect
62+
github.com/google/go-cmp v0.5.9 // indirect
6163
github.com/google/gofuzz v1.2.0 // indirect
6264
github.com/google/uuid v1.2.0 // indirect
6365
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
64-
github.com/hashicorp/golang-lru v0.5.1 // indirect
6566
github.com/heptiolabs/healthcheck v0.0.0-20211123025425-613501dd5deb // indirect
6667
github.com/josharian/intern v1.0.0 // indirect
6768
github.com/json-iterator/go v1.1.12 // indirect
@@ -70,12 +71,10 @@ require (
7071
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
7172
github.com/modern-go/reflect2 v1.0.2 // indirect
7273
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
73-
github.com/nxadm/tail v1.4.8 // indirect
7474
github.com/opencontainers/go-digest v1.0.0 // indirect
7575
github.com/opencontainers/image-spec v1.0.2 // indirect
7676
github.com/pkg/errors v0.9.1 // indirect
7777
github.com/pmezard/go-difflib v1.0.0 // indirect
78-
github.com/prometheus/client_golang v1.13.0 // indirect
7978
github.com/prometheus/client_model v0.2.0 // indirect
8079
github.com/prometheus/common v0.37.0 // indirect
8180
github.com/prometheus/procfs v0.8.0 // indirect
@@ -89,20 +88,19 @@ require (
8988
go.uber.org/multierr v1.6.0 // indirect
9089
go.uber.org/zap v1.19.1 // indirect
9190
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
92-
golang.org/x/net v0.0.0-20220607020251-c690dde0001d // indirect
91+
golang.org/x/net v0.5.0 // indirect
9392
golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb // indirect
9493
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect
95-
golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d // indirect
96-
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 // indirect
97-
golang.org/x/text v0.3.7 // indirect
94+
golang.org/x/sys v0.4.0 // indirect
95+
golang.org/x/term v0.4.0 // indirect
96+
golang.org/x/text v0.6.0 // indirect
9897
golang.org/x/time v0.0.0-20220922220347-f3bd1da661af // indirect
9998
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
10099
google.golang.org/appengine v1.6.7 // indirect
101100
google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90 // indirect
102101
gopkg.in/inf.v0 v0.9.1 // indirect
103-
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
104102
gopkg.in/yaml.v2 v2.4.0 // indirect
105-
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
103+
gopkg.in/yaml.v3 v3.0.1 // indirect
106104
k8s.io/apiextensions-apiserver v0.23.5 // indirect
107105
k8s.io/component-base v0.24.4 // indirect
108106
k8s.io/klog/v2 v2.60.1 // indirect

components/ws-manager-mk2/go.sum

Lines changed: 16 additions & 14 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)