l-88 插曲-关于更新的一个细节

master
dongming 2 years ago
parent 5ce16fc777
commit cf99a87034

@ -69,10 +69,28 @@ func CreateIngressMsbDeployment(ctx *framework.TestContext, f *framework.Framewo
})
Context("Delete msbdeployment mod ingress", func() {
It("Should be delete mod ingress success", func() {})
It("Should not be exist msbdeployment", func() {})
It("Should not be exist deployment", func() {})
It("Should not be exist service", func() {})
It("Should not be exist ingress", func() {})
It("Should be delete mod ingress success", func() {
err = dc.Resource(msbGVR).Namespace("default").Delete(context.TODO(), obj.GetName(), metav1.DeleteOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait deleting done")
time.Sleep(time.Second)
})
It("Should not be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
})
}

@ -1,7 +1,16 @@
package create
import (
"context"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"mashibing.com/pkg/mashibing-deployment/test/framework"
)
@ -10,19 +19,79 @@ import (
// 测试创建Nodeport模式
func CreateNodeportMsbDeployment(ctx *framework.TestContext, f *framework.Framework) {
var (
// 1. 准备测试数据
ctFilePath = "create/testdata/create-nodeport.yaml"
obj = &unstructured.Unstructured{Object: make(map[string]interface{})}
dc dynamic.Interface
cs *kubernetes.Clientset
// 3. 准备测试用到的全局变量
msbGVR = schema.GroupVersionResource{
Group: "apps.mashibing.com",
Version: "v1",
Resource: "msbdeployments",
}
err error
)
BeforeEach(func() {
// 2. 加载测试数据
err = f.LoadYamlToUnstructured(ctFilePath, obj)
Expect(err).Should(BeNil())
// 4. 初始化测试用到的全局变量
dc = ctx.CreateDynamicClient()
cs = ctx.CreateClientSet()
})
Context("Create msbdeployment mod nodeport", func() {
It("Should be create mode nodeport success", func() {})
It("Should be exist msbdeployment", func() {})
It("Should be exist deployment", func() {})
It("Should be exist service", func() {})
It("Should not be exist ingress", func() {})
It("Should be create mod nodeport success", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Create(context.TODO(), obj, metav1.CreateOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait creating done")
time.Sleep(time.Second)
})
It("Should be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
})
Context("Delete msbdeployment mod nodeport", func() {
It("Should be delete mod nodeport success", func() {})
It("Should not be exist msbdeployment", func() {})
It("Should not be exist deployment", func() {})
It("Should not be exist service", func() {})
It("Should not be exist ingress", func() {})
It("Should be delete mod nodeport success", func() {
err = dc.Resource(msbGVR).Namespace("default").Delete(context.TODO(), obj.GetName(), metav1.DeleteOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait deleting done")
time.Sleep(time.Second)
})
It("Should not be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
})
}

@ -1,47 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="e2e" tests="44" failures="0" errors="0" time="88.641">
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be create mod ingress success" classname="e2e" time="1.022819158"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist msbdeployment" classname="e2e" time="0.011042164"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist deployment" classname="e2e" time="0.010476651"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist service" classname="e2e" time="0.011884409"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist ingress" classname="e2e" time="0.007711314"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should be delete mod ingress success" classname="e2e" time="0.159769005"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist msbdeployment" classname="e2e" time="0.406098839"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist deployment" classname="e2e" time="0.406216596"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist service" classname="e2e" time="0.386941655"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist ingress" classname="e2e" time="0.400914807"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be create mod ingress success" classname="e2e" time="0.398575828"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist msbdeployment" classname="e2e" time="0.40035368"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist deployment" classname="e2e" time="0.402275948"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist service" classname="e2e" time="0.397884956"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist ingress" classname="e2e" time="0.400241593"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be update to nodeport success" classname="e2e" time="0.400317655"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should not be exist ingress" classname="e2e" time="0.400142585"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should be delete success" classname="e2e" time="0.404196039"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist msbdeployment" classname="e2e" time="0.394759408"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist deployment" classname="e2e" time="0.400598306"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist service" classname="e2e" time="0.399921651"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist ingress" classname="e2e" time="0.399307785"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be create mod nodeport success" classname="e2e" time="0.400627036"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist msbdeployment" classname="e2e" time="0.399831122"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist deployment" classname="e2e" time="0.399952299"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist service" classname="e2e" time="0.3998821"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should not be exist ingress" classname="e2e" time="0.40065962"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be update to ingress success" classname="e2e" time="0.399780321"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist ingress" classname="e2e" time="0.399753287"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should be delete success" classname="e2e" time="0.400256732"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist msbdeployment" classname="e2e" time="0.399516085"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist deployment" classname="e2e" time="0.400321443"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist service" classname="e2e" time="0.39949787"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist ingress" classname="e2e" time="0.399721876"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be create mode nodeport success" classname="e2e" time="0.400345032"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be exist msbdeployment" classname="e2e" time="0.399825314"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be exist deployment" classname="e2e" time="0.399686453"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be exist service" classname="e2e" time="0.400756069"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should not be exist ingress" classname="e2e" time="0.4001103"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should be delete mod nodeport success" classname="e2e" time="0.398722227"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist msbdeployment" classname="e2e" time="0.401853646"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist deployment" classname="e2e" time="0.403237009"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist service" classname="e2e" time="0.398816187"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist ingress" classname="e2e" time="0.397479371"></testcase>
<testsuite name="e2e" tests="44" failures="0" errors="0" time="97.662">
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be create mod nodeport success" classname="e2e" time="1.026717149"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist msbdeployment" classname="e2e" time="0.030551428"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist deployment" classname="e2e" time="0.024435618"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist service" classname="e2e" time="0.037999962"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should not be exist ingress" classname="e2e" time="0.020698391"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be update to ingress success" classname="e2e" time="1.022973247"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Update msbdeployment mod nodeport to ingress Should be exist ingress" classname="e2e" time="0.035940753"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should be delete mod nodeport success" classname="e2e" time="1.017934112"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist msbdeployment" classname="e2e" time="0.008005493"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist deployment" classname="e2e" time="0.010767817"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist service" classname="e2e" time="0.009286801"></testcase>
<testcase name="Update msbdeployment mod nodeport to Ingress Delete msbdeployment n2i Should not be exist ingress" classname="e2e" time="0.372336887"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be create mod nodeport success" classname="e2e" time="1.219922741"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be exist msbdeployment" classname="e2e" time="0.050279079"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be exist deployment" classname="e2e" time="0.0223911"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should be exist service" classname="e2e" time="0.3076832"></testcase>
<testcase name="Create msbdeployment mod nodeport Create msbdeployment mod nodeport Should not be exist ingress" classname="e2e" time="0.403548755"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should be delete mod nodeport success" classname="e2e" time="1.2189811879999999"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist msbdeployment" classname="e2e" time="0.036602463"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist deployment" classname="e2e" time="0.028695034"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist service" classname="e2e" time="0.317578804"></testcase>
<testcase name="Create msbdeployment mod nodeport Delete msbdeployment mod nodeport Should not be exist ingress" classname="e2e" time="0.394650602"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be create mod ingress success" classname="e2e" time="1.20767007"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist msbdeployment" classname="e2e" time="0.011088203"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist deployment" classname="e2e" time="0.00989582"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist service" classname="e2e" time="0.371392181"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be exist ingress" classname="e2e" time="0.399642944"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should be update to nodeport success" classname="e2e" time="1.208255044"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Update msbdeployment mod ingress to nodeport Should not be exist ingress" classname="e2e" time="0.030754518"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should be delete mod ingress success" classname="e2e" time="1.023413829"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist msbdeployment" classname="e2e" time="0.011419424"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist deployment" classname="e2e" time="0.012140784"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist service" classname="e2e" time="0.114740463"></testcase>
<testcase name="Update msbdeployment mod ingress to Nodeport Delete msbdeployment i2n Should not be exist ingress" classname="e2e" time="0.399506273"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be create mod ingress success" classname="e2e" time="1.20592297"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist msbdeployment" classname="e2e" time="0.02226977"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist deployment" classname="e2e" time="0.054546523"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist service" classname="e2e" time="0.316390433"></testcase>
<testcase name="Create msbdeployment mod ingress Create msbdeployment mod ingress Should be exist ingress" classname="e2e" time="0.401976745"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should be delete mod ingress success" classname="e2e" time="1.208420674"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist msbdeployment" classname="e2e" time="0.024650323"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist deployment" classname="e2e" time="0.015709386"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist service" classname="e2e" time="0.349153042"></testcase>
<testcase name="Create msbdeployment mod ingress Delete msbdeployment mod ingress Should not be exist ingress" classname="e2e" time="0.404473546"></testcase>
</testsuite>

@ -1,7 +1,16 @@
package update
import (
"context"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"mashibing.com/pkg/mashibing-deployment/test/framework"
)
@ -10,22 +19,101 @@ import (
// 测试从Ingress模式更新为Nodeport模式
func UpdateI2NMsbDeployment(ctx *framework.TestContext, f *framework.Framework) {
var (
// 1. 准备测试数据
ctFilePath = "update/testdata/update-ingress.yaml"
ctUpdateFilePath = "update/testdata/update-i2n.yaml"
obj = &unstructured.Unstructured{Object: make(map[string]interface{})}
objUpdate = &unstructured.Unstructured{Object: make(map[string]interface{})}
dc dynamic.Interface
cs *kubernetes.Clientset
// 3. 准备测试用到的全局变量
msbGVR = schema.GroupVersionResource{
Group: "apps.mashibing.com",
Version: "v1",
Resource: "msbdeployments",
}
err error
)
BeforeEach(func() {
// 2. 加载测试数据
err = f.LoadYamlToUnstructured(ctFilePath, obj)
Expect(err).Should(BeNil())
err = f.LoadYamlToUnstructured(ctUpdateFilePath, objUpdate)
Expect(err).Should(BeNil())
// 4. 初始化测试用到的全局变量
dc = ctx.CreateDynamicClient()
cs = ctx.CreateClientSet()
})
Context("Update msbdeployment mod ingress to nodeport", func() {
It("Should be create mod ingress success", func() {})
It("Should be exist msbdeployment", func() {})
It("Should be exist deployment", func() {})
It("Should be exist service", func() {})
It("Should be exist ingress", func() {})
It("Should be update to nodeport success", func() {})
It("Should not be exist ingress", func() {})
It("Should be create mod ingress success", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Create(context.TODO(), obj, metav1.CreateOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait creating done")
time.Sleep(time.Second)
})
It("Should be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be update to nodeport success", func() {
var md *unstructured.Unstructured
md, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
objUpdate.SetResourceVersion(md.GetResourceVersion())
_, err = dc.Resource(msbGVR).Namespace("default").Update(context.TODO(), objUpdate, metav1.UpdateOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait creating done")
time.Sleep(time.Second)
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
})
Context("Delete msbdeployment i2n", func() {
It("Should be delete success", func() {})
It("Should not be exist msbdeployment", func() {})
It("Should not be exist deployment", func() {})
It("Should not be exist service", func() {})
It("Should not be exist ingress", func() {})
It("Should be delete mod ingress success", func() {
err = dc.Resource(msbGVR).Namespace("default").Delete(context.TODO(), objUpdate.GetName(), metav1.DeleteOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait deleting done")
time.Sleep(time.Second)
})
It("Should not be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
})
}

@ -1,7 +1,16 @@
package update
import (
"context"
"time"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
"mashibing.com/pkg/mashibing-deployment/test/framework"
)
@ -10,22 +19,101 @@ import (
// 测试从Nodeport模式更新为Ingress模式
func UpdateN2IMsbDeployment(ctx *framework.TestContext, f *framework.Framework) {
var (
// 1. 准备测试数据
ctFilePath = "update/testdata/update-nodeport.yaml"
ctUpdateFilePath = "update/testdata/update-n2i.yaml"
obj = &unstructured.Unstructured{Object: make(map[string]interface{})}
objUpdate = &unstructured.Unstructured{Object: make(map[string]interface{})}
dc dynamic.Interface
cs *kubernetes.Clientset
// 3. 准备测试用到的全局变量
msbGVR = schema.GroupVersionResource{
Group: "apps.mashibing.com",
Version: "v1",
Resource: "msbdeployments",
}
err error
)
BeforeEach(func() {
// 2. 加载测试数据
err = f.LoadYamlToUnstructured(ctFilePath, obj)
Expect(err).Should(BeNil())
err = f.LoadYamlToUnstructured(ctUpdateFilePath, objUpdate)
Expect(err).Should(BeNil())
// 4. 初始化测试用到的全局变量
dc = ctx.CreateDynamicClient()
cs = ctx.CreateClientSet()
})
Context("Update msbdeployment mod nodeport to ingress", func() {
It("Should be create mod nodeport success", func() {})
It("Should be exist msbdeployment", func() {})
It("Should be exist deployment", func() {})
It("Should be exist service", func() {})
It("Should not be exist ingress", func() {})
It("Should be update to ingress success", func() {})
It("Should be exist ingress", func() {})
It("Should be create mod nodeport success", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Create(context.TODO(), obj, metav1.CreateOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait creating done")
time.Sleep(time.Second)
})
It("Should be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should be update to ingress success", func() {
var md *unstructured.Unstructured
md, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), obj.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
objUpdate.SetResourceVersion(md.GetResourceVersion())
_, err = dc.Resource(msbGVR).Namespace("default").Update(context.TODO(), objUpdate, metav1.UpdateOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait creating done")
time.Sleep(time.Second)
})
It("Should be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).Should(BeNil())
})
})
Context("Delete msbdeployment n2i", func() {
It("Should be delete success", func() {})
It("Should not be exist msbdeployment", func() {})
It("Should not be exist deployment", func() {})
It("Should not be exist service", func() {})
It("Should not be exist ingress", func() {})
It("Should be delete mod nodeport success", func() {
err = dc.Resource(msbGVR).Namespace("default").Delete(context.TODO(), objUpdate.GetName(), metav1.DeleteOptions{})
Expect(err).Should(BeNil())
By("Sleep 1 second wait deleting done")
time.Sleep(time.Second)
})
It("Should not be exist msbdeployment", func() {
_, err = dc.Resource(msbGVR).Namespace("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist deployment", func() {
_, err = cs.AppsV1().Deployments("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist service", func() {
_, err = cs.CoreV1().Services("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
It("Should not be exist ingress", func() {
_, err = cs.NetworkingV1().Ingresses("default").Get(context.TODO(), objUpdate.GetName(), metav1.GetOptions{})
Expect(err).ShouldNot(BeNil())
})
})
}

Loading…
Cancel
Save