Skip to content

Commit 844a589

Browse files
WVerlaekkylos101
authored andcommitted
[e2e] Support and fixes for mk2 e2e tests
1 parent 72a58dd commit 844a589

File tree

7 files changed

+75
-31
lines changed

7 files changed

+75
-31
lines changed

.github/workflows/workspace-integration-tests.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
required: false
1717
type: boolean
1818
description: "Skip delete preview environment (debug only)"
19+
wsman_mk2:
20+
required: false
21+
type: boolean
22+
description: "Run tests against ws-manager-mk2"
1923
schedule:
2024
- cron: "0 3,12 * * *"
2125
jobs:
@@ -99,7 +103,7 @@ jobs:
99103
env:
100104
SLACK_WEBHOOK: ${{ steps.secrets.outputs.WORKSPACE_SLACK_WEBHOOK }}
101105
SLACK_COLOR: ${{ job.status }}
102-
SLACK_MESSAGE: Workspace Integration Tests failed
106+
SLACK_MESSAGE: "Workspace Integration Tests failed (used mk2: ${{ github.event.inputs.wsman_mk2 }})"
103107

104108
infrastructure:
105109
needs: [ configuration ]
@@ -200,6 +204,8 @@ jobs:
200204
WS_MANAGER_TESTS="$BASE_TESTS_DIR/components/ws-manager"
201205
WORKSPACE_TESTS="$BASE_TESTS_DIR/workspace"
202206
207+
WS_MANAGER_MK2="${{ github.event.inputs.wsman_mk2 }}"
208+
203209
go install github.com/jstemmer/go-junit-report/v2@latest
204210
205211
FAILURE_COUNT=0

