mirror of https://github.com/kubeedge/beehive.git
modify test case; remove conf/modules.yaml
Kubeedge-commit: 66c6053169951a092cd1321f1b18f9a0587edc0c
This commit is contained in:
parent
ad0eb59804
commit
4b53c74fda
|
|
@ -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)
|
||||
}
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
modules:
|
||||
enabled: [destinationmodule, sourcemodule, destinationgroupmodule]
|
||||
|
|
@ -1,2 +0,0 @@
|
|||
modules:
|
||||
enabled: [destination_module, sourcemodule]
|
||||
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue