diff options
| author | KubeEdge Bot <48982446+kubeedge-bot@users.noreply.github.com> | 2020-02-28 15:42:24 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-02-28 15:42:24 +0800 |
| commit | 108e2308e0d792db6dee313d32d76aa4c34d64fa (patch) | |
| tree | 334ef0689b4ec74b21f52a909c7ead751672e17f | |
| parent | Merge pull request #1487 from kevin-wangzefeng/automated-cherry-pick-of-#1467... (diff) | |
| parent | delete device_crd dir (diff) | |
| download | kubeedge-108e2308e0d792db6dee313d32d76aa4c34d64fa.tar.gz | |
Merge pull request #1506 from fisherxu/automated-cherry-pick-of-#1492-upstream-release-1.2
Automated cherry pick of #1492: add device e2e test
| -rw-r--r-- | cloud/pkg/cloudhub/channelq/channelq.go | 3 | ||||
| -rw-r--r-- | tests/e2e/deployment/deployment_suite_test.go | 3 | ||||
| -rw-r--r-- | tests/e2e/deployment/device_crd_test.go (renamed from tests/e2e/device_crd/device_crd_test.go) | 92 | ||||
| -rw-r--r-- | tests/e2e/device_crd/device_crd_suit_test.go | 135 | ||||
| -rw-r--r-- | tests/e2e/utils/common.go | 15 | ||||
| -rw-r--r-- | tests/e2e/utils/test_setup.go | 1 |
6 files changed, 63 insertions, 186 deletions
diff --git a/cloud/pkg/cloudhub/channelq/channelq.go b/cloud/pkg/cloudhub/channelq/channelq.go index 6ca5ab1ba..9d1b1c3de 100644 --- a/cloud/pkg/cloudhub/channelq/channelq.go +++ b/cloud/pkg/cloudhub/channelq/channelq.go @@ -15,7 +15,6 @@ import ( beehiveModel "github.com/kubeedge/beehive/pkg/core/model" "github.com/kubeedge/kubeedge/cloud/pkg/cloudhub/common/model" hubconfig "github.com/kubeedge/kubeedge/cloud/pkg/cloudhub/config" - deviceconstants "github.com/kubeedge/kubeedge/cloud/pkg/devicecontroller/constants" edgeconst "github.com/kubeedge/kubeedge/cloud/pkg/edgecontroller/constants" edgemessagelayer "github.com/kubeedge/kubeedge/cloud/pkg/edgecontroller/messagelayer" "github.com/kubeedge/kubeedge/cloud/pkg/synccontroller" @@ -170,7 +169,7 @@ func isListResource(msg *beehiveModel.Message) bool { strings.Contains(msgResource, commonconst.ResourceTypeServiceList) || strings.Contains(msgResource, commonconst.ResourceTypeEndpointsList) || strings.Contains(msgResource, "membership") || - strings.Contains(msgResource, deviceconstants.ResourceTypeTwinEdgeUpdated) { + strings.Contains(msgResource, "twin/cloud_updated") { return true } diff --git a/tests/e2e/deployment/deployment_suite_test.go b/tests/e2e/deployment/deployment_suite_test.go index 051253fe3..befe2fcd7 100644 --- a/tests/e2e/deployment/deployment_suite_test.go +++ b/tests/e2e/deployment/deployment_suite_test.go @@ -60,7 +60,8 @@ func TestEdgecoreAppDeployment(t *testing.T) { utils.Infof("Node Name: %v, Node Status: %v", nodeName, status) return status }, "60s", "4s").Should(Equal("Running"), "Node register to the k8s master is unsuccessfull !!") - + err := utils.MqttConnect() + Expect(err).To(BeNil()) }) AfterSuite(func() { By("After Suite Execution....!") diff --git a/tests/e2e/device_crd/device_crd_test.go b/tests/e2e/deployment/device_crd_test.go index fe45b9640..ea6dde62f 100644 --- a/tests/e2e/device_crd/device_crd_test.go +++ b/tests/e2e/deployment/device_crd_test.go @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -package device_crd +package deployment import ( "encoding/json" @@ -162,7 +162,7 @@ var _ = Describe("Device Management test in E2E scenario", func() { deviceInstanceList, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nil) Expect(err).To(BeNil()) for _, device := range deviceInstanceList { - IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+device.Name, "") + IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+device.Name, "") Expect(IsDeviceDeleted).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) } @@ -191,7 +191,7 @@ var _ = Describe("Device Management test in E2E scenario", func() { deviceInstanceList, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nil) Expect(err).To(BeNil()) for _, device := range deviceInstanceList { - IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+device.Name, "") + IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+device.Name, "") Expect(IsDeviceDeleted).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) } @@ -210,21 +210,21 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "led") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "led") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "led") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - newLedDevice := utils.NewLedDeviceInstance(NodeName) + newLedDevice := utils.NewLedDeviceInstance(nodeName) _, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &newLedDevice) Expect(err).To(BeNil()) time.Sleep(3 * time.Second) - statusCode, body := utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode, body := utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode).Should(Equal(http.StatusOK)) var configMap v1.ConfigMap err = json.Unmarshal(body, &configMap) Expect(err).To(BeNil()) - isEqual := utils.CompareConfigMaps(configMap, utils.NewConfigMapLED(NodeName)) + isEqual := utils.CompareConfigMaps(configMap, utils.NewConfigMapLED(nodeName)) Expect(isEqual).Should(Equal(true)) - go utils.TwinSubscribe(utils.NewLedDeviceInstance(NodeName).Name) + go utils.TwinSubscribe(utils.NewLedDeviceInstance(nodeName).Name) Eventually(func() bool { return utils.TwinResult.Twin != nil }, "20s", "2s").Should(Equal(true), "Device information not reaching edge!!") @@ -247,21 +247,21 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "bluetooth") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "bluetooth") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "bluetooth") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - newBluetoothDevice := utils.NewBluetoothDeviceInstance(NodeName) + newBluetoothDevice := utils.NewBluetoothDeviceInstance(nodeName) _, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &newBluetoothDevice) Expect(err).To(BeNil()) time.Sleep(3 * time.Second) - statusCode, body := utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode, body := utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode).Should(Equal(http.StatusOK)) var configMap v1.ConfigMap err = json.Unmarshal(body, &configMap) Expect(err).To(BeNil()) - isEqual := utils.CompareConfigMaps(configMap, utils.NewConfigMapBluetooth(NodeName)) + isEqual := utils.CompareConfigMaps(configMap, utils.NewConfigMapBluetooth(nodeName)) Expect(isEqual).Should(Equal(true)) - go utils.TwinSubscribe(utils.NewBluetoothDeviceInstance(NodeName).Name) + go utils.TwinSubscribe(utils.NewBluetoothDeviceInstance(nodeName).Name) Eventually(func() bool { return utils.TwinResult.Twin != nil }, "20s", "2s").Should(Equal(true), "Device information not reaching edge!!") @@ -284,21 +284,21 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "modbus") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "modbus") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "modbus") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - newModbusDevice := utils.NewModbusDeviceInstance(NodeName) + newModbusDevice := utils.NewModbusDeviceInstance(nodeName) _, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &newModbusDevice) Expect(err).To(BeNil()) time.Sleep(3 * time.Second) - statusCode, body := utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode, body := utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode).Should(Equal(http.StatusOK)) var configMap v1.ConfigMap err = json.Unmarshal(body, &configMap) Expect(err).To(BeNil()) - isEqual := utils.CompareConfigMaps(configMap, utils.NewConfigMapModbus(NodeName)) + isEqual := utils.CompareConfigMaps(configMap, utils.NewConfigMapModbus(nodeName)) Expect(isEqual).Should(Equal(true)) - go utils.TwinSubscribe(utils.NewModbusDeviceInstance(NodeName).Name) + go utils.TwinSubscribe(utils.NewModbusDeviceInstance(nodeName).Name) Eventually(func() bool { return utils.TwinResult.Twin != nil }, "20s", "2s").Should(Equal(true), "Device information not reaching edge!!") @@ -317,15 +317,15 @@ var _ = Describe("Device Management test in E2E scenario", func() { Expect(isEqual).Should(Equal(true)) }) It("E2E_CREATE_DEVICE_4: Create device instance for incorrect device instance", func() { - statusCode := utils.DeleteConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode := utils.DeleteConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode == http.StatusOK || statusCode == http.StatusNotFound).Should(Equal(true)) IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "led") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "incorrect-instance") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "incorrect-instance") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusUnprocessableEntity)) - statusCode, _ = utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode, _ = utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode).Should(Equal(http.StatusNotFound)) }) It("E2E_UPDATE_DEVICE_1: Update device instance for LED device (No Protocol)", func() { @@ -333,17 +333,17 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "led") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "led") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "led") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+utils.UpdatedLedDeviceInstance(NodeName).Name, "led") + IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+utils.UpdatedLedDeviceInstance(nodeName).Name, "led") Expect(IsDeviceUpdated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) - updatedLedDevice := utils.UpdatedLedDeviceInstance(NodeName) + updatedLedDevice := utils.UpdatedLedDeviceInstance(nodeName) time.Sleep(2 * time.Second) _, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &updatedLedDevice) Expect(err).To(BeNil()) - go utils.TwinSubscribe(utils.UpdatedLedDeviceInstance(NodeName).Name) + go utils.TwinSubscribe(utils.UpdatedLedDeviceInstance(nodeName).Name) Eventually(func() bool { return utils.TwinResult.Twin != nil }, "20s", "2s").Should(Equal(true), "Device information not reaching edge!!") @@ -366,17 +366,17 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "bluetooth") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "bluetooth") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "bluetooth") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+utils.UpdatedBluetoothDeviceInstance(NodeName).Name, "bluetooth") + IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+utils.UpdatedBluetoothDeviceInstance(nodeName).Name, "bluetooth") Expect(IsDeviceUpdated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) - updatedBluetoothDevice := utils.UpdatedBluetoothDeviceInstance(NodeName) + updatedBluetoothDevice := utils.UpdatedBluetoothDeviceInstance(nodeName) time.Sleep(2 * time.Second) _, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &updatedBluetoothDevice) Expect(err).To(BeNil()) - go utils.TwinSubscribe(utils.UpdatedBluetoothDeviceInstance(NodeName).Name) + go utils.TwinSubscribe(utils.UpdatedBluetoothDeviceInstance(nodeName).Name) Eventually(func() bool { return utils.TwinResult.Twin != nil }, "20s", "2s").Should(Equal(true), "Device information not reaching edge!!") @@ -399,17 +399,17 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "modbus") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "modbus") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "modbus") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+utils.UpdatedModbusDeviceInstance(NodeName).Name, "modbus") + IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+utils.UpdatedModbusDeviceInstance(nodeName).Name, "modbus") Expect(IsDeviceUpdated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) - updatedModbusDevice := utils.UpdatedModbusDeviceInstance(NodeName) + updatedModbusDevice := utils.UpdatedModbusDeviceInstance(nodeName) time.Sleep(2 * time.Second) _, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &updatedModbusDevice) Expect(err).To(BeNil()) - go utils.TwinSubscribe(utils.UpdatedModbusDeviceInstance(NodeName).Name) + go utils.TwinSubscribe(utils.UpdatedModbusDeviceInstance(nodeName).Name) Eventually(func() bool { return utils.TwinResult.Twin != nil }, "20s", "2s").Should(Equal(true), "Device information not reaching edge!!") @@ -431,10 +431,10 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "led") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "led") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "led") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+utils.UpdatedLedDeviceInstance(NodeName).Name, "incorrect-instance") + IsDeviceUpdated, statusCode := utils.HandleDeviceInstance(http.MethodPatch, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+utils.UpdatedLedDeviceInstance(nodeName).Name, "incorrect-instance") Expect(IsDeviceUpdated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusUnprocessableEntity)) }) @@ -442,21 +442,21 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "led") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "led") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "led") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) time.Sleep(1 * time.Second) - statusCode, _ = utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode, _ = utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode).Should(Equal(http.StatusOK)) - IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+utils.NewLedDeviceInstance(NodeName).Name, "") + IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+utils.NewLedDeviceInstance(nodeName).Name, "") Expect(IsDeviceDeleted).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) time.Sleep(1 * time.Second) - statusCode, _ = utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + NodeName) + statusCode, _ = utils.GetConfigmap(ctx.Cfg.K8SMasterForKubeEdge + ConfigmapHandler + "/" + "device-profile-config-" + nodeName) Expect(statusCode).Should(Equal(http.StatusNotFound)) }) It("E2E_DELETE_DEVICE_2: Delete device instance for a non-existing device", func() { - IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+utils.NewLedDeviceModel().Name, "") + IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+utils.NewLedDeviceModel().Name, "") Expect(IsDeviceDeleted).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusNotFound)) }) @@ -469,7 +469,7 @@ var _ = Describe("Device Management test in E2E scenario", func() { deviceInstanceList, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nil) Expect(err).To(BeNil()) for _, device := range deviceInstanceList { - IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+device.Name, "") + IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+device.Name, "") Expect(IsDeviceDeleted).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) } @@ -498,7 +498,7 @@ var _ = Describe("Device Management test in E2E scenario", func() { deviceInstanceList, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nil) Expect(err).To(BeNil()) for _, device := range deviceInstanceList { - IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "/"+device.Name, "") + IsDeviceDeleted, statusCode := utils.HandleDeviceInstance(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "/"+device.Name, "") Expect(IsDeviceDeleted).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusOK)) } @@ -517,20 +517,20 @@ var _ = Describe("Device Management test in E2E scenario", func() { IsDeviceModelCreated, statusCode := utils.HandleDeviceModel(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceModelHandler, "", "led") Expect(IsDeviceModelCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, NodeName, "", "led") + IsDeviceCreated, statusCode := utils.HandleDeviceInstance(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, nodeName, "", "led") Expect(IsDeviceCreated).Should(BeTrue()) Expect(statusCode).Should(Equal(http.StatusCreated)) - newLedDevice := utils.NewLedDeviceInstance(NodeName) + newLedDevice := utils.NewLedDeviceInstance(nodeName) time.Sleep(3 * time.Second) var deviceTwinUpdateMessage utils.DeviceTwinUpdate reportedValue := "OFF" deviceTwinUpdateMessage.Twin = map[string]*utils.MsgTwin{ "power-status": {Actual: &utils.TwinValue{Value: &reportedValue}, Metadata: &utils.TypeMetadata{Type: "string"}}, } - err := utils.ChangeTwinValue(deviceTwinUpdateMessage, utils.NewLedDeviceInstance(NodeName).Name) + err := utils.ChangeTwinValue(deviceTwinUpdateMessage, utils.NewLedDeviceInstance(nodeName).Name) Expect(err).To(BeNil()) time.Sleep(3 * time.Second) - newLedDevice = utils.NewLedDeviceInstance(NodeName) + newLedDevice = utils.NewLedDeviceInstance(nodeName) list, err := utils.GetDevice(&deviceList, ctx.Cfg.K8SMasterForKubeEdge+DeviceInstanceHandler, &newLedDevice) Expect(err).To(BeNil()) Expect(list[0].Status.Twins[0].PropertyName).To(Equal("power-status")) diff --git a/tests/e2e/device_crd/device_crd_suit_test.go b/tests/e2e/device_crd/device_crd_suit_test.go deleted file mode 100644 index 507a77ff5..000000000 --- a/tests/e2e/device_crd/device_crd_suit_test.go +++ /dev/null @@ -1,135 +0,0 @@ -/* -Copyright 2019 The KubeEdge 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 device_crd - -import ( - "bytes" - "io/ioutil" - "net/http" - "path" - "path/filepath" - "runtime" - "testing" - - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" - - "github.com/kubeedge/kubeedge/tests/e2e/constants" - "github.com/kubeedge/kubeedge/tests/e2e/utils" -) - -//context to load config and access across the package -var ( - ctx *utils.TestContext - nodeSelector string - NodeName string -) -var ( - deviceCRDPath = "../../../build/crds/devices/devices_v1alpha1_device.yaml" - deviceModelCRDPath = "../../../build/crds/devices/devices_v1alpha1_devicemodel.yaml" - crdHandler = "/apis/apiextensions.k8s.io/v1beta1/customresourcedefinitions" - deviceCRD = "devices.devices.kubeedge.io" - deviceModelCRD = "devicemodels.devices.kubeedge.io" -) - -//Function to run the Ginkgo Test -func TestEdgecoreAppDeployment(t *testing.T) { - - RegisterFailHandler(Fail) - var _ = BeforeSuite(func() { - client := &http.Client{} - utils.Infof("Before Suite Execution") - ctx = utils.NewTestContext(utils.LoadConfig()) - NodeName = "integration-node-" + utils.GetRandomString(10) - nodeSelector = "node-" + utils.GetRandomString(3) - - //Generate Cerificates for Edge and Cloud nodes copy to respective folders - Expect(utils.GenerateCerts()).Should(BeNil()) - //Do the neccessary config changes in Cloud and Edge nodes - Expect(utils.DeploySetup(ctx, NodeName, "deployment")).Should(BeNil()) - //Run ./cloudcore binary - Expect(utils.StartCloudCore()).Should(BeNil()) - //Register the Edge Node to Master - Expect(utils.RegisterNodeToMaster(NodeName, ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, nodeSelector)).Should(BeNil()) - //Run ./edgecore after node registration - Expect(utils.StartEdgeCore()).Should(BeNil()) - //Check node successfully registered or not - Eventually(func() string { - status := utils.CheckNodeReadyStatus(ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, NodeName) - utils.Infof("Node Name: %v, Node Status: %v", NodeName, status) - return status - }, "60s", "4s").Should(Equal("Running"), "Node register to the k8s master is unsuccessfull !!") - //Apply the CRDs - filePath := path.Join(getpwd(), deviceModelCRDPath) - deviceModelBody, err := ioutil.ReadFile(filePath) - Expect(err).Should(BeNil()) - BodyBuf := bytes.NewReader(deviceModelBody) - req, err := http.NewRequest(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+crdHandler, BodyBuf) - Expect(err).Should(BeNil()) - req.Header.Set("Content-Type", "application/yaml") - resp, err := client.Do(req) - Expect(err).Should(BeNil()) - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - filePath = path.Join(getpwd(), deviceCRDPath) - deviceBody, err := ioutil.ReadFile(filePath) - Expect(err).Should(BeNil()) - BodyBuf = bytes.NewReader(deviceBody) - req, err = http.NewRequest(http.MethodPost, ctx.Cfg.K8SMasterForKubeEdge+crdHandler, BodyBuf) - Expect(err).Should(BeNil()) - req.Header.Set("Content-Type", "application/yaml") - resp, err = client.Do(req) - Expect(err).Should(BeNil()) - Expect(resp.StatusCode).Should(Equal(http.StatusCreated)) - err = utils.MqttConnect() - Expect(err).To(BeNil()) - }) - AfterSuite(func() { - By("After Suite Execution....!") - //Deregister the edge node from master - Expect(utils.DeRegisterNodeFromMaster(ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, NodeName)).Should(BeNil()) - Eventually(func() int { - statuscode := utils.CheckNodeDeleteStatus(ctx.Cfg.K8SMasterForKubeEdge+constants.NodeHandler, NodeName) - utils.Infof("Node Name: %v, Node Statuscode: %v", NodeName, statuscode) - return statuscode - }, "60s", "4s").Should(Equal(http.StatusNotFound), "Node register to the k8s master is unsuccessfull !!") - client := &http.Client{} - req, err := http.NewRequest(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+crdHandler+"/"+deviceModelCRD, nil) - Expect(err).Should(BeNil()) - req.Header.Set("Content-Type", "application/yaml") - resp, err := client.Do(req) - Expect(err).Should(BeNil()) - Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - req, err = http.NewRequest(http.MethodDelete, ctx.Cfg.K8SMasterForKubeEdge+crdHandler+"/"+deviceCRD, nil) - Expect(err).Should(BeNil()) - req.Header.Set("Content-Type", "application/yaml") - resp, err = client.Do(req) - Expect(err).Should(BeNil()) - Expect(resp.StatusCode).Should(Equal(http.StatusOK)) - - //Run the Cleanup steps to kill edgecore and cloudcore binaries - Expect(utils.CleanUp("device_crd")).Should(BeNil()) - utils.Infof("Cleanup is Successfull !!") - }) - RunSpecs(t, "kubeedge Device Managemnet Suite") -} - -func getpwd() string { - _, file, _, _ := runtime.Caller(0) - dir, err := filepath.Abs(filepath.Dir(file)) - Expect(err).Should(BeNil()) - return dir -} diff --git a/tests/e2e/utils/common.go b/tests/e2e/utils/common.go index 388ca927f..8e5db5d4c 100644 --- a/tests/e2e/utils/common.go +++ b/tests/e2e/utils/common.go @@ -539,7 +539,13 @@ func HandleDeviceModel(operation string, apiserver string, UID string, protocolT var err error var body io.Reader - client := &http.Client{} + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + client := &http.Client{ + Transport: tr, + } + switch operation { case "POST": body := newDeviceModelObject(protocolType, false) @@ -583,7 +589,12 @@ func HandleDeviceInstance(operation string, apiserver string, nodeSelector strin var err error var body io.Reader - client := &http.Client{} + tr := &http.Transport{ + TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, + } + client := &http.Client{ + Transport: tr, + } switch operation { case "POST": body := newDeviceInstanceObject(nodeSelector, protocolType, false) diff --git a/tests/e2e/utils/test_setup.go b/tests/e2e/utils/test_setup.go index 1ce81d944..6506845e4 100644 --- a/tests/e2e/utils/test_setup.go +++ b/tests/e2e/utils/test_setup.go @@ -174,6 +174,7 @@ func createEdgeCoreConfigFile(nodeName string) { c.Modules.EdgeHub.TLSPrivateKeyFile = "/tmp/edgecore/kubeedge.key" c.Modules.Edged.HostnameOverride = nodeName c.DataBase.DataSource = "/tmp/edgecore/edgecore.db" + c.Modules.EventBus.MqttMode = edgecore.MqttModeInternal data, err := yaml.Marshal(c) if err != nil { |
