summaryrefslogtreecommitdiff
path: root/staging
diff options
context:
space:
mode:
authorlmxia <344905745@qq.com>2020-04-09 12:51:24 +0800
committerlmxia <344905745@qq.com>2020-04-09 12:51:24 +0800
commit66c6053169951a092cd1321f1b18f9a0587edc0c (patch)
tree8f76684f060b6cb22c65bc13c8ba9d5098a39f2b /staging
parentMerge pull request #1580 from chendave/services (diff)
downloadkubeedge-66c6053169951a092cd1321f1b18f9a0587edc0c.tar.gz
modify test case; remove conf/modules.yaml
Diffstat (limited to 'staging')
-rw-r--r--staging/src/github.com/kubeedge/beehive/pkg/common/util/file_util.go17
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/cmd/conf/modules.yaml2
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/conf/modules.yaml2
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go24
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go18
-rw-r--r--staging/src/github.com/kubeedge/beehive/test/modules/test_source.go20
6 files changed, 28 insertions, 55 deletions
diff --git a/staging/src/github.com/kubeedge/beehive/pkg/common/util/file_util.go b/staging/src/github.com/kubeedge/beehive/pkg/common/util/file_util.go
deleted file mode 100644
index 95302ba63..000000000
--- a/staging/src/github.com/kubeedge/beehive/pkg/common/util/file_util.go
+++ /dev/null
@@ -1,17 +0,0 @@
-package util
-
-import (
- "fmt"
- "os"
- "path/filepath"
- "strings"
-)
-
-// GetCurrentDirectory get dir
-func GetCurrentDirectory() string {
- dir, err := filepath.Abs(filepath.Dir(os.Args[0]))
- if err != nil {
- fmt.Printf("error when reading currentDirectory:%v\n", err)
- }
- return strings.Replace(dir, "\\", "/", -1)
-}
diff --git a/staging/src/github.com/kubeedge/beehive/test/cmd/conf/modules.yaml b/staging/src/github.com/kubeedge/beehive/test/cmd/conf/modules.yaml
deleted file mode 100644
index 9306e9dc1..000000000
--- a/staging/src/github.com/kubeedge/beehive/test/cmd/conf/modules.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-modules:
- enabled: [destinationmodule, sourcemodule, destinationgroupmodule]
diff --git a/staging/src/github.com/kubeedge/beehive/test/conf/modules.yaml b/staging/src/github.com/kubeedge/beehive/test/conf/modules.yaml
deleted file mode 100644
index e92e63a08..000000000
--- a/staging/src/github.com/kubeedge/beehive/test/conf/modules.yaml
+++ /dev/null
@@ -1,2 +0,0 @@
-modules:
- enabled: [destination_module, sourcemodule]
diff --git a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go
index fb1ada882..257634229 100644
--- a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go
+++ b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination.go
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/kubeedge/beehive/pkg/core"
- "github.com/kubeedge/beehive/pkg/core/context"
+ beehiveContext "github.com/kubeedge/beehive/pkg/core/context"
)
//Constants for module name and group
@@ -14,7 +14,10 @@ const (
)
type testModuleDest struct {
- context *context.Context
+}
+
+func (m *testModuleDest) Enable() bool {
+ return true
}
func init() {
@@ -29,22 +32,21 @@ func (*testModuleDest) Group() string {
return DestinationGroup
}
-func (m *testModuleDest) Start(c *context.Context) {
- m.context = c
- message, err := c.Receive(DestinationModule)
+func (m *testModuleDest) Start() {
+ message, err := beehiveContext.Receive(DestinationModule)
fmt.Printf("destination module receive message:%v error:%v\n", message, err)
- message, err = c.Receive(DestinationModule)
+ message, err = beehiveContext.Receive(DestinationModule)
fmt.Printf("destination module receive message:%v error:%v\n", message, err)
resp := message.NewRespByMessage(&message, "fine")
if message.IsSync() {
- c.SendResp(*resp)
+ beehiveContext.SendResp(*resp)
}
- message, err = c.Receive(DestinationModule)
+ message, err = beehiveContext.Receive(DestinationModule)
fmt.Printf("destination module receive message:%v error:%v\n", message, err)
if message.IsSync() {
resp = message.NewRespByMessage(&message, "fine")
- c.SendResp(*resp)
+ beehiveContext.SendResp(*resp)
}
//message, err = c.Receive(DestinationModule)
@@ -54,7 +56,3 @@ func (m *testModuleDest) Start(c *context.Context) {
// c.SendResp(*resp)
//}
}
-
-func (m *testModuleDest) Cleanup() {
- m.context.Cleanup(m.Name())
-}
diff --git a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go
index b8bcd3f50..df20d9039 100644
--- a/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go
+++ b/staging/src/github.com/kubeedge/beehive/test/modules/test_destination_group.go
@@ -4,7 +4,7 @@ import (
"fmt"
"github.com/kubeedge/beehive/pkg/core"
- "github.com/kubeedge/beehive/pkg/core/context"
+ beehiveContext "github.com/kubeedge/beehive/pkg/core/context"
)
//Constant for test module destination group name
@@ -13,7 +13,10 @@ const (
)
type testModuleDestGroup struct {
- context *context.Context
+}
+
+func (m *testModuleDestGroup) Enable() bool {
+ return true
}
func init() {
@@ -28,16 +31,11 @@ func (*testModuleDestGroup) Group() string {
return DestinationGroup
}
-func (m *testModuleDestGroup) Start(c *context.Context) {
- m.context = c
- message, err := c.Receive(DestinationGroupModule)
+func (m *testModuleDestGroup) Start() {
+ message, err := beehiveContext.Receive(DestinationGroupModule)
fmt.Printf("destination group module receive message:%v error:%v\n", message, err)
if message.IsSync() {
resp := message.NewRespByMessage(&message, "10 years old")
- c.SendResp(*resp)
+ beehiveContext.SendResp(*resp)
}
}
-
-func (m *testModuleDestGroup) Cleanup() {
- m.context.Cleanup(m.Name())
-}
diff --git a/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go b/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go
index 50c6e48ef..768ab4823 100644
--- a/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go
+++ b/staging/src/github.com/kubeedge/beehive/test/modules/test_source.go
@@ -5,7 +5,7 @@ import (
"time"
"github.com/kubeedge/beehive/pkg/core"
- "github.com/kubeedge/beehive/pkg/core/context"
+ beehiveContext "github.com/kubeedge/beehive/pkg/core/context"
"github.com/kubeedge/beehive/pkg/core/model"
)
@@ -16,13 +16,16 @@ const (
)
type testModuleSource struct {
- context *context.Context
}
func init() {
core.Register(&testModuleSource{})
}
+func (m *testModuleSource) Enable() bool {
+ return true
+}
+
func (*testModuleSource) Name() string {
return SourceModule
}
@@ -31,15 +34,14 @@ func (*testModuleSource) Group() string {
return SourceGroup
}
-func (m *testModuleSource) Start(c *context.Context) {
- m.context = c
+func (m *testModuleSource) Start() {
message := model.NewMessage("").SetRoute(SourceModule, "").
SetResourceOperation("test", model.InsertOperation).FillBody("hello")
- c.Send(DestinationModule, *message)
+ beehiveContext.Send(DestinationModule, *message)
message = model.NewMessage("").SetRoute(SourceModule, "").
SetResourceOperation("test", model.UpdateOperation).FillBody("how are you")
- resp, err := c.SendSync(DestinationModule, *message, 5*time.Second)
+ resp, err := beehiveContext.SendSync(DestinationModule, *message, 5*time.Second)
if err != nil {
fmt.Printf("failed to send sync message, error:%v\n", err)
} else {
@@ -48,9 +50,5 @@ func (m *testModuleSource) Start(c *context.Context) {
message = model.NewMessage("").SetRoute(SourceModule, DestinationGroup).
SetResourceOperation("test", model.DeleteOperation).FillBody("fine")
- c.SendToGroup(DestinationGroup, *message)
-}
-
-func (m *testModuleSource) Cleanup() {
- m.context.Cleanup(m.Name())
+ beehiveContext.SendToGroup(DestinationGroup, *message)
}