Skip to content

Commit

Permalink
Fix functional tests and pre-commit
Browse files Browse the repository at this point in the history
Note: It also bump timeout in order to make sure csv get installed.

Signed-off-by: Chandan Kumar <[email protected]>
  • Loading branch information
raukadah committed Nov 27, 2024
1 parent feb8447 commit b62f9b9
Show file tree
Hide file tree
Showing 10 changed files with 22 additions and 160 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ watcher: export CATALOG_IMG=${CATALOG_IMAGE}
watcher: ## Install watcher operator via olm
bash ci/olm.sh
oc apply -f ci/olm.yaml
timeout 300s bash -c "while ! (oc get csv -n openstack-operators -l operators.coreos.com/watcher-operator.openstack-operators -o jsonpath='{.items[*].status.phase}' | grep Succeeded); do sleep 1; done"
timeout 600s bash -c "while ! (oc get csv -n openstack-operators -l operators.coreos.com/watcher-operator.openstack-operators -o jsonpath='{.items[*].status.phase}' | grep Succeeded); do sleep 1; done"

.PHONY: watcher_deploy
watcher_deploy: ## Deploy watcher service
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/watcher_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *Watcher) ValidateCreate() (admission.Warnings, error) {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *Watcher) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *Watcher) ValidateUpdate(runtime.Object) (admission.Warnings, error) {
watcherlog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/watcherapi_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *WatcherAPI) ValidateCreate() (admission.Warnings, error) {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *WatcherAPI) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *WatcherAPI) ValidateUpdate(runtime.Object) (admission.Warnings, error) {
watcherapilog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/watcherapplier_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *WatcherApplier) ValidateCreate() (admission.Warnings, error) {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *WatcherApplier) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *WatcherApplier) ValidateUpdate(runtime.Object) (admission.Warnings, error) {
watcherapplierlog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta1/watcherdecisionengine_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func (r *WatcherDecisionEngine) ValidateCreate() (admission.Warnings, error) {
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type
func (r *WatcherDecisionEngine) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
func (r *WatcherDecisionEngine) ValidateUpdate(runtime.Object) (admission.Warnings, error) {
watcherdecisionenginelog.Info("validate update", "name", r.Name)

// TODO(user): fill in your validation logic upon object update.
Expand Down
141 changes: 0 additions & 141 deletions api/v1beta1/webhook_suite_test.go

This file was deleted.

Empty file modified hack/clean_local_webhook.sh
100644 → 100755
Empty file.
Empty file modified hack/run_with_local_webhook.sh
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func main() {
setupLog.Error(err, "unable to create webhook", "webhook", "WatcherDecisionEngine")
os.Exit(1)
}
}
}
if err := mgr.AddHealthzCheck("healthz", checker); err != nil {
setupLog.Error(err, "unable to set up health check")
os.Exit(1)
Expand All @@ -179,4 +179,4 @@ func main() {
setupLog.Error(err, "problem running manager")
os.Exit(1)
}
}
}
27 changes: 15 additions & 12 deletions tests/functional/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ package functional

import (
"context"
"crypto/tls"
"fmt"
"net"
"path/filepath"
"testing"
"time"
Expand Down Expand Up @@ -148,8 +151,8 @@ var _ = BeforeSuite(func() {

watcherv1.SetupDefaults()

//err = (&watcherv1.Watcher{}).SetupWebhookWithManager(k8sManager)
//Expect(err).NotTo(HaveOccurred())
err = (&watcherv1.Watcher{}).SetupWebhookWithManager(k8sManager)
Expect(err).NotTo(HaveOccurred())

go func() {
defer GinkgoRecover()
Expand All @@ -158,16 +161,16 @@ var _ = BeforeSuite(func() {
}()

// wait for the webhook server to get ready
//dialer := &net.Dialer{Timeout: 10 * time.Second}
//addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
//Eventually(func() error {
// conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
// if err != nil {
// return err
// }
// conn.Close()
// return nil
//}).Should(Succeed())
dialer := &net.Dialer{Timeout: 10 * time.Second}
addrPort := fmt.Sprintf("%s:%d", webhookInstallOptions.LocalServingHost, webhookInstallOptions.LocalServingPort)
Eventually(func() error {
conn, err := tls.DialWithDialer(dialer, "tcp", addrPort, &tls.Config{InsecureSkipVerify: true})
if err != nil {
return err
}
conn.Close()
return nil
}).Should(Succeed())
})

var _ = AfterSuite(func() {
Expand Down

0 comments on commit b62f9b9

Please sign in to comment.