diff --git a/.gitignore b/.gitignore index 00dfa3bc67467b7267c2815c8f6645be0759b6bf..159fd2d040dbb2bc31b032e93a50d5089aa2212f 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ artifacts/ # containerlab .gosdn.clab.yml clab-gosdn_csbi_arista_base/ +.gosdn.clab.yml.bak # non vimmers .vscode/ diff --git a/api/go/gosdn/rbac/role.pb.go b/api/go/gosdn/rbac/role.pb.go index e3dfae038facef552767a4dfb61c881d77077c54..c4212deaae5a8bc582972d2bb6bf556f3bfd73b9 100644 --- a/api/go/gosdn/rbac/role.pb.go +++ b/api/go/gosdn/rbac/role.pb.go @@ -213,6 +213,7 @@ type GetRoleRequest struct { Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` RoleName string `protobuf:"bytes,2,opt,name=role_name,json=roleName,proto3" json:"role_name,omitempty"` + Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` } func (x *GetRoleRequest) Reset() { @@ -261,6 +262,13 @@ func (x *GetRoleRequest) GetRoleName() string { return "" } +func (x *GetRoleRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + type GetRoleResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -808,12 +816,13 @@ var file_gosdn_rbac_role_proto_rawDesc = []byte{ 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x72, 0x62, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, - 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x4b, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x6f, + 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x22, 0x5b, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x1b, 0x0a, 0x09, 0x72, 0x6f, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x72, 0x6f, 0x6c, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x02, 0x69, 0x64, 0x22, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, diff --git a/api/go/gosdn/rbac/user.pb.go b/api/go/gosdn/rbac/user.pb.go index f999c7ddee55ebdc9a4de8f525a42ab5ea03669c..ef2f31b24e1600f2bb8f43c9ffd20442610dc423 100644 --- a/api/go/gosdn/rbac/user.pb.go +++ b/api/go/gosdn/rbac/user.pb.go @@ -221,6 +221,7 @@ type GetUserRequest struct { Timestamp int64 `protobuf:"varint,1,opt,name=timestamp,proto3" json:"timestamp,omitempty"` Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` } func (x *GetUserRequest) Reset() { @@ -269,6 +270,13 @@ func (x *GetUserRequest) GetName() string { return "" } +func (x *GetUserRequest) GetId() string { + if x != nil { + return x.Id + } + return "" +} + type GetUserResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -703,11 +711,12 @@ var file_gosdn_rbac_user_proto_rawDesc = []byte{ 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x12, 0x2e, 0x67, 0x6f, 0x73, 0x64, 0x6e, 0x2e, 0x72, 0x62, 0x61, 0x63, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, - 0x73, 0x22, 0x42, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, + 0x73, 0x22, 0x52, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, + 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x81, 0x01, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x12, 0x2a, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, diff --git a/api/openapiv2/gosdn_northbound.swagger.json b/api/openapiv2/gosdn_northbound.swagger.json index 4cd6a8a702f29bb36f5dbbcddcf980b41106a996..4699ec6d2ae28af477e34ddd32223b7678b7405f 100644 --- a/api/openapiv2/gosdn_northbound.swagger.json +++ b/api/openapiv2/gosdn_northbound.swagger.json @@ -994,6 +994,12 @@ "in": "query", "required": false, "type": "string" + }, + { + "name": "id", + "in": "query", + "required": false, + "type": "string" } ], "tags": [ @@ -1237,6 +1243,12 @@ "in": "query", "required": false, "type": "string" + }, + { + "name": "id", + "in": "query", + "required": false, + "type": "string" } ], "tags": [ diff --git a/api/proto/buf.lock b/api/proto/buf.lock index 609ccb0d975e8a80f3bd3e50c1df57a05dfc26b0..5075172a4997e3b8a056da53b859e06e8fdd9ad1 100644 --- a/api/proto/buf.lock +++ b/api/proto/buf.lock @@ -4,7 +4,7 @@ deps: - remote: buf.build owner: googleapis repository: googleapis - commit: 7529bb85c9cd4c489dba05e04769c547 + commit: 868034942d3c4d24b722f6a834dd7bb2 - remote: buf.build owner: grpc-ecosystem repository: grpc-gateway diff --git a/api/proto/gosdn/rbac/role.proto b/api/proto/gosdn/rbac/role.proto index 044fbef8a5f3edd2ba63023554f2d148aa3f6a87..29edc1cd4f9bd7f777eec1bf14ceace0eec03c21 100644 --- a/api/proto/gosdn/rbac/role.proto +++ b/api/proto/gosdn/rbac/role.proto @@ -84,6 +84,7 @@ message CreateRolesResponse { message GetRoleRequest { int64 timestamp = 1; string role_name = 2; + string id = 3; } message GetRoleResponse { diff --git a/api/proto/gosdn/rbac/user.proto b/api/proto/gosdn/rbac/user.proto index 3ad7f88de24cb5a0adbc5504c335c9d0f215f6e6..8de04465cc4add2b4223930157118d5e6858cab1 100644 --- a/api/proto/gosdn/rbac/user.proto +++ b/api/proto/gosdn/rbac/user.proto @@ -78,6 +78,7 @@ message CreateUsersResponse { message GetUserRequest { int64 timestamp = 1; string name = 2; + string id = 3; } message GetUserResponse { diff --git a/cli/cmd/userGet.go b/cli/cmd/userGet.go index b5f1a0bd9ba21765a81df889fabc182029126615..1a487a3a7f02a2aa275f479ca064210ee89fbe38 100644 --- a/cli/cmd/userGet.go +++ b/cli/cmd/userGet.go @@ -33,6 +33,7 @@ package cmd import ( "code.fbi.h-da.de/danet/gosdn/controller/api" + "github.com/google/uuid" log "github.com/sirupsen/logrus" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -45,7 +46,12 @@ var userGetCmd = &cobra.Command{ Long: `Requests one user using the provided name to search for it in the stored users.`, RunE: func(cmd *cobra.Command, args []string) error { - resp, err := api.GetUser(createContextWithAuthorization(), viper.GetString("controllerAPIEndpoint"), nbUserName) + resp, err := api.GetUser( + createContextWithAuthorization(), + viper.GetString("controllerAPIEndpoint"), + nbUserName, + uuid.Nil, + ) if err != nil { return err } diff --git a/controller/api/role.go b/controller/api/role.go index b9d6bcc5c66186db408cf6c974a1bfab101d0769..cef73197238fa77d13a81d9a561a9ea3ea20ee2b 100644 --- a/controller/api/role.go +++ b/controller/api/role.go @@ -6,6 +6,7 @@ import ( apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac" nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/client" + "github.com/google/uuid" ) // CreateRoles creates roles with provided data @@ -24,7 +25,7 @@ func CreateRoles(ctx context.Context, addr string, roles []*apb.Role) (*apb.Crea } // GetRole returns one requested role found by name -func GetRole(ctx context.Context, addr, name string) (*apb.GetRoleResponse, error) { +func GetRole(ctx context.Context, addr, name string, uuid uuid.UUID) (*apb.GetRoleResponse, error) { roleClient, err := nbi.RoleClient(addr, dialOptions...) if err != nil { return nil, err @@ -33,6 +34,7 @@ func GetRole(ctx context.Context, addr, name string) (*apb.GetRoleResponse, erro r := &apb.GetRoleRequest{ Timestamp: time.Now().UnixNano(), RoleName: name, + Id: uuid.String(), } return roleClient.GetRole(ctx, r) diff --git a/controller/api/role_test.go b/controller/api/role_test.go index c98b0d277579b2376b86aa5b03d7e2e051b09a50..785ae3128e3c36d770bd67208492d27cb8aaccb4 100644 --- a/controller/api/role_test.go +++ b/controller/api/role_test.go @@ -61,6 +61,7 @@ func TestGetRole(t *testing.T) { ctx context.Context addr string name string + id uuid.UUID } tests := []struct { name string @@ -74,6 +75,7 @@ func TestGetRole(t *testing.T) { ctx: context.TODO(), addr: testAPIEndpoint, name: "adminTestRole", + id: uuid.Nil, }, want: &apb.GetRoleResponse{ Status: apb.Status_STATUS_OK, @@ -90,6 +92,7 @@ func TestGetRole(t *testing.T) { ctx: context.TODO(), addr: testAPIEndpoint, name: "not role", + id: uuid.Nil, }, want: nil, wantErr: true, @@ -97,7 +100,7 @@ func TestGetRole(t *testing.T) { } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := GetRole(tt.args.ctx, tt.args.addr, tt.args.name) + got, err := GetRole(tt.args.ctx, tt.args.addr, tt.args.name, tt.args.id) if (err != nil) != tt.wantErr { t.Errorf("GetRole() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/controller/api/user.go b/controller/api/user.go index 31d6828607c38c994dabde2e12fd2d4e7e9bfb54..f5f49ea4d6fc44a8dea527cc72db2556163b03d5 100644 --- a/controller/api/user.go +++ b/controller/api/user.go @@ -6,6 +6,8 @@ import ( apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac" nbi "code.fbi.h-da.de/danet/gosdn/controller/northbound/client" + + "github.com/google/uuid" ) // CreateUsers creates users with provided data @@ -24,7 +26,7 @@ func CreateUsers(ctx context.Context, addr string, users []*apb.User) (*apb.Crea } //GetUser returns one requested user found by name -func GetUser(ctx context.Context, addr, name string) (*apb.GetUserResponse, error) { +func GetUser(ctx context.Context, addr, name string, uuid uuid.UUID) (*apb.GetUserResponse, error) { userClient, err := nbi.UserClient(addr, dialOptions...) if err != nil { return nil, err @@ -33,6 +35,7 @@ func GetUser(ctx context.Context, addr, name string) (*apb.GetUserResponse, erro r := &apb.GetUserRequest{ Timestamp: time.Now().UnixNano(), Name: name, + Id: uuid.String(), } return userClient.GetUser(ctx, r) diff --git a/controller/api/user_test.go b/controller/api/user_test.go index ab8cf858ec7e2fa7c4bf651b01da4517afb2c4f9..afa2f6dc6aa0f3bc9edbde0030dab5f20d74b31d 100644 --- a/controller/api/user_test.go +++ b/controller/api/user_test.go @@ -65,6 +65,7 @@ func TestGetUser(t *testing.T) { ctx context.Context addr string name string + id uuid.UUID } tests := []struct { name string @@ -78,6 +79,7 @@ func TestGetUser(t *testing.T) { ctx: context.TODO(), addr: testAPIEndpoint, name: "testAdmin", + id: uuid.Nil, }, want: &apb.GetUserResponse{ Status: apb.Status_STATUS_OK, @@ -94,6 +96,7 @@ func TestGetUser(t *testing.T) { ctx: context.TODO(), addr: testAPIEndpoint, name: "foos", + id: uuid.Nil, }, want: nil, wantErr: true, @@ -102,7 +105,7 @@ func TestGetUser(t *testing.T) { for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { - got, err := GetUser(tt.args.ctx, tt.args.addr, tt.args.name) + got, err := GetUser(tt.args.ctx, tt.args.addr, tt.args.name, tt.args.id) if (err != nil) != tt.wantErr { t.Errorf("GetUser() error = %v, wantErr %v", err, tt.wantErr) return diff --git a/controller/configs/containerlab-gosdn.toml.example b/controller/configs/containerlab-gosdn.toml.example index 3fffe360b55fc3f9d7909890e1a2bd844d05dc35..6f52b353c6594ed1e91f06d9b769e974a857841e 100644 --- a/controller/configs/containerlab-gosdn.toml.example +++ b/controller/configs/containerlab-gosdn.toml.example @@ -15,5 +15,5 @@ filesystemPathToStores = "stores" amqpPrefix = "amqp://" amqpUser = "guest" amqpPassword = "guest" -amqpHost = "localhost" +amqpHost = "rabbitmq" amqpPort = "5672" diff --git a/controller/event/event.go b/controller/event/event.go index 68e8fb1c525fbd6318b3a4af5cd4541fce0cad83..4f9aaef8db2bc5a702fac335c62d4bb44030acd4 100644 --- a/controller/event/event.go +++ b/controller/event/event.go @@ -9,14 +9,16 @@ type Event struct { Type string `json:"type,omitempty"` } -// TypeAdd is an add event. -const TypeAdd = "add" +const ( + // TypeAdd is an add event. + TypeAdd = "add" -// TypeUpdate is an update event. -const TypeUpdate = "update" + // TypeUpdate is an update event. + TypeUpdate = "update" -// TypeDelete is a delete event. -const TypeDelete = "delete" + // TypeDelete is a delete event. + TypeDelete = "delete" +) // NewAddEvent creates a new add event. func NewAddEvent(entityID uuid.UUID) Event { diff --git a/controller/eventService/utils.go b/controller/eventService/utils.go index 7a06a8b3afd93592b0518d9011e08c71fa0dc622..891142fef2e7bf809daca4885fb58921d4e4f9e3 100644 --- a/controller/eventService/utils.go +++ b/controller/eventService/utils.go @@ -11,12 +11,6 @@ func amqpURIBuilder(prefix, user, pass, host, port string) string { return fmt.Sprintf("%s%s:%s@%s:%s/", prefix, user, pass, host, port) } -// Service is the event service -type Service interface { - PublishEvent(topic string, event event.Event) error - CloseConnection() -} - // MockEventService is used to setup a connection to a broker and publish events to topics. type MockEventService struct { Queue map[string][]event.Event diff --git a/controller/northbound/server/role.go b/controller/northbound/server/role.go index 4cb05b6e16e885082f2e6a1b88466f000f2a7961..4141c6250d51b81984b652430e852f6f0a3a4eb4 100644 --- a/controller/northbound/server/role.go +++ b/controller/northbound/server/role.go @@ -2,6 +2,7 @@ package server import ( "context" + "fmt" "time" apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac" @@ -59,7 +60,12 @@ func (r Role) GetRole(ctx context.Context, request *apb.GetRoleRequest) (*apb.Ge start := metrics.StartHook(labels, grpcRequestsTotal) defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds) - roleData, err := r.roleService.Get(store.Query{Name: request.RoleName}) + roleID, err := uuid.Parse(request.Id) + if err != nil { + return nil, fmt.Errorf("could not parse role uuid") + } + + roleData, err := r.roleService.Get(store.Query{Name: request.RoleName, ID: roleID}) if err != nil { return nil, err } diff --git a/controller/northbound/server/role_test.go b/controller/northbound/server/role_test.go index 7f99f92f9c8611975787d4e39223ea0cda0c9402..b9d0a62bbd992f585e08197930c61573eb440a0f 100644 --- a/controller/northbound/server/role_test.go +++ b/controller/northbound/server/role_test.go @@ -93,6 +93,7 @@ func TestRole_GetRole(t *testing.T) { ctx: context.TODO(), request: &apb.GetRoleRequest{ RoleName: "adminTestRole", + Id: uuid.Nil.String(), }, }, want: &apb.GetRoleResponse{ @@ -110,6 +111,7 @@ func TestRole_GetRole(t *testing.T) { ctx: context.TODO(), request: &apb.GetRoleRequest{ RoleName: "not role", + Id: uuid.Nil.String(), }, }, want: nil, diff --git a/controller/northbound/server/user.go b/controller/northbound/server/user.go index 23885863725164f7643f933203c60fdf3c57438d..2e0bfed22e52e23552021744a3421268ea3b1e00 100644 --- a/controller/northbound/server/user.go +++ b/controller/northbound/server/user.go @@ -3,6 +3,7 @@ package server import ( "context" "encoding/base64" + "fmt" "time" apb "code.fbi.h-da.de/danet/gosdn/api/go/gosdn/rbac" @@ -82,7 +83,12 @@ func (u User) GetUser(ctx context.Context, request *apb.GetUserRequest) (*apb.Ge start := metrics.StartHook(labels, grpcRequestsTotal) defer metrics.FinishHook(labels, start, grpcRequestDurationSecondsTotal, grpcRequestDurationSeconds) - userData, err := u.userService.Get(store.Query{Name: request.Name}) + userID, err := uuid.Parse(request.Id) + if err != nil { + return nil, fmt.Errorf("could not parse user uuid") + } + + userData, err := u.userService.Get(store.Query{Name: request.Name, ID: userID}) if err != nil { return nil, err } diff --git a/controller/northbound/server/user_test.go b/controller/northbound/server/user_test.go index c85639b7d1fa161a5ecca5bc3955c83bd541c400..83a9c081390a16e961aa7c6b7185f4e0c9de07bd 100644 --- a/controller/northbound/server/user_test.go +++ b/controller/northbound/server/user_test.go @@ -95,6 +95,7 @@ func TestUser_GetUser(t *testing.T) { ctx: context.TODO(), request: &apb.GetUserRequest{ Name: "testAdmin", + Id: uuid.Nil.String(), }, }, want: &apb.GetUserResponse{Status: apb.Status_STATUS_OK, @@ -108,6 +109,7 @@ func TestUser_GetUser(t *testing.T) { ctx: context.TODO(), request: &apb.GetUserRequest{ Name: "nope", + Id: uuid.Nil.String(), }, }, want: nil, diff --git a/controller/nucleus/device_test.go b/controller/nucleus/device_test.go index 885f21ba37744e69997de74881202c64d03c925b..2ce8863613908f4ee9f9760d7e17e7a6b4f3b097 100644 --- a/controller/nucleus/device_test.go +++ b/controller/nucleus/device_test.go @@ -98,7 +98,9 @@ func TestNewDevice(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() resp, err := NewDevice(tt.args.name, uuid.Nil, tt.args.opts, tt.args.sbi) if (err != nil) != tt.wantErr { t.Errorf("NewDevice() error = %v, wantErr %v", err, tt.wantErr) diff --git a/controller/nucleus/principalNetworkDomain_test.go b/controller/nucleus/principalNetworkDomain_test.go index 0cd9c3b14a2eb3e9089cf672d53300d0dcd3e0d1..99e78bf61bac5edc14d4c0da1c15b18d09d70cbd 100644 --- a/controller/nucleus/principalNetworkDomain_test.go +++ b/controller/nucleus/principalNetworkDomain_test.go @@ -325,7 +325,9 @@ func Test_pndImplementation_RemoveDevice(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() pnd := newPnd() sbi, err := NewSBI(spb.Type_TYPE_OPENCONFIG) if err != nil { @@ -366,7 +368,9 @@ func Test_pndImplementation_RemoveSbi(t *testing.T) { {name: "fails", args: args{id: uuid.New()}, wantErr: true}, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() eventService := eventservice.NewMockEventService() sbiStore := NewMemorySbiStore() deviceStore := NewMemoryDeviceStore() @@ -432,7 +436,9 @@ func Test_pndImplementation_RemoveSbiWithAssociatedDevices(t *testing.T) { {name: "exclusively remove associated devices", args: args{id: defaultSbiID}, wantErr: false}, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() eventService := eventservice.NewMockEventService() sbiStore := NewMemorySbiStore() deviceStore := NewMemoryDeviceStore() @@ -535,7 +541,9 @@ func Test_pndImplementation_Request(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() sbiService := NewGenericService[southbound.SouthboundInterface]() deviceService := NewGenericService[device.Device]() @@ -619,7 +627,9 @@ func Test_pndImplementation_RequestAll(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() sbiService := NewGenericService[southbound.SouthboundInterface]() deviceService := NewGenericService[device.Device]() @@ -760,7 +770,9 @@ func Test_pndImplementation_ChangeOND(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() pnd := newPnd() if err := pnd.addSbi(&OpenConfig{id: defaultSbiID}); err != nil { t.Error(err) @@ -847,7 +859,9 @@ func Test_pndImplementation_GetDevice(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() foundDevice, err := pnd.GetDevice(tt.args.uuid.String()) if (err != nil) != tt.wantErr { t.Errorf("GetDevice() error = %v, wantErr %v", err, tt.wantErr) @@ -916,7 +930,9 @@ func Test_pndImplementation_GetDeviceByName(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() foundDevice, err := pnd.GetDevice(tt.args.name) if (err != nil) != tt.wantErr { t.Errorf("GetDeviceByName() error = %v, wantErr %v", err, tt.wantErr) @@ -947,7 +963,9 @@ func Test_pndImplementation_Confirm(t *testing.T) { } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() sbiService := NewGenericService[southbound.SouthboundInterface]() deviceService := NewGenericService[device.Device]() @@ -1179,7 +1197,9 @@ func Test_pndImplementation_saveGoStructsToFile(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() err := saveStreamToFile(tt.args.client, util.GoStructName, tt.args.id) if (err != nil) != tt.wantErr { t.Errorf("saveGoStructsToFile() error = %v, wantErr %v", err, tt.wantErr) diff --git a/controller/test/integration/nucleusIntegration_test.go b/controller/test/integration/nucleusIntegration_test.go index b85058a46a6c8b4a1d691bb8633db8f63aff2f94..36b977a62b8a8db6ea6875f958ee4ce7ae8b7b2f 100644 --- a/controller/test/integration/nucleusIntegration_test.go +++ b/controller/test/integration/nucleusIntegration_test.go @@ -225,7 +225,9 @@ func TestGnmi_SetValidIntegration(t *testing.T) { }, } for _, tt := range tests { + tt := tt t.Run(tt.name, func(t *testing.T) { + t.Parallel() cuid, err := pnd.ChangeOND(device.ID(), tt.apiOp, tt.path, tt.value) if err != nil { t.Error(err) diff --git a/gosdn.clab.yaml b/gosdn.clab.yaml index f6acd6185f992622d62872d1f8ca59188c61afd1..69135e79707cb2bfc7f349d403a05406a1fbb15c 100644 --- a/gosdn.clab.yaml +++ b/gosdn.clab.yaml @@ -14,20 +14,24 @@ topology: kind: ceos mgmt_ipv4: 172.100.0.11 group: spine + ceos1a: kind: ceos mgmt_ipv4: 172.100.0.12 group: spine + centos1: kind: linux image: centos:8 mgmt_ipv4: 172.100.0.3 group: server + centos2: kind: linux image: centos:8 mgmt_ipv4: 172.100.0.4 group: server + gosdn: kind: linux image: gosdn @@ -38,12 +42,14 @@ topology: cmd: --config /gosdn/configs/containerlab-gosdn.toml mgmt_ipv4: 172.100.0.5 + gnmi-target: kind: linux image: gnmi-target ports: - 7030:7030 mgmt_ipv4: 172.100.0.6 + csbi-orchestrator: kind: linux image: orchestrator @@ -55,6 +61,7 @@ topology: - ./csbi/.csbi.yaml:/etc/.csbi.yml cmd: --log-level trace --config /etc/.csbi.yml mgmt_ipv4: 172.100.0.7 + grafana: kind: linux image: grafana/grafana:8.1.2 @@ -63,6 +70,7 @@ topology: ports: - 3000:3000 mgmt_ipv4: 172.100.0.8 + prometheus: kind: linux image: prom/prometheus:v2.29.1 @@ -72,6 +80,7 @@ topology: - ./csbi/prometheus:/etc/prometheus cmd: --web.enable-lifecycle --config.file=/etc/prometheus/prometheus.yml mgmt_ipv4: 172.100.0.9 + mongodb: kind: linux image: mongo:5 @@ -81,6 +90,7 @@ topology: MONGO_INITDB_ROOT_USERNAME: root MONGO_INITDB_ROOT_PASSWORD: example mgmt_ipv4: 172.100.0.13 + mongodb-express: kind: linux image: mongo-express:0.54.0 @@ -92,7 +102,16 @@ topology: ME_CONFIG_MONGODB_SERVER: mongodb mgmt_ipv4: 172.100.0.14 + rabbitmq: + kind: linux + image: rabbitmq:3-management + ports: + - 127.0.0.1:5672:5672 + - 127.0.0.1:15672:15672 + mgmt_ipv4: 172.100.0.15 + links: - endpoints: ["ceos0:eth1","ceos1a:eth1"] - endpoints: ["ceos0:eth2","centos1:eth1"] - endpoints: ["ceos1a:eth2","centos2:eth1"] +