mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-05-24 01:54:12 +00:00
Some checks failed
Scorecard supply-chain security / Scorecard analysis (push) Failing after 28s
Post / coverage (push) Failing after 22s
Post / images (amd64, addon-manager) (push) Failing after 30s
Post / images (amd64, placement) (push) Failing after 25s
Post / images (amd64, registration) (push) Failing after 16s
Post / images (amd64, registration-operator) (push) Failing after 23s
Post / images (amd64, work) (push) Failing after 17s
Post / images (arm64, addon-manager) (push) Failing after 14s
Post / images (arm64, placement) (push) Failing after 19s
Post / images (arm64, registration) (push) Failing after 23s
Post / images (arm64, registration-operator) (push) Failing after 17s
Post / images (arm64, work) (push) Failing after 19s
Post / image manifest (addon-manager) (push) Has been skipped
Post / image manifest (placement) (push) Has been skipped
Post / image manifest (registration) (push) Has been skipped
Post / image manifest (registration-operator) (push) Has been skipped
Post / image manifest (work) (push) Has been skipped
Post / trigger clusteradm e2e (push) Has been skipped
Close stale issues and PRs / stale (push) Failing after 31s
* Remove event after apply and add jitter when requeue Signed-off-by: Jian Qiu <jqiu@redhat.com> * Change event handler to avoid redundant reconciles Signed-off-by: Jian Qiu <jqiu@redhat.com> * Add unit tests for onAdd and onUpdate function Signed-off-by: Jian Qiu <jqiu@redhat.com> * Fix interegation test fail Signed-off-by: Jian Qiu <jqiu@redhat.com> * Set resync interval to 4-6 mins Signed-off-by: Jian Qiu <jqiu@redhat.com> --------- Signed-off-by: Jian Qiu <jqiu@redhat.com>
72 lines
1.8 KiB
Go
72 lines
1.8 KiB
Go
package klusterlet
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
|
|
"github.com/onsi/ginkgo/v2"
|
|
"github.com/onsi/gomega"
|
|
"github.com/openshift/library-go/pkg/controller/controllercmd"
|
|
"k8s.io/client-go/rest"
|
|
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
|
logf "sigs.k8s.io/controller-runtime/pkg/log"
|
|
"sigs.k8s.io/controller-runtime/pkg/log/zap"
|
|
|
|
"open-cluster-management.io/ocm/test/integration/util"
|
|
)
|
|
|
|
var testEnv *envtest.Environment
|
|
var cfg *rest.Config
|
|
|
|
func TestKlusterlet(t *testing.T) {
|
|
gomega.RegisterFailHandler(ginkgo.Fail)
|
|
ginkgo.RunSpecs(t, "Klusterlet Suite")
|
|
}
|
|
|
|
var _ = ginkgo.BeforeSuite(func() {
|
|
logf.SetLogger(zap.New(zap.WriteTo(ginkgo.GinkgoWriter), zap.UseDevMode(true)))
|
|
|
|
ginkgo.By("bootstrapping test environment")
|
|
|
|
var err error
|
|
// install operator CRDs and start a local kube-apiserver
|
|
testEnv = &envtest.Environment{
|
|
ErrorIfCRDPathMissing: true,
|
|
CRDDirectoryPaths: []string{
|
|
filepath.Join("../../../../", "deploy", "klusterlet", "olm-catalog", "latest", "manifests"),
|
|
},
|
|
}
|
|
cfg, err = testEnv.Start()
|
|
cfg.QPS = 100
|
|
cfg.Burst = 200
|
|
|
|
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
|
gomega.Expect(cfg).ToNot(gomega.BeNil())
|
|
})
|
|
|
|
var _ = ginkgo.AfterSuite(func() {
|
|
ginkgo.By("tearing down the test environment")
|
|
|
|
err := testEnv.Stop()
|
|
gomega.Expect(err).ToNot(gomega.HaveOccurred())
|
|
})
|
|
|
|
var _ = ginkgo.Describe("start klusterlet", func() {
|
|
ginkgo.It("start klusterlet", func() {
|
|
ctx, stopKlusterlet := context.WithCancel(context.Background())
|
|
|
|
// start hub controller
|
|
go func() {
|
|
defer ginkgo.GinkgoRecover()
|
|
o := &Options{EnableSyncLabels: true}
|
|
err := o.RunKlusterletOperator(ctx, &controllercmd.ControllerContext{
|
|
KubeConfig: cfg,
|
|
EventRecorder: util.NewIntegrationTestEventRecorder("integration"),
|
|
})
|
|
gomega.Expect(err).NotTo(gomega.HaveOccurred())
|
|
}()
|
|
stopKlusterlet()
|
|
})
|
|
})
|