diff --git a/integration-tests/application_tests/appUtility_test.go b/integration-tests/application_tests/appUtility_test.go index a9cd6a726c4fbe7f3b5e9f5ac330bd0aa25f76c5..4539072576150b1742635ed42307cfa17cfa0da2 100644 --- a/integration-tests/application_tests/appUtility_test.go +++ b/integration-tests/application_tests/appUtility_test.go @@ -17,10 +17,13 @@ const localhost = "127.0.0.1" // Application is an example for a sdn application. type Application struct { - eventService event.ServiceInterface - stopChannel chan os.Signal - grpcClientConn *grpc.ClientConn - eventChannel chan event.Event + eventService event.ServiceInterface + stopChannel chan os.Signal + grpcClientConn *grpc.ClientConn + addEventChannel chan event.Event + updateEventChannel chan event.Event + deleteEventChannel chan event.Event + subscribeEventChannel chan event.Event } func NewApplication(ctx context.Context, grpcClientConn *grpc.ClientConn, controllerAddress string, topics []event.Topic, rabbitMQAddress string) *Application { @@ -44,10 +47,13 @@ func NewApplication(ctx context.Context, grpcClientConn *grpc.ClientConn, contro } return &Application{ - eventService: eventService, - stopChannel: make(chan os.Signal, 1), - grpcClientConn: grpcClientConn, - eventChannel: make(chan event.Event, 1), + eventService: eventService, + stopChannel: make(chan os.Signal, 1), + grpcClientConn: grpcClientConn, + addEventChannel: make(chan event.Event, 1), + updateEventChannel: make(chan event.Event, 1), + deleteEventChannel: make(chan event.Event, 1), + subscribeEventChannel: make(chan event.Event, 1), } } @@ -75,7 +81,22 @@ func (a *Application) Run(eventTypeCallbackTuples []event.TypeToCallbackTuple) { <-forever } -func (a *Application) callback(event *event.Event) { +func (a *Application) addCallback(event *event.Event) { logrus.Infof("Incoming Event: EntityID: %v, ID: %v, PathsAndValues: %v, Type: %v", event.EntityID, event.ID, event.PathsAndValuesMap, event.Type) - a.eventChannel <- *event + a.addEventChannel <- *event +} + +func (a *Application) updateCallback(event *event.Event) { + logrus.Infof("Incoming Event: EntityID: %v, ID: %v, PathsAndValues: %v, Type: %v", event.EntityID, event.ID, event.PathsAndValuesMap, event.Type) + a.updateEventChannel <- *event +} + +func (a *Application) deleteCallback(event *event.Event) { + logrus.Infof("Incoming Event: EntityID: %v, ID: %v, PathsAndValues: %v, Type: %v", event.EntityID, event.ID, event.PathsAndValuesMap, event.Type) + a.deleteEventChannel <- *event +} + +func (a *Application) subscribeCallback(event *event.Event) { + logrus.Infof("Incoming Event: EntityID: %v, ID: %v, PathsAndValues: %v, Type: %v", event.EntityID, event.ID, event.PathsAndValuesMap, event.Type) + a.subscribeEventChannel <- *event } diff --git a/integration-tests/application_tests/application_test.go b/integration-tests/application_tests/application_test.go index 6431a79d493a4bde4568e0c0f17276191d921538..8e22c1caa0dbfdb6c8225eb0c4aa3c6e360e2893 100644 --- a/integration-tests/application_tests/application_test.go +++ b/integration-tests/application_tests/application_test.go @@ -74,19 +74,19 @@ func TestMain(m *testing.M) { eventTypeCallbackTuples := []event.TypeToCallbackTuple{ { Type: event.Add, - Callback: application.callback, + Callback: application.addCallback, }, { Type: event.Update, - Callback: application.callback, + Callback: application.updateCallback, }, { Type: event.Delete, - Callback: application.callback, + Callback: application.deleteCallback, }, { Type: event.Subscribe, - Callback: application.callback, + Callback: application.subscribeCallback, }, } go application.Run(eventTypeCallbackTuples) @@ -97,9 +97,9 @@ func TestMain(m *testing.M) { // a user and updates it because of the login. After then only logins are done, no user creations. // This means that this will block after trying once, because the two attempts to read from eventChannel. - _ = <-application.eventChannel - _ = <-application.eventChannel - _ = <-application.eventChannel + _ = <-application.addEventChannel + _ = <-application.addEventChannel + _ = <-application.updateEventChannel m.Run() } @@ -142,14 +142,14 @@ func TestNetworkElementAddAndSubscribeEvent(t *testing.T) { } // check if events are available and correct type and content - addEvent := <-application.eventChannel + addEvent := <-application.addEventChannel assert.Equal(t, event.Add.String(), addEvent.Type) assert.Equal(t, mneID, addEvent.EntityID.String()) - subscribeEvent := <-application.eventChannel + subscribeEvent := <-application.subscribeEventChannel assert.Equal(t, event.Subscribe.String(), subscribeEvent.Type) - subscribeEvent = <-application.eventChannel + subscribeEvent = <-application.subscribeEventChannel assert.Equal(t, event.Subscribe.String(), subscribeEvent.Type) } @@ -192,7 +192,7 @@ func TestUserAddAndUpdateEvent(t *testing.T) { } // check if event is available and correct type - addEvent := <-application.eventChannel + addEvent := <-application.addEventChannel assert.Equal(t, event.Add.String(), addEvent.Type) assert.Equal(t, userID, addEvent.EntityID.String()) @@ -203,7 +203,7 @@ func TestUserAddAndUpdateEvent(t *testing.T) { t.FailNow() } - updateEvent := <-application.eventChannel + updateEvent := <-application.updateEventChannel assert.Equal(t, event.Update.String(), updateEvent.Type) assert.Equal(t, userID, updateEvent.EntityID.String()) } @@ -239,7 +239,7 @@ func TestRoleAddAndDeleteEvent(t *testing.T) { t.FailNow() } - addEvent := <-application.eventChannel + addEvent := <-application.addEventChannel assert.Equal(t, event.Add.String(), addEvent.Type) assert.Equal(t, roleID, addEvent.EntityID.String()) @@ -250,7 +250,7 @@ func TestRoleAddAndDeleteEvent(t *testing.T) { t.FailNow() } - deleteEvent := <-application.eventChannel + deleteEvent := <-application.deleteEventChannel assert.Equal(t, event.Delete.String(), deleteEvent.Type) assert.Equal(t, roleID, deleteEvent.EntityID.String()) }