mirror of
https://github.com/kubevela/kubevela.git
synced 2026-02-14 18:10:21 +00:00
Some checks failed
CodeQL / Analyze (go) (push) Failing after 6m23s
Definition-Lint / definition-doc (push) Failing after 3m8s
E2E MultiCluster Test / detect-noop (push) Successful in 6s
E2E Test / detect-noop (push) Successful in 3s
Go / detect-noop (push) Successful in 2s
license / Check for unapproved licenses (push) Failing after 18s
Registry / publish-core-images (push) Failing after 1m4s
Unit-Test / detect-noop (push) Successful in 20s
Sync SDK / sync_sdk (push) Failing after 3m9s
Go / staticcheck (push) Successful in 6m17s
Go / check-diff (push) Failing after 19m4s
Go / check-core-image-build (push) Failing after 5m44s
Go / check-cli-image-build (push) Failing after 3m31s
Unit-Test / unit-tests (push) Failing after 13m54s
Go / lint (push) Failing after 1h53m27s
Scorecards supply-chain security / Scorecards analysis (push) Failing after 1m27s
E2E MultiCluster Test / e2e-multi-cluster-tests (v1.29) (push) Has been cancelled
E2E Test / e2e-tests (v1.29) (push) Has been cancelled
Go / check-windows (push) Has been cancelled
* chore: update k8s to 1.29 Signed-off-by: phantomnat <w.nattadej@gmail.com> * fix: unit test Signed-off-by: phantomnat <w.nattadej@gmail.com> * fix: lint Signed-off-by: phantomnat <w.nattadej@gmail.com> * fix: lint Signed-off-by: phantomnat <w.nattadej@gmail.com> * fix: e2e Signed-off-by: phantomnat <w.nattadej@gmail.com> * fix: lint and e2e test Signed-off-by: phantomnat <w.nattadej@gmail.com> * test(e2e): increase timeout Signed-off-by: phantomnat <w.nattadej@gmail.com> * fix e2e and scripts Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com> * make reviewable Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com> * rollback a unnecessary ut change Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com> * update go.mod to import merged workflow Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com> --------- Signed-off-by: phantomnat <w.nattadej@gmail.com> Signed-off-by: AiRanthem <zhongtianyun.zty@alibaba-inc.com> Co-authored-by: phantomnat <w.nattadej@gmail.com>
98 lines
2.6 KiB
Go
98 lines
2.6 KiB
Go
/*
|
|
Copyright 2021 The KubeVela Authors.
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
*/
|
|
|
|
package cli
|
|
|
|
import (
|
|
"context"
|
|
"math/rand"
|
|
"testing"
|
|
"time"
|
|
|
|
cuexv1alpha1 "github.com/kubevela/pkg/apis/cue/v1alpha1"
|
|
"github.com/kubevela/pkg/util/singleton"
|
|
. "github.com/onsi/ginkgo/v2"
|
|
. "github.com/onsi/gomega"
|
|
corev1 "k8s.io/api/core/v1"
|
|
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
|
"k8s.io/client-go/discovery"
|
|
"k8s.io/client-go/dynamic/fake"
|
|
"k8s.io/client-go/rest"
|
|
"k8s.io/utils/ptr"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
"sigs.k8s.io/controller-runtime/pkg/envtest"
|
|
|
|
"github.com/oam-dev/kubevela/apis/types"
|
|
"github.com/oam-dev/kubevela/pkg/utils/common"
|
|
)
|
|
|
|
func TestCli(t *testing.T) {
|
|
RegisterFailHandler(Fail)
|
|
RunSpecs(t, "Cli Suite")
|
|
}
|
|
|
|
var cfg *rest.Config
|
|
var k8sClient client.Client
|
|
var testEnv *envtest.Environment
|
|
var dc *discovery.DiscoveryClient
|
|
|
|
var _ = BeforeSuite(func() {
|
|
rand.Seed(time.Now().UnixNano())
|
|
By("bootstrapping test environment")
|
|
|
|
testEnv = &envtest.Environment{
|
|
ControlPlaneStartTimeout: time.Minute * 3,
|
|
ControlPlaneStopTimeout: time.Minute,
|
|
UseExistingCluster: ptr.To(false),
|
|
CRDDirectoryPaths: []string{"../../charts/vela-core/crds"},
|
|
}
|
|
|
|
By("start kube test env")
|
|
var err error
|
|
cfg, err = testEnv.Start()
|
|
Expect(err).ShouldNot(HaveOccurred())
|
|
Expect(cfg).ToNot(BeNil())
|
|
|
|
By("new kube client")
|
|
cfg.Timeout = time.Minute * 2
|
|
testScheme := common.Scheme
|
|
err = cuexv1alpha1.AddToScheme(testScheme)
|
|
Expect(err).NotTo(HaveOccurred())
|
|
k8sClient, err = client.New(cfg, client.Options{Scheme: testScheme})
|
|
Expect(err).Should(BeNil())
|
|
Expect(k8sClient).ToNot(BeNil())
|
|
singleton.KubeClient.Set(k8sClient)
|
|
fakeDynamicClient := fake.NewSimpleDynamicClient(testScheme)
|
|
singleton.DynamicClient.Set(fakeDynamicClient)
|
|
|
|
dc, err = discovery.NewDiscoveryClientForConfig(cfg)
|
|
Expect(err).ToNot(HaveOccurred())
|
|
Expect(dc).ShouldNot(BeNil())
|
|
|
|
By("new namespace")
|
|
err = k8sClient.Create(context.TODO(), &corev1.Namespace{
|
|
ObjectMeta: v1.ObjectMeta{Name: types.DefaultKubeVelaNS},
|
|
})
|
|
Expect(err).Should(BeNil())
|
|
})
|
|
|
|
var _ = AfterSuite(func() {
|
|
if testEnv != nil {
|
|
err := testEnv.Stop()
|
|
Expect(err).Should(BeNil())
|
|
}
|
|
})
|