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"
|
"fmt"
|
||||||
|
|
||||||
"github.com/kubeedge/beehive/pkg/core"
|
"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
|
//Constants for module name and group
|
||||||
|
|
@ -14,7 +14,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testModuleDest struct {
|
type testModuleDest struct {
|
||||||
context *context.Context
|
}
|
||||||
|
|
||||||
|
func (m *testModuleDest) Enable() bool {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -29,22 +32,21 @@ func (*testModuleDest) Group() string {
|
||||||
return DestinationGroup
|
return DestinationGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *testModuleDest) Start(c *context.Context) {
|
func (m *testModuleDest) Start() {
|
||||||
m.context = c
|
message, err := beehiveContext.Receive(DestinationModule)
|
||||||
message, err := c.Receive(DestinationModule)
|
|
||||||
fmt.Printf("destination module receive message:%v error:%v\n", message, err)
|
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)
|
fmt.Printf("destination module receive message:%v error:%v\n", message, err)
|
||||||
resp := message.NewRespByMessage(&message, "fine")
|
resp := message.NewRespByMessage(&message, "fine")
|
||||||
if message.IsSync() {
|
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)
|
fmt.Printf("destination module receive message:%v error:%v\n", message, err)
|
||||||
if message.IsSync() {
|
if message.IsSync() {
|
||||||
resp = message.NewRespByMessage(&message, "fine")
|
resp = message.NewRespByMessage(&message, "fine")
|
||||||
c.SendResp(*resp)
|
beehiveContext.SendResp(*resp)
|
||||||
}
|
}
|
||||||
|
|
||||||
//message, err = c.Receive(DestinationModule)
|
//message, err = c.Receive(DestinationModule)
|
||||||
|
|
@ -54,7 +56,3 @@ func (m *testModuleDest) Start(c *context.Context) {
|
||||||
// c.SendResp(*resp)
|
// c.SendResp(*resp)
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *testModuleDest) Cleanup() {
|
|
||||||
m.context.Cleanup(m.Name())
|
|
||||||
}
|
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/kubeedge/beehive/pkg/core"
|
"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
|
//Constant for test module destination group name
|
||||||
|
|
@ -13,7 +13,10 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testModuleDestGroup struct {
|
type testModuleDestGroup struct {
|
||||||
context *context.Context
|
}
|
||||||
|
|
||||||
|
func (m *testModuleDestGroup) Enable() bool {
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
@ -28,16 +31,11 @@ func (*testModuleDestGroup) Group() string {
|
||||||
return DestinationGroup
|
return DestinationGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *testModuleDestGroup) Start(c *context.Context) {
|
func (m *testModuleDestGroup) Start() {
|
||||||
m.context = c
|
message, err := beehiveContext.Receive(DestinationGroupModule)
|
||||||
message, err := c.Receive(DestinationGroupModule)
|
|
||||||
fmt.Printf("destination group module receive message:%v error:%v\n", message, err)
|
fmt.Printf("destination group module receive message:%v error:%v\n", message, err)
|
||||||
if message.IsSync() {
|
if message.IsSync() {
|
||||||
resp := message.NewRespByMessage(&message, "10 years old")
|
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"
|
"time"
|
||||||
|
|
||||||
"github.com/kubeedge/beehive/pkg/core"
|
"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"
|
"github.com/kubeedge/beehive/pkg/core/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -16,13 +16,16 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
type testModuleSource struct {
|
type testModuleSource struct {
|
||||||
context *context.Context
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
core.Register(&testModuleSource{})
|
core.Register(&testModuleSource{})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *testModuleSource) Enable() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func (*testModuleSource) Name() string {
|
func (*testModuleSource) Name() string {
|
||||||
return SourceModule
|
return SourceModule
|
||||||
}
|
}
|
||||||
|
|
@ -31,15 +34,14 @@ func (*testModuleSource) Group() string {
|
||||||
return SourceGroup
|
return SourceGroup
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *testModuleSource) Start(c *context.Context) {
|
func (m *testModuleSource) Start() {
|
||||||
m.context = c
|
|
||||||
message := model.NewMessage("").SetRoute(SourceModule, "").
|
message := model.NewMessage("").SetRoute(SourceModule, "").
|
||||||
SetResourceOperation("test", model.InsertOperation).FillBody("hello")
|
SetResourceOperation("test", model.InsertOperation).FillBody("hello")
|
||||||
c.Send(DestinationModule, *message)
|
beehiveContext.Send(DestinationModule, *message)
|
||||||
|
|
||||||
message = model.NewMessage("").SetRoute(SourceModule, "").
|
message = model.NewMessage("").SetRoute(SourceModule, "").
|
||||||
SetResourceOperation("test", model.UpdateOperation).FillBody("how are you")
|
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 {
|
if err != nil {
|
||||||
fmt.Printf("failed to send sync message, error:%v\n", err)
|
fmt.Printf("failed to send sync message, error:%v\n", err)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -48,9 +50,5 @@ func (m *testModuleSource) Start(c *context.Context) {
|
||||||
|
|
||||||
message = model.NewMessage("").SetRoute(SourceModule, DestinationGroup).
|
message = model.NewMessage("").SetRoute(SourceModule, DestinationGroup).
|
||||||
SetResourceOperation("test", model.DeleteOperation).FillBody("fine")
|
SetResourceOperation("test", model.DeleteOperation).FillBody("fine")
|
||||||
c.SendToGroup(DestinationGroup, *message)
|
beehiveContext.SendToGroup(DestinationGroup, *message)
|
||||||
}
|
|
||||||
|
|
||||||
func (m *testModuleSource) Cleanup() {
|
|
||||||
m.context.Cleanup(m.Name())
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue