Skip to content
Snippets Groups Projects
Verified Commit 47cb2d63 authored by André Sterba's avatar André Sterba
Browse files

Merge branch 'master' into validation-tests

parents 28b26430 5f2b5aff
No related branches found
No related tags found
3 merge requests!573Add validation tests for topology,!572Add validation tests for user entity,!567Add test for role api inputs
Pipeline #164184 passed
build-mkdocs: build-mkdocs:
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:3.11.5-slim-bullseye image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:3.11.5-slim-bookworm
stage: build stage: build
before_script: before_script:
- pip install mkdocs-material - pip install mkdocs-material
...@@ -13,7 +13,7 @@ build-mkdocs: ...@@ -13,7 +13,7 @@ build-mkdocs:
- if: $CI_COMMIT_REF_PROTECTED == "true" - if: $CI_COMMIT_REF_PROTECTED == "true"
.pages-options: &pages-options .pages-options: &pages-options
image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:3.11.5-slim-bullseye image: ${CI_DEPENDENCY_PROXY_GROUP_IMAGE_PREFIX}/python:3.11.5-slim-bookworm
stage: deploy stage: deploy
script: script:
- mv mkdocs-built public - mv mkdocs-built public
......
...@@ -12,6 +12,8 @@ const ( ...@@ -12,6 +12,8 @@ const (
Update Update
// Delete is a delete event. // Delete is a delete event.
Delete Delete
// Subscribe is a gNMI subscribe event.
Subscribe
) )
// String implements the stringer interface for types. // String implements the stringer interface for types.
...@@ -23,6 +25,8 @@ func (t Type) String() string { ...@@ -23,6 +25,8 @@ func (t Type) String() string {
return "update" return "update"
case Delete: case Delete:
return "delete" return "delete"
case Subscribe:
return "subscribe"
} }
return "unknown" return "unknown"
...@@ -30,9 +34,10 @@ func (t Type) String() string { ...@@ -30,9 +34,10 @@ func (t Type) String() string {
var ( var (
typeLookup = map[string]Type{ typeLookup = map[string]Type{
"add": Add, "add": Add,
"update": Update, "update": Update,
"delete": Delete, "delete": Delete,
"subscribe": Subscribe,
} }
) )
......
...@@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.21 ...@@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY=code.fbi.h-da.de:443/danet/dependency_proxy/containers ARG $GITLAB_PROXY=code.fbi.h-da.de:443/danet/dependency_proxy/containers
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bullseye AS builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm AS builder
WORKDIR /gosdn WORKDIR /gosdn
......
...@@ -2,14 +2,14 @@ ARG GOLANG_VERSION=1.21 ...@@ -2,14 +2,14 @@ ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY ARG $GITLAB_PROXY
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bullseye as builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder
WORKDIR /gosdn/ WORKDIR /gosdn/
COPY . . COPY . .
RUN --mount=type=cache,target=/root/go/pkg/mod \ RUN --mount=type=cache,target=/root/go/pkg/mod \
--mount=type=cache,target=/root/.cache/go-build \ --mount=type=cache,target=/root/.cache/go-build \
make build-gosdn make build-gosdn
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bullseye FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm
WORKDIR /app/ WORKDIR /app/
COPY --from=builder /gosdn/controller/configs/development-gosdn.toml.example ./configs/development-gosdn.toml COPY --from=builder /gosdn/controller/configs/development-gosdn.toml.example ./configs/development-gosdn.toml
COPY --from=builder /gosdn/controller/configs/containerlab-gosdn.toml.example ./configs/containerlab-gosdn.toml COPY --from=builder /gosdn/controller/configs/containerlab-gosdn.toml.example ./configs/containerlab-gosdn.toml
......
...@@ -19,6 +19,9 @@ const ( ...@@ -19,6 +19,9 @@ const (
// TypeDelete is a delete event. // TypeDelete is a delete event.
TypeDelete = "delete" TypeDelete = "delete"
// TypeSubscribe 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()
......
...@@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.21 ...@@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY ARG $GITLAB_PROXY
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bullseye as builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder
WORKDIR /plugin-registry/ WORKDIR /plugin-registry/
RUN apt-get update RUN apt-get update
RUN apt-get -y install --no-install-recommends zip RUN apt-get -y install --no-install-recommends zip
......
...@@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.21 ...@@ -2,7 +2,7 @@ ARG GOLANG_VERSION=1.21
ARG BUILDARGS ARG BUILDARGS
ARG $GITLAB_PROXY ARG $GITLAB_PROXY
FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bullseye as builder FROM ${GITLAB_PROXY}golang:$GOLANG_VERSION-bookworm as builder
WORKDIR /plugin-registry/ WORKDIR /plugin-registry/
RUN apt-get update RUN apt-get update
RUN apt-get -y install --no-install-recommends zip RUN apt-get -y install --no-install-recommends zip
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment