diff --git a/pkg/common/util/file_util.go b/pkg/common/util/file_util.go deleted file mode 100644 index 95302ba..0000000 --- a/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/test/cmd/conf/modules.yaml b/test/cmd/conf/modules.yaml deleted file mode 100644 index 9306e9d..0000000 --- a/test/cmd/conf/modules.yaml +++ /dev/null @@ -1,2 +0,0 @@ -modules: - enabled: [destinationmodule, sourcemodule, destinationgroupmodule] diff --git a/test/conf/modules.yaml b/test/conf/modules.yaml deleted file mode 100644 index e92e63a..0000000 --- a/test/conf/modules.yaml +++ /dev/null @@ -1,2 +0,0 @@ -modules: - enabled: [destination_module, sourcemodule] diff --git a/test/modules/test_destination.go b/test/modules/test_destination.go index fb1ada8..2576342 100644 --- a/test/modules/test_destination.go +++ b/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/test/modules/test_destination_group.go b/test/modules/test_destination_group.go index b8bcd3f..df20d90 100644 --- a/test/modules/test_destination_group.go +++ b/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/test/modules/test_source.go b/test/modules/test_source.go index 50c6e48..768ab48 100644 --- a/test/modules/test_source.go +++ b/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) }