@@ -20,6 +20,8 @@ import (
20
20
"sigs.k8s.io/controller-runtime/pkg/log/zap"
21
21
"sigs.k8s.io/controller-runtime/pkg/metrics"
22
22
23
+ "github.com/gitpod-io/gitpod/common-go/util"
24
+ "github.com/gitpod-io/gitpod/ws-manager-mk2/pkg/activity"
23
25
"github.com/gitpod-io/gitpod/ws-manager/api/config"
24
26
workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
25
27
//+kubebuilder:scaffold:imports
@@ -28,6 +30,12 @@ import (
28
30
// These tests use Ginkgo (BDD-style Go testing framework). Refer to
29
31
// http://onsi.github.io/ginkgo/ to learn more about Ginkgo.
30
32
33
+ const (
34
+ timeout = time .Second * 20
35
+ duration = time .Second * 2
36
+ interval = time .Millisecond * 250
37
+ )
38
+
31
39
// var cfg *rest.Config
32
40
var k8sClient client.Client
33
41
var testEnv * envtest.Environment
@@ -39,8 +47,9 @@ func TestAPIs(t *testing.T) {
39
47
}
40
48
41
49
var (
42
- ctx context.Context
43
- cancel context.CancelFunc
50
+ ctx context.Context
51
+ cancel context.CancelFunc
52
+ wsActivity * activity.WorkspaceActivity
44
53
)
45
54
46
55
var _ = BeforeSuite (func () {
@@ -91,21 +100,15 @@ var _ = BeforeSuite(func() {
91
100
})
92
101
Expect (err ).ToNot (HaveOccurred ())
93
102
94
- wsReconciler , err := NewWorkspaceReconciler (k8sManager .GetClient (), k8sManager .GetScheme (), & config.Configuration {
95
- Namespace : "default" ,
96
- SeccompProfile : "default.json" ,
97
- WorkspaceClasses : map [string ]* config.WorkspaceClass {
98
- "default" : {
99
- Name : "default" ,
100
- },
101
- },
102
- WorkspaceURLTemplate : "{{ .ID }}-{{ .Prefix }}-{{ .Host }}" ,
103
- GitpodHostURL : "gitpod.io" ,
104
- }, metrics .Registry )
105
-
103
+ conf := newTestConfig ()
104
+ wsReconciler , err := NewWorkspaceReconciler (k8sManager .GetClient (), k8sManager .GetScheme (), & conf , metrics .Registry )
106
105
Expect (err ).ToNot (HaveOccurred ())
107
- err = wsReconciler .SetupWithManager (k8sManager )
106
+ Expect (wsReconciler .SetupWithManager (k8sManager )).To (Succeed ())
107
+
108
+ wsActivity = & activity.WorkspaceActivity {}
109
+ timeoutReconciler , err := NewTimeoutReconciler (k8sManager .GetClient (), conf , wsActivity )
108
110
Expect (err ).ToNot (HaveOccurred ())
111
+ Expect (timeoutReconciler .SetupWithManager (k8sManager )).To (Succeed ())
109
112
110
113
ctx , cancel = context .WithCancel (context .Background ())
111
114
@@ -117,6 +120,32 @@ var _ = BeforeSuite(func() {
117
120
118
121
})
119
122
123
+ func newTestConfig () config.Configuration {
124
+ return config.Configuration {
125
+ GitpodHostURL : "gitpod.io" ,
126
+ HeartbeatInterval : util .Duration (30 * time .Second ),
127
+ Namespace : "default" ,
128
+ SeccompProfile : "default.json" ,
129
+ Timeouts : config.WorkspaceTimeoutConfiguration {
130
+ AfterClose : util .Duration (1 * time .Minute ),
131
+ Initialization : util .Duration (30 * time .Minute ),
132
+ TotalStartup : util .Duration (45 * time .Minute ),
133
+ RegularWorkspace : util .Duration (60 * time .Minute ),
134
+ MaxLifetime : util .Duration (36 * time .Hour ),
135
+ HeadlessWorkspace : util .Duration (90 * time .Minute ),
136
+ Stopping : util .Duration (60 * time .Minute ),
137
+ ContentFinalization : util .Duration (55 * time .Minute ),
138
+ Interrupted : util .Duration (5 * time .Minute ),
139
+ },
140
+ WorkspaceClasses : map [string ]* config.WorkspaceClass {
141
+ "default" : {
142
+ Name : "default" ,
143
+ },
144
+ },
145
+ WorkspaceURLTemplate : "{{ .ID }}-{{ .Prefix }}-{{ .Host }}" ,
146
+ }
147
+ }
148
+
120
149
var _ = AfterSuite (func () {
121
150
cancel ()
122
151
By ("tearing down the test environment" )
0 commit comments