Skip to content
Snippets Groups Projects
Commit efd4f85c authored by Fabian Seidl's avatar Fabian Seidl
Browse files

added new event type, reverted change to update event in mne service

parent 1efc0da7
No related branches found
No related tags found
No related merge requests found
Pipeline #163895 passed
...@@ -19,6 +19,9 @@ const ( ...@@ -19,6 +19,9 @@ const (
// TypeDelete is a delete event. // TypeDelete is a delete event.
TypeDelete = "delete" TypeDelete = "delete"
// TypeSusbcribe is a gNMI subscribe event.
TypeSubscribe = "subscribe"
) )
// NewAddEvent creates a new add event. // NewAddEvent creates a new add event.
...@@ -48,12 +51,12 @@ func NewUpdateEvent(entityID uuid.UUID) Event { ...@@ -48,12 +51,12 @@ func NewUpdateEvent(entityID uuid.UUID) Event {
} }
} }
// NewMneUpdateEvent creates a new update event for managed network elements. // NewGnmiSubscribeEvent creates a new gNMI subscribe event for managed network elements.
func NewMneUpdateEvent(entityID uuid.UUID, pathsAndValues map[string]string) Event { func NewGnmiSubscribeEvent(entityID uuid.UUID, pathsAndValues map[string]string) Event {
return Event{ return Event{
ID: uuid.New(), ID: uuid.New(),
EntityID: entityID, EntityID: entityID,
Type: TypeUpdate, Type: TypeSubscribe,
PathsAndValuesMap: pathsAndValues, PathsAndValuesMap: pathsAndValues,
} }
} }
...@@ -121,7 +121,7 @@ func TestNewUpdateEvent(t *testing.T) { ...@@ -121,7 +121,7 @@ func TestNewUpdateEvent(t *testing.T) {
} }
} }
func TestNewMneUpdateEvent(t *testing.T) { func TestNewGnmiSubscribeEvent(t *testing.T) {
type args struct { type args struct {
entityID uuid.UUID entityID uuid.UUID
pathsAndValuesMap map[string]string pathsAndValuesMap map[string]string
...@@ -132,7 +132,7 @@ func TestNewMneUpdateEvent(t *testing.T) { ...@@ -132,7 +132,7 @@ func TestNewMneUpdateEvent(t *testing.T) {
want Event want Event
}{ }{
{ {
name: "should create a new update event", name: "should create a new subscribe event",
args: args{ args: args{
entityID: getTestEntityUUID(), entityID: getTestEntityUUID(),
pathsAndValuesMap: map[string]string{"some/random/path": "val"}, pathsAndValuesMap: map[string]string{"some/random/path": "val"},
...@@ -140,25 +140,25 @@ func TestNewMneUpdateEvent(t *testing.T) { ...@@ -140,25 +140,25 @@ func TestNewMneUpdateEvent(t *testing.T) {
want: Event{ want: Event{
ID: uuid.New(), ID: uuid.New(),
EntityID: getTestEntityUUID(), EntityID: getTestEntityUUID(),
Type: TypeUpdate, Type: TypeSubscribe,
PathsAndValuesMap: map[string]string{"some/random/path": "val"}, PathsAndValuesMap: map[string]string{"some/random/path": "val"},
}, },
}, },
} }
for _, tt := range tests { for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
got := NewMneUpdateEvent(tt.args.entityID, tt.args.pathsAndValuesMap) got := NewGnmiSubscribeEvent(tt.args.entityID, tt.args.pathsAndValuesMap)
if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) { if !reflect.DeepEqual(got.EntityID, tt.want.EntityID) {
t.Errorf("NewMneUpdateEvent().EntityID = %v, want %v", got, tt.want) t.Errorf("NewGnmiSubscribeEvent().EntityID = %v, want %v", got, tt.want)
} }
if !reflect.DeepEqual(got.Type, tt.want.Type) { if !reflect.DeepEqual(got.Type, tt.want.Type) {
t.Errorf("NewMneUpdateEvent().Type = %v, want %v", got, tt.want) t.Errorf("NewGnmiSubscribeEvent().Type = %v, want %v", got, tt.want)
} }
if !reflect.DeepEqual(got.PathsAndValuesMap, tt.want.PathsAndValuesMap) { if !reflect.DeepEqual(got.PathsAndValuesMap, tt.want.PathsAndValuesMap) {
t.Errorf("NewMneUpdateEvent().PathsAndValuesMap = %v, want %v", got, tt.want) t.Errorf("NewGnmiSubscribeEvent().PathsAndValuesMap = %v, want %v", got, tt.want)
} }
}) })
} }
......
...@@ -146,7 +146,7 @@ func (s *NetworkElementService) UpdateModel(networkElementID uuid.UUID, modelAsS ...@@ -146,7 +146,7 @@ func (s *NetworkElementService) UpdateModel(networkElementID uuid.UUID, modelAsS
} }
// TODO (faseid): check if we want to add the paths with values here instead of empty map! // TODO (faseid): check if we want to add the paths with values here instead of empty map!
pubEvent := event.NewMneUpdateEvent(networkElementID, map[string]string{}) pubEvent := event.NewUpdateEvent(networkElementID)
if err := s.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil { if err := s.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil {
go func() { go func() {
s.eventService.Reconnect() s.eventService.Reconnect()
...@@ -169,7 +169,7 @@ func (s *NetworkElementService) Update(networkElementToUpdate networkelement.Net ...@@ -169,7 +169,7 @@ func (s *NetworkElementService) Update(networkElementToUpdate networkelement.Net
} }
// TODO (faseid): check if we want to add the paths with values here instead of empty map! // TODO (faseid): check if we want to add the paths with values here instead of empty map!
pubEvent := event.NewMneUpdateEvent(networkElementToUpdate.ID(), map[string]string{}) pubEvent := event.NewUpdateEvent(networkElementToUpdate.ID())
if err := s.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil { if err := s.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil {
go func() { go func() {
s.eventService.Reconnect() s.eventService.Reconnect()
......
...@@ -201,7 +201,7 @@ func (n *NetworkElementWatcher) handleSubscribeResponseUpdate(resp *gpb.Subscrib ...@@ -201,7 +201,7 @@ func (n *NetworkElementWatcher) handleSubscribeResponseUpdate(resp *gpb.Subscrib
log.Errorf("Error trying to parse uuid, could not handle subscription response: %v", err) log.Errorf("Error trying to parse uuid, could not handle subscription response: %v", err)
} }
pubEvent := event.NewMneUpdateEvent(mneID, pathsAndValues) pubEvent := event.NewGnmiSubscribeEvent(mneID, pathsAndValues)
if err := n.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil { if err := n.eventService.PublishEvent(NetworkElementEventTopic, pubEvent); err != nil {
go func() { go func() {
n.eventService.Reconnect() n.eventService.Reconnect()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment