@@ -6,14 +6,19 @@ package wsmanager
6
6
7
7
import (
8
8
"context"
9
+ "encoding/json"
9
10
"testing"
10
11
"time"
11
12
13
+ corev1 "k8s.io/api/core/v1"
14
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
15
+ "sigs.k8s.io/e2e-framework/pkg/envconf"
16
+ "sigs.k8s.io/e2e-framework/pkg/features"
17
+
12
18
csapi "github.com/gitpod-io/gitpod/content-service/api"
13
19
"github.com/gitpod-io/gitpod/test/pkg/integration"
14
20
wsmanapi "github.com/gitpod-io/gitpod/ws-manager/api"
15
- "sigs.k8s.io/e2e-framework/pkg/envconf"
16
- "sigs.k8s.io/e2e-framework/pkg/features"
21
+ "github.com/gitpod-io/gitpod/ws-manager/api/config"
17
22
)
18
23
19
24
func TestMaintenance (t * testing.T ) {
@@ -24,6 +29,43 @@ func TestMaintenance(t *testing.T) {
24
29
WithLabel ("component" , "ws-manager" ).
25
30
WithLabel ("type" , "maintenance" ).
26
31
Assess ("should display maintenance message" , func (testCtx context.Context , t * testing.T , cfg * envconf.Config ) context.Context {
32
+ kubeClient , err := cfg .NewClient ()
33
+ if err != nil {
34
+ t .Fatal (err )
35
+ }
36
+
37
+ futureTime := time .Now ().Add (1 * time .Hour )
38
+ mcfg := config.MaintenanceConfig {
39
+ EnabledUntil : & futureTime ,
40
+ }
41
+
42
+ data , err := json .Marshal (mcfg )
43
+ if err != nil {
44
+ t .Fatal (err )
45
+ }
46
+
47
+ configMap := & corev1.ConfigMap {
48
+ ObjectMeta : metav1.ObjectMeta {
49
+ Name : "ws-manager-mk2-maintenance-mode" ,
50
+ Namespace : "default" ,
51
+ },
52
+ Data : map [string ]string {
53
+ "config.json" : string (data ),
54
+ },
55
+ }
56
+
57
+ err = kubeClient .Resources ().Create (testCtx , configMap )
58
+ if err != nil {
59
+ t .Fatal (err )
60
+ }
61
+
62
+ t .Cleanup (func () {
63
+ err := kubeClient .Resources ().Delete (testCtx , configMap )
64
+ if err != nil {
65
+ t .Error (err )
66
+ }
67
+ })
68
+
27
69
ctx , cancel := context .WithTimeout (testCtx , time .Duration (5 * time .Minute ))
28
70
defer cancel ()
29
71
0 commit comments