components/ws-manager-mk2/service/manager.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,8 @@ func (wsm *WorkspaceManagerServer) StopWorkspace(ctx context.Context, req *wsman
366366
ws.Status.SetCondition(workspacev1.NewWorkspaceConditionStoppedByRequest(gracePeriod.String()))
367367
return nil
368368
})
369-
if err != nil {
369+
// Ignore NotFound errors, workspace has already been stopped.
370+
if err != nil && status.Code(err) != codes.NotFound {
370371
return nil, err
371372
}
372373
return &wsmanapi.StopWorkspaceResponse{}, nil

test/pkg/integration/apis.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -708,11 +708,16 @@ func (c *ComponentAPI) WorkspaceManager() (wsmanapi.WorkspaceManagerClient, erro
708708
return c.wsmanStatus.Client, nil
709709
}
710710

711+
var wsman = ComponentWorkspaceManager
712+
if UseWsmanMk2() {
713+
wsman = ComponentWorkspaceManagerMK2
714+
}
715+
711716
if c.wsmanStatus.Port == 0 {
712717
c.wsmanStatusMu.Lock()
713718
defer c.wsmanStatusMu.Unlock()
714719

715-
pod, _, err := selectPod(ComponentWorkspaceManager, selectPodOptions{}, c.namespace, c.client)
720+
pod, _, err := selectPod(wsman, selectPodOptions{}, c.namespace, c.client)
716721
if err != nil {
717722
return nil, err
718723
}
@@ -733,7 +738,7 @@ func (c *ComponentAPI) WorkspaceManager() (wsmanapi.WorkspaceManagerClient, erro
733738
c.wsmanStatus.Port = localPort
734739
}
735740

736-
secretName := "ws-manager-client-tls"
741+
secretName := fmt.Sprintf("%s-client-tls", wsman)
737742
ctx, cancel := context.WithCancel(context.Background())
738743

739744
c.appendCloser(func() error { cancel(); return nil })
@@ -759,7 +764,7 @@ func (c *ComponentAPI) WorkspaceManager() (wsmanapi.WorkspaceManagerClient, erro
759764
creds := credentials.NewTLS(&tls.Config{
760765
Certificates: []tls.Certificate{cert},
761766
RootCAs: certPool,
762-
ServerName: "ws-manager",
767+
ServerName: string(wsman),
763768
})
764769
dialOption := grpc.WithTransportCredentials(creds)
765770

@@ -1084,12 +1089,17 @@ func (c *ComponentAPI) ImageBuilder(opts ...APIImageBuilderOpt) (imgbldr.ImageBu
10841089
return c.imgbldStatus.Client, nil
10851090
}
10861091

1092+
imgbuilder := ComponentImageBuilderMK3
1093+
if UseWsmanMk2() {
1094+
imgbuilder = ComponentImageBuilderMK3Wsman
1095+
}
1096+
10871097
err := func() error {
10881098
if c.imgbldStatus.Port == 0 {
10891099
c.imgbldStatusMu.Lock()
10901100
defer c.imgbldStatusMu.Unlock()
10911101

1092-
pod, _, err := selectPod(ComponentImageBuilderMK3, selectPodOptions{}, c.namespace, c.client)
1102+
pod, _, err := selectPod(imgbuilder, selectPodOptions{}, c.namespace, c.client)
10931103
if err != nil {
10941104
return err
10951105
}

test/pkg/integration/integration.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,16 @@ const (
586586
ComponentWorkspaceDaemon ComponentType = "ws-daemon"
587587
// ComponentWorkspaceManager points to the workspace manager
588588
ComponentWorkspaceManager ComponentType = "ws-manager"
589+
// ComponentWorkspaceManagerMK2 points to the MK2 workspace manager
590+
ComponentWorkspaceManagerMK2 ComponentType = "ws-manager-mk2"
589591
// ComponentContentService points to the content service
590592
ComponentContentService ComponentType = "content-service"
591593
// ComponentWorkspace points to a workspace
592594
ComponentWorkspace ComponentType = "workspace"
593595
// ComponentImageBuilderMK3 points to the image-builder-mk3
594596
ComponentImageBuilderMK3 ComponentType = "image-builder-mk3"
597+
// ComponentImageBuilderMK3Wsman points to ws-manager-mk2's image-builder-mk3
598+
ComponentImageBuilderMK3Wsman ComponentType = "image-builder-mk3-wsman"
595599
)
596600

597601
func waitForPodRunningReady(c kubernetes.Interface, podName string, namespace string, timeout time.Duration) error {

test/pkg/integration/setup.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,17 +142,24 @@ func waitOnGitpodRunning(namespace string, waitTimeout time.Duration) env.Func {
142142
klog.V(2).Info("Checking status of Gitpod components...")
143143

144144
return func(ctx context.Context, cfg *envconf.Config) (context.Context, error) {
145+
imgBuilder := "image-builder-mk3"
146+
wsman := "ws-manager"
147+
if UseWsmanMk2() {
148+
imgBuilder = "image-builder-mk3-wsman"
149+
wsman = "ws-manager-mk2"
150+
}
151+
145152
components := []string{
146153
"agent-smith",
147154
"blobserve",
148155
"content-service",
149156
"dashboard",
150-
"image-builder-mk3",
157+
imgBuilder,
151158
"proxy",
152159
"registry-facade",
153160
"server",
154161
"ws-daemon",
155-
"ws-manager",
162+
wsman,
156163
"ws-manager-bridge",
157164
"ws-proxy",
158165
}
@@ -221,3 +228,7 @@ func getNamespace(path string) (string, error) {
221228

222229
return namespace, nil
223230
}
231+
232+
func UseWsmanMk2() bool {
233+
return os.Getenv("WS_MANAGER_MK2") == "true"
234+
}

test/tests/components/ws-manager/prebuild_test.go

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -552,27 +552,31 @@ func TestOpenWorkspaceFromOutdatedPrebuild(t *testing.T) {
552552
})
553553

554554
// create a prebuild
555-
ws, prebuildStopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api, integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
556-
req.Type = wsmanapi.WorkspaceType_PREBUILD
557-
req.Spec.Envvars = append(req.Spec.Envvars, &wsmanapi.EnvironmentVariable{
558-
Name: "GITPOD_TASKS",
559-
Value: `[{ "init": "./init.sh" }]`,
560-
})
561-
req.Spec.FeatureFlags = test.FF
562-
req.Spec.Initializer = &csapi.WorkspaceInitializer{
563-
Spec: &csapi.WorkspaceInitializer_Git{
564-
Git: &csapi.GitInitializer{
565-
RemoteUri: test.RemoteUri,
566-
TargetMode: csapi.CloneTargetMode_REMOTE_BRANCH,
567-
CloneTaget: test.CloneTargetForPrebuild,
568-
CheckoutLocation: test.CheckoutLocation,
569-
Config: &csapi.GitConfig{},
555+
ws, prebuildStopWs, err := integration.LaunchWorkspaceDirectly(t, ctx, api,
556+
integration.WithRequestModifier(func(req *wsmanapi.StartWorkspaceRequest) error {
557+
req.Type = wsmanapi.WorkspaceType_PREBUILD
558+
req.Spec.Envvars = append(req.Spec.Envvars, &wsmanapi.EnvironmentVariable{
559+
Name: "GITPOD_TASKS",
560+
Value: `[{ "init": "./init.sh" }]`,
561+
})
562+
req.Spec.FeatureFlags = test.FF
563+
req.Spec.Initializer = &csapi.WorkspaceInitializer{
564+
Spec: &csapi.WorkspaceInitializer_Git{
565+
Git: &csapi.GitInitializer{
566+
RemoteUri: test.RemoteUri,
567+
TargetMode: csapi.CloneTargetMode_REMOTE_BRANCH,
568+
CloneTaget: test.CloneTargetForPrebuild,
569+
CheckoutLocation: test.CheckoutLocation,
570+
Config: &csapi.GitConfig{},
571+
},
570572
},
571-
},
572-
}
573-
req.Spec.WorkspaceLocation = test.CheckoutLocation
574-
return nil
575-
}))
573+
}
574+
req.Spec.WorkspaceLocation = test.CheckoutLocation
575+
return nil
576+
}),
577+
// The init task only runs for a short duration, so it's possible we miss the Running state, as it quickly transitions to Stopping.
578+
// Therefore ignore if we can't see the Running state.
579+
integration.WithWaitWorkspaceForOpts(integration.WorkspaceCanFail))
576580
if err != nil {
577581
t.Fatalf("cannot launch a workspace: %q", err)
578582
}
@@ -586,6 +590,9 @@ func TestOpenWorkspaceFromOutdatedPrebuild(t *testing.T) {
586590
if err != nil {
587591
t.Fatalf("stop workspace and find snapshot error: %v", err)
588592
}
593+
if prebuildSnapshot == "" {
594+
t.Fatalf("prebuild snapshot is empty")
595+
}
589596

590597
t.Logf("prebuild snapshot: %s", prebuildSnapshot)
591598

@@ -1050,7 +1057,7 @@ func watchStopWorkspaceAndFindSnapshot(t *testing.T, ctx context.Context, instan
10501057
if lastStatus.Conditions.HeadlessTaskFailed != "" {
10511058
return "", nil, errors.New("unexpected HeadlessTaskFailed condition")
10521059
}
1053-
if lastStatus == nil || lastStatus.Conditions == nil || lastStatus.Conditions.VolumeSnapshot == nil {
1060+
if lastStatus == nil || lastStatus.Conditions == nil {
10541061
return "", nil, nil
10551062
}
10561063
return lastStatus.Conditions.Snapshot, lastStatus.Conditions.VolumeSnapshot, nil

test/tests/components/ws-manager/protected_secrets_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,13 @@ func assertEnvSuppliedBySecret(t *testing.T, wsPod *corev1.Pod, secretEnv string
120120
t.Fatalf("environment variable value is not supplied by secret")
121121
}
122122

123-
if env.ValueFrom.SecretKeyRef.Name != wsPod.Name {
124-
t.Fatalf("expected environment variable values are not supplied by secret %s", wsPod.Name)
123+
expectedName := wsPod.Name
124+
if integration.UseWsmanMk2() {
125+
expectedName = fmt.Sprintf("%s-env", strings.TrimPrefix(wsPod.Name, "ws-"))
126+
}
127+
128+
if env.ValueFrom.SecretKeyRef.Name != expectedName {
129+
t.Fatalf("expected environment variable values are not supplied by secret %s", expectedName)
125130
}
126131
}
127132
}

0 commit comments

Comments
 (0)