Skip to content

Commit

Permalink
Drop invalid routing controller test
Browse files Browse the repository at this point in the history
Drop devworkspacerouting reconciler test for "gets preparing status", as
this test relied on a bug (403 forbidden responses to API calls were
ignored) in the controller.

Since there's no good way to create a 'preparing' DevWorkspaceRouting,
we can't test this specific function.

Signed-off-by: Angel Misevski <[email protected]>
  • Loading branch information
amisevsk committed Oct 27, 2023
1 parent a03c0a5 commit b512c88
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,6 @@ import (

var _ = Describe("DevWorkspaceRouting Controller", func() {
Context("Basic DevWorkspaceRouting Tests", func() {
It("Gets Preparing status", func() {
By("Creating a new DevWorkspaceRouting object")
dwrNamespacedName := namespacedName(devWorkspaceRoutingName, testNamespace)
createdDWR := createPreparingDWR(testWorkspaceID, devWorkspaceRoutingName)
Eventually(func() bool {
err := k8sClient.Get(ctx, dwrNamespacedName, createdDWR)
return err == nil
}, timeout, interval).Should(BeTrue(), "DevWorkspaceRouting should exist in cluster")

By("Checking DevWorkspaceRouting Status is updated to preparing")
Eventually(func() (phase controllerv1alpha1.DevWorkspaceRoutingPhase, err error) {
if err := k8sClient.Get(ctx, dwrNamespacedName, createdDWR); err != nil {
return "", err
}
return createdDWR.Status.Phase, nil
}, timeout, interval).Should(Equal(controllerv1alpha1.RoutingPreparing), "DevWorkspaceRouting should have Preparing phase")

Expect(createdDWR.Status.Message).ShouldNot(BeNil(), "Status message should be set for DevWorkspaceRoutings in Preparing phase")

deleteDevWorkspaceRouting(devWorkspaceRoutingName)
// Services and Ingresses aren't created since the DWR was stuck in preparing phase, no need to clean them up
})

It("Gets Ready Status on OpenShift", func() {
By("Setting infrastructure to OpenShift")
infrastructure.InitializeForTesting(infrastructure.OpenShiftv4)
Expand Down
33 changes: 0 additions & 33 deletions controllers/controller/devworkspacerouting/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,39 +54,6 @@ var (
ExpectedLabels = map[string]string{constants.DevWorkspaceIDLabel: testWorkspaceID}
)

func createPreparingDWR(workspaceID string, name string) *controllerv1alpha1.DevWorkspaceRouting {
mainAttributes := controllerv1alpha1.Attributes{}
mainAttributes.PutString("type", "main")
exposedEndpoint := controllerv1alpha1.Endpoint{
Name: exposedEndPointName,
Attributes: mainAttributes,
// Target port must be within range 1 and 65535
// Created service will be invalid on cluster and error will be logged
// DWR will continue trying to reconcile however, keeping it stuck in preparing phase
TargetPort: 0,
}
machineEndpointsMap := map[string]controllerv1alpha1.EndpointList{
testMachineName: {
exposedEndpoint,
},
}

dwr := &controllerv1alpha1.DevWorkspaceRouting{
Spec: controllerv1alpha1.DevWorkspaceRoutingSpec{
DevWorkspaceId: workspaceID,
RoutingClass: controllerv1alpha1.DevWorkspaceRoutingBasic,
Endpoints: machineEndpointsMap,
PodSelector: map[string]string{
constants.DevWorkspaceIDLabel: workspaceID,
},
},
}
dwr.SetName(name)
dwr.SetNamespace(testNamespace)
Expect(k8sClient.Create(ctx, dwr)).Should(Succeed())
return dwr
}

func createDWR(workspaceID string, name string) *controllerv1alpha1.DevWorkspaceRouting {
mainAttributes := controllerv1alpha1.Attributes{}
mainAttributes.PutString("type", "main")
Expand Down

0 comments on commit b512c88

Please sign in to comment.