Skip to content

Commit

Permalink
Merge pull request kubevirt#530 from akrejcir/test-wait-after-revert-…
Browse files Browse the repository at this point in the history
…v0.17

[release-v0.17] fix: console proxy and tests: Stabilize functional tests
  • Loading branch information
kubevirt-bot authored Mar 29, 2023
2 parents 5d14520 + 1050932 commit 238a5b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 11 deletions.
13 changes: 9 additions & 4 deletions internal/operands/vm-console-proxy/reconcile.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,17 @@ func (v *vmConsoleProxy) Reconcile(request *common.Request) ([]common.ReconcileR
var reconcileFunc []common.ReconcileFunc

if !isEnabled(request) {
_, err := v.Cleanup(request)
cleanupResults, err := v.Cleanup(request)
if err != nil {
return []common.ReconcileResult{}, err
return nil, err
}

return []common.ReconcileResult{}, nil
var results []common.ReconcileResult
for _, cleanupResult := range cleanupResults {
if !cleanupResult.Deleted {
results = append(results, common.ResourceDeletedResult(cleanupResult.Resource, common.OperationResultDeleted))
}
}
return results, nil
}

reconcileFunc = append(reconcileFunc, reconcileServiceAccountsFuncs(*v.serviceAccount.DeepCopy()))
Expand Down
2 changes: 2 additions & 0 deletions tests/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (s *newSspStrategy) GetSSPWebhookServiceName() string {
func (s *newSspStrategy) RevertToOriginalSspCr() {
waitForSspDeletionIfNeeded(s.ssp)
createOrUpdateSsp(s.ssp)
waitUntilDeployed()
}

func (s *newSspStrategy) SkipSspUpdateTestsIfNeeded() {
Expand Down Expand Up @@ -347,6 +348,7 @@ func (s *existingSspStrategy) GetSSPWebhookServiceName() string {
func (s *existingSspStrategy) RevertToOriginalSspCr() {
waitForSspDeletionIfNeeded(s.ssp)
createOrUpdateSsp(s.ssp)
waitUntilDeployed()
}

func (s *existingSspStrategy) SkipSspUpdateTestsIfNeeded() {
Expand Down
19 changes: 12 additions & 7 deletions tests/vm_console_proxy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ package tests
import (
"crypto/tls"
"io"
"kubevirt.io/ssp-operator/tests/env"
"net/http"
"net/url"
"reflect"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
Expand Down Expand Up @@ -236,16 +238,19 @@ var _ = Describe("VM Console Proxy Operand", func() {
url, err := url.JoinPath(routeApiUrl, strategy.GetNamespace(), "non-existing-vm", "token")
Expect(err).ToNot(HaveOccurred())

response, err := httpClient.Get(url)
Expect(err).ToNot(HaveOccurred())
defer func() { _ = response.Body.Close() }()
// It may take a moment for the service to be reachable through route
Eventually(func(g Gomega) {
response, err := httpClient.Get(url)
g.Expect(err).ToNot(HaveOccurred())
defer func() { _ = response.Body.Close() }()

Expect(response.StatusCode).To(Equal(http.StatusUnauthorized))
g.Expect(response.StatusCode).To(Equal(http.StatusUnauthorized))

body, err := io.ReadAll(response.Body)
Expect(err).ToNot(HaveOccurred())
body, err := io.ReadAll(response.Body)
g.Expect(err).ToNot(HaveOccurred())

Expect(body).To(ContainSubstring("authenticating token cannot be empty"))
g.Expect(body).To(ContainSubstring("authenticating token cannot be empty"))
}, env.ShortTimeout(), time.Second).Should(Succeed())
})
})
})

0 comments on commit 238a5b8

Please sign in to comment.