Skip to content

Commit

Permalink
comment on nodepool related e2e test temporarily
Browse files Browse the repository at this point in the history
Signed-off-by: ricky <yricky509@gmail.com>
  • Loading branch information
y-ykcir committed Jul 12, 2023
1 parent 041c085 commit d30e94f
Show file tree
Hide file tree
Showing 3 changed files with 487 additions and 508 deletions.
202 changes: 101 additions & 101 deletions test/e2e/yurt/nodepool.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,104 +16,104 @@ limitations under the License.

package yurt

import (
"context"
"errors"
"fmt"
"time"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"k8s.io/apimachinery/pkg/util/rand"
"k8s.io/apimachinery/pkg/util/sets"
runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"

"github.com/openyurtio/openyurt/pkg/apis/apps/v1beta1"
"github.com/openyurtio/openyurt/test/e2e/util"
ycfg "github.com/openyurtio/openyurt/test/e2e/yurtconfig"
)

var _ = Describe("nodepool test", func() {
ctx := context.Background()
var k8sClient runtimeclient.Client
poolToNodesMap := make(map[string]sets.String)

checkNodePoolStatus := func(poolToNodesMap map[string]sets.String) error {
nps := &v1beta1.NodePoolList{}
if err := k8sClient.List(ctx, nps); err != nil {
return err
}
for _, tmp := range nps.Items {
if int(tmp.Status.ReadyNodeNum) != poolToNodesMap[tmp.Name].Len() {
return errors.New("nodepool size not match")
}
}
return nil
}

BeforeEach(func() {
By("Start to run nodepool test, cleanup previous resources")
k8sClient = ycfg.YurtE2eCfg.RuntimeClient
poolToNodesMap = map[string]sets.String{}

util.CleanupNodePoolLabel(ctx, k8sClient)
util.CleanupNodePool(ctx, k8sClient)
})

AfterEach(func() {
By("Cleanup resources after test")
util.CleanupNodePoolLabel(ctx, k8sClient)
util.CleanupNodePool(ctx, k8sClient)
})

It("Test NodePool empty", func() {
By("Run noolpool empty")
Eventually(
func() error {
return util.InitNodeAndNodePool(ctx, k8sClient, poolToNodesMap)
},
time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))

Eventually(
func() error {
return checkNodePoolStatus(poolToNodesMap)
},
time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
})

It("Test NodePool create", func() {
By("Run nodepool create")

npName := fmt.Sprintf("test-%s", rand.String(4))
poolToNodesMap[npName] = sets.NewString("openyurt-e2e-test-worker", "openyurt-e2e-test-worker2")
Eventually(
func() error {
return util.InitNodeAndNodePool(ctx, k8sClient, poolToNodesMap)
},
time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))

Eventually(
func() error {
return checkNodePoolStatus(poolToNodesMap)
},
time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
})

It(" Test Multiple NodePools With Nodes", func() {
poolToNodesMap["beijing"] = sets.NewString("openyurt-e2e-test-worker")
poolToNodesMap["hangzhou"] = sets.NewString("openyurt-e2e-test-worker2")

Eventually(
func() error {
return util.InitNodeAndNodePool(ctx, k8sClient, poolToNodesMap)
},
time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))

Eventually(
func() error {
return checkNodePoolStatus(poolToNodesMap)
},
time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
})

})
//import (
// "context"
// "errors"
// "fmt"
// "time"
//
// . "github.com/onsi/ginkgo/v2"
// . "github.com/onsi/gomega"
// "k8s.io/apimachinery/pkg/util/rand"
// "k8s.io/apimachinery/pkg/util/sets"
// runtimeclient "sigs.k8s.io/controller-runtime/pkg/client"
//
// "github.com/openyurtio/openyurt/pkg/apis/apps/v1beta1"
// "github.com/openyurtio/openyurt/test/e2e/util"
// ycfg "github.com/openyurtio/openyurt/test/e2e/yurtconfig"
//)
//
//var _ = Describe("nodepool test", func() {
// ctx := context.Background()
// var k8sClient runtimeclient.Client
// poolToNodesMap := make(map[string]sets.String)
//
// checkNodePoolStatus := func(poolToNodesMap map[string]sets.String) error {
// nps := &v1beta1.NodePoolList{}
// if err := k8sClient.List(ctx, nps); err != nil {
// return err
// }
// for _, tmp := range nps.Items {
// if int(tmp.Status.ReadyNodeNum) != poolToNodesMap[tmp.Name].Len() {
// return errors.New("nodepool size not match")
// }
// }
// return nil
// }
//
// BeforeEach(func() {
// By("Start to run nodepool test, cleanup previous resources")
// k8sClient = ycfg.YurtE2eCfg.RuntimeClient
// poolToNodesMap = map[string]sets.String{}
//
// util.CleanupNodePoolLabel(ctx, k8sClient)
// util.CleanupNodePool(ctx, k8sClient)
// })
//
// AfterEach(func() {
// By("Cleanup resources after test")
// util.CleanupNodePoolLabel(ctx, k8sClient)
// util.CleanupNodePool(ctx, k8sClient)
// })
//
// It("Test NodePool empty", func() {
// By("Run noolpool empty")
// Eventually(
// func() error {
// return util.InitNodeAndNodePool(ctx, k8sClient, poolToNodesMap)
// },
// time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
//
// Eventually(
// func() error {
// return checkNodePoolStatus(poolToNodesMap)
// },
// time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
// })
//
// It("Test NodePool create", func() {
// By("Run nodepool create")
//
// npName := fmt.Sprintf("test-%s", rand.String(4))
// poolToNodesMap[npName] = sets.NewString("openyurt-e2e-test-worker", "openyurt-e2e-test-worker2")
// Eventually(
// func() error {
// return util.InitNodeAndNodePool(ctx, k8sClient, poolToNodesMap)
// },
// time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
//
// Eventually(
// func() error {
// return checkNodePoolStatus(poolToNodesMap)
// },
// time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
// })
//
// It(" Test Multiple NodePools With Nodes", func() {
// poolToNodesMap["beijing"] = sets.NewString("openyurt-e2e-test-worker")
// poolToNodesMap["hangzhou"] = sets.NewString("openyurt-e2e-test-worker2")
//
// Eventually(
// func() error {
// return util.InitNodeAndNodePool(ctx, k8sClient, poolToNodesMap)
// },
// time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
//
// Eventually(
// func() error {
// return checkNodePoolStatus(poolToNodesMap)
// },
// time.Second*5, time.Millisecond*500).Should(SatisfyAny(BeNil()))
// })
//
//})
Loading

0 comments on commit d30e94f

Please sign in to comment.