Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into data-center-aggrregation-support
Browse files Browse the repository at this point in the history
  • Loading branch information
NickyMateev committed Apr 15, 2024
2 parents a046639 + a799c2d commit 6a8c163
Show file tree
Hide file tree
Showing 135 changed files with 2,514 additions and 778 deletions.
2 changes: 2 additions & 0 deletions chart/compass/charts/ord-service/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ spec:
value: {{ .Values.global.ordService.authTokenPath | quote }}
- name: DESTINATION_FETCHER_SKIP_SSL_VALIDATION
value: {{ .Values.global.ordService.skipSSLValidation | quote }}
- name: SPECIFICATION_PROTOCOL
value: {{ .Values.global.ordService.specification.protocol }}
livenessProbe:
httpGet:
port: {{.Values.deployment.args.containerPort }}
Expand Down
12 changes: 7 additions & 5 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -175,23 +175,23 @@ global:
name: compass-pairing-adapter
director:
dir: dev/incubator/
version: "PR-3789"
version: "PR-3801"
name: compass-director
hydrator:
dir: dev/incubator/
version: "PR-3717"
name: compass-hydrator
ias_adapter:
dir: dev/incubator/
version: "PR-3768"
version: "PR-3811"
name: compass-ias-adapter
kyma_adapter:
dir: dev/incubator/
version: "PR-3719"
name: compass-kyma-adapter
instance_creator:
dir: dev/incubator/
version: "PR-3760"
version: "PR-3792"
name: compass-instance-creator
default_tenant_mapping_handler:
dir: dev/incubator/
Expand All @@ -207,11 +207,11 @@ global:
name: compass-operations-controller
ord_service:
dir: dev/incubator/
version: "PR-128"
version: "PR-130"
name: compass-ord-service
schema_migrator:
dir: dev/incubator/
version: "PR-3763"
version: "PR-3801"
name: compass-schema-migrator
system_broker:
dir: dev/incubator/
Expand Down Expand Up @@ -1053,6 +1053,8 @@ global:
userContextHeader: "user_context"
authTokenPath: "/var/run/secrets/kubernetes.io/serviceaccount/token"
skipSSLValidation: false
specification:
protocol: "https"
ordAggregator:
port: 3000
prefix: /ord-aggregator
Expand Down
6 changes: 3 additions & 3 deletions components/director/internal/domain/formation/asa_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ func NewASAEngine(asaRepository automaticFormationAssignmentRepository, runtimeR
}

// EnsureScenarioAssigned ensures that the scenario is assigned to all the runtimes and runtimeContexts that are in the ASAs target_tenant_id
func (s *ASAEngine) EnsureScenarioAssigned(ctx context.Context, in model.AutomaticScenarioAssignment, processScenarioFunc ProcessScenarioFunc) error {
func (s *ASAEngine) EnsureScenarioAssigned(ctx context.Context, in *model.AutomaticScenarioAssignment, processScenarioFunc ProcessScenarioFunc) error {
return s.processScenario(ctx, in, processScenarioFunc, model.AssignFormation)
}

// RemoveAssignedScenario removes all the scenarios that are coming from the provided ASA
func (s *ASAEngine) RemoveAssignedScenario(ctx context.Context, in model.AutomaticScenarioAssignment, processScenarioFunc ProcessScenarioFunc) error {
func (s *ASAEngine) RemoveAssignedScenario(ctx context.Context, in *model.AutomaticScenarioAssignment, processScenarioFunc ProcessScenarioFunc) error {
return s.processScenario(ctx, in, processScenarioFunc, model.UnassignFormation)
}

func (s *ASAEngine) processScenario(ctx context.Context, in model.AutomaticScenarioAssignment, processScenarioFunc ProcessScenarioFunc, processingType model.FormationOperation) error {
func (s *ASAEngine) processScenario(ctx context.Context, in *model.AutomaticScenarioAssignment, processScenarioFunc ProcessScenarioFunc, processingType model.FormationOperation) error {
runtimeTypes, err := s.getFormationTemplateRuntimeTypes(ctx, in.ScenarioName, in.Tenant)
if err != nil {
return err
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestService_EnsureScenarioAssigned(t *testing.T) {
FormationRepositoryFn func() *automock.FormationRepository
FormationTemplateRepositoryFn func() *automock.FormationTemplateRepository
ProcessFunc func() *automock.ProcessFunc
InputASA model.AutomaticScenarioAssignment
InputASA *model.AutomaticScenarioAssignment
ExpectedErrMessage string
}{
{
Expand Down Expand Up @@ -408,7 +408,7 @@ func TestService_RemoveAssignedScenario(t *testing.T) {
FormationRepositoryFn func() *automock.FormationRepository
FormationTemplateRepositoryFn func() *automock.FormationTemplateRepository
ProcessFunc func() *automock.ProcessFunc
InputASA model.AutomaticScenarioAssignment
InputASA *model.AutomaticScenarioAssignment
ExpectedErrMessage string
}{
{
Expand Down
117 changes: 112 additions & 5 deletions components/director/internal/domain/formation/assign_formation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,14 @@ func TestServiceAssignFormation(t *testing.T) {
TargetType: model.FormationAssignmentTypeRuntimeContext,
},
}

asa := model.AutomaticScenarioAssignment{
asa := &model.AutomaticScenarioAssignment{
ScenarioName: testFormationName,
Tenant: TntInternalID,
TargetTenantID: TargetTenant,
}

runtime := &model.Runtime{ID: RuntimeID}

testCases := []struct {
Name string
TxFn func() (*persistenceautomock.PersistenceTx, *persistenceautomock.Transactioner)
Expand All @@ -251,6 +252,7 @@ func TestServiceAssignFormation(t *testing.T) {
AsaRepoFn func() *automock.AutomaticFormationAssignmentRepository
AsaServiceFN func() *automock.AutomaticFormationAssignmentService
RuntimeContextRepoFn func() *automock.RuntimeContextRepository
RuntimeRepoFn func() *automock.RuntimeRepository
FormationRepositoryFn func() *automock.FormationRepository
NotificationServiceFN func() *automock.NotificationsService
FormationTemplateRepositoryFn func() *automock.FormationTemplateRepository
Expand Down Expand Up @@ -503,6 +505,11 @@ func TestServiceAssignFormation(t *testing.T) {
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
return repo
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
runtimeRepo := &automock.RuntimeRepository{}
runtimeRepo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return runtimeRepo
},
NotificationServiceFN: func() *automock.NotificationsService {
notificationSvc := &automock.NotificationsService{}
notificationSvc.On("GenerateFormationAssignmentNotifications", ctx, TntInternalID, RuntimeID, expectedFormation, model.AssignFormation, graphql.FormationObjectTypeRuntime).Return(notifications, nil).Once()
Expand Down Expand Up @@ -546,6 +553,11 @@ func TestServiceAssignFormation(t *testing.T) {
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
return repo
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
runtimeRepo := &automock.RuntimeRepository{}
runtimeRepo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return runtimeRepo
},
NotificationServiceFN: func() *automock.NotificationsService {
notificationSvc := &automock.NotificationsService{}
notificationSvc.On("GenerateFormationAssignmentNotifications", ctx, TntInternalID, RuntimeID, expectedFormation, model.AssignFormation, graphql.FormationObjectTypeRuntime).Return(notifications, nil).Once()
Expand Down Expand Up @@ -596,6 +608,11 @@ func TestServiceAssignFormation(t *testing.T) {
notificationSvc.On("GenerateFormationAssignmentNotifications", ctx, TntInternalID, RuntimeID, expectedSecondFormation, model.AssignFormation, graphql.FormationObjectTypeRuntime).Return(notifications, nil).Once()
return notificationSvc
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
runtimeRepo := &automock.RuntimeRepository{}
runtimeRepo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return runtimeRepo
},
FormationAssignmentServiceFn: func() *automock.FormationAssignmentService {
formationAssignmentSvc := &automock.FormationAssignmentService{}
formationAssignmentSvc.On("GenerateAssignments", ctx, TntInternalID, RuntimeID, graphql.FormationObjectTypeRuntime, expectedSecondFormation).Return(formationAssignmentInputs, nil).Once()
Expand Down Expand Up @@ -969,6 +986,7 @@ func TestServiceAssignFormation(t *testing.T) {
repo := &automock.ApplicationRepository{}
repo.On("GetByID", mock.Anything, TntInternalID, ApplicationID).Return(&model.Application{
BaseEntity: &model.BaseEntity{
ID: ApplicationID,
Ready: false,
},
}, nil).Once()
Expand Down Expand Up @@ -1006,6 +1024,7 @@ func TestServiceAssignFormation(t *testing.T) {
repo := &automock.ApplicationRepository{}
repo.On("GetByID", mock.Anything, TntInternalID, ApplicationID).Return(&model.Application{
BaseEntity: &model.BaseEntity{
ID: ApplicationID,
DeletedAt: &time.Time{},
Ready: true,
},
Expand Down Expand Up @@ -1126,6 +1145,7 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &applicationTypeLblInput).Return(emptyApplicationType, nil).Once()
return labelService
},
ApplicationRepoFn: expectEmptySliceApplicationAndReadyApplicationRepo,
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedSecondFormation, nil).Once()
Expand Down Expand Up @@ -1164,6 +1184,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &applicationTypeLblInput).Return(emptyApplicationType, nil).Once()
return labelService
},
ApplicationRepoFn: func() *automock.ApplicationRepository {
repo := &automock.ApplicationRepository{}
repo.On("GetByID", mock.Anything, TntInternalID, ApplicationID).Return(existingApp, nil).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedSecondFormation, nil).Once()
Expand Down Expand Up @@ -1193,6 +1218,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &applicationTypeLblInput).Return(nil, testErr).Once()
return labelService
},
ApplicationRepoFn: func() *automock.ApplicationRepository {
repo := &automock.ApplicationRepository{}
repo.On("GetByID", mock.Anything, TntInternalID, ApplicationID).Return(existingApp, nil).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedSecondFormation, nil).Once()
Expand Down Expand Up @@ -1244,6 +1274,39 @@ func TestServiceAssignFormation(t *testing.T) {
InputFormation: inputFormation,
ExpectedErrMessage: testErr.Error(),
},
{
Name: "error for runtime when runtime does not exist",
TxFn: txGen.ThatDoesntExpectCommit,
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(nil, testErr).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedFormation, nil).Once()
return formationRepo
},
FormationTemplateRepositoryFn: func() *automock.FormationTemplateRepository {
repo := &automock.FormationTemplateRepository{}
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
return repo
},
LabelServiceFn: func() *automock.LabelService {
labelService := &automock.LabelService{}
labelService.On("GetLabel", ctx, TntInternalID, &runtimeTypeLblInput).Return(runtimeTypeLbl, nil).Once()
return labelService
},
ConstraintEngineFn: func() *automock.ConstraintEngine {
engine := &automock.ConstraintEngine{}
engine.On("EnforceConstraints", ctx, preAssignLocation, fixAssignRuntimeDetails(testFormationName), FormationTemplateID).Return(nil).Once()
return engine
},
ObjectType: graphql.FormationObjectTypeRuntime,
ObjectID: RuntimeID,
InputFormation: inputFormation,
ExpectedErrMessage: testErr.Error(),
},
{
Name: "error for runtime when label does not exist and can't create it",
TxFn: txGen.ThatDoesntExpectCommit,
Expand All @@ -1252,6 +1315,11 @@ func TestServiceAssignFormation(t *testing.T) {
uidService.On("Generate").Return(fixUUID()).Once()
return uidService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedFormation, nil).Once()
Expand Down Expand Up @@ -1288,6 +1356,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &runtimeLblInput).Return(nil, testErr).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationTemplateRepositoryFn: func() *automock.FormationTemplateRepository {
repo := &automock.FormationTemplateRepository{}
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
Expand Down Expand Up @@ -1331,6 +1404,11 @@ func TestServiceAssignFormation(t *testing.T) {
}, nil).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationTemplateRepositoryFn: func() *automock.FormationTemplateRepository {
repo := &automock.FormationTemplateRepository{}
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
Expand Down Expand Up @@ -1368,6 +1446,11 @@ func TestServiceAssignFormation(t *testing.T) {
}, nil).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationTemplateRepositoryFn: func() *automock.FormationTemplateRepository {
repo := &automock.FormationTemplateRepository{}
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
Expand Down Expand Up @@ -1398,6 +1481,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("UpdateLabel", ctx, TntInternalID, runtimeLbl.ID, &runtimeLblInput).Return(testErr).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationTemplateRepositoryFn: func() *automock.FormationTemplateRepository {
repo := &automock.FormationTemplateRepository{}
repo.On("Get", ctx, FormationTemplateID).Return(expectedFormationTemplate, nil).Once()
Expand Down Expand Up @@ -1458,7 +1546,7 @@ func TestServiceAssignFormation(t *testing.T) {
},
AsaRepoFn: func() *automock.AutomaticFormationAssignmentRepository {
asaRepo := &automock.AutomaticFormationAssignmentRepository{}
asaRepo.On("Create", ctx, model.AutomaticScenarioAssignment{ScenarioName: testFormationName, Tenant: TntInternalID, TargetTenantID: TargetTenant}).Return(testErr).Once()
asaRepo.On("Create", ctx, asa).Return(testErr).Once()

return asaRepo
},
Expand Down Expand Up @@ -1547,6 +1635,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &runtimeTypeLblInput).Return(runtimeTypeLbl, nil).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedFormation, nil).Once()
Expand Down Expand Up @@ -1590,6 +1683,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &runtimeTypeLblInput).Return(emptyRuntimeType, nil).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedFormation, nil).Once()
Expand Down Expand Up @@ -1619,6 +1717,11 @@ func TestServiceAssignFormation(t *testing.T) {
labelService.On("GetLabel", ctx, TntInternalID, &runtimeTypeLblInput).Return(nil, testErr).Once()
return labelService
},
RuntimeRepoFn: func() *automock.RuntimeRepository {
repo := &automock.RuntimeRepository{}
repo.On("GetByID", ctx, TntInternalID, RuntimeID).Return(runtime, nil).Once()
return repo
},
FormationRepositoryFn: func() *automock.FormationRepository {
formationRepo := &automock.FormationRepository{}
formationRepo.On("GetByName", ctx, testFormationName, TntInternalID).Return(expectedFormation, nil).Once()
Expand Down Expand Up @@ -2729,6 +2832,10 @@ func TestServiceAssignFormation(t *testing.T) {
if testCase.RuntimeContextRepoFn != nil {
runtimeContextRepo = testCase.RuntimeContextRepoFn()
}
runtimeRepo := unusedRuntimeRepo()
if testCase.RuntimeRepoFn != nil {
runtimeRepo = testCase.RuntimeRepoFn()
}
formationRepo := unusedFormationRepo()
if testCase.FormationRepositoryFn != nil {
formationRepo = testCase.FormationRepositoryFn()
Expand Down Expand Up @@ -2756,7 +2863,7 @@ func TestServiceAssignFormation(t *testing.T) {
asaEngine = testCase.ASAEngineFn()
}

svc := formation.NewServiceWithAsaEngine(transact, applicationRepository, nil, nil, formationRepo, formationTemplateRepo, labelService, uidService, labelDefService, asaRepo, asaService, tenantSvc, nil, runtimeContextRepo, formationAssignmentSvc, nil, nil, notificationSvc, constraintEngine, runtimeType, applicationType, asaEngine, nil)
svc := formation.NewServiceWithAsaEngine(transact, applicationRepository, nil, nil, formationRepo, formationTemplateRepo, labelService, uidService, labelDefService, asaRepo, asaService, tenantSvc, runtimeRepo, runtimeContextRepo, formationAssignmentSvc, nil, nil, notificationSvc, constraintEngine, runtimeType, applicationType, asaEngine, nil)

// WHEN
actual, err := svc.AssignFormation(ctx, TntInternalID, testCase.ObjectID, testCase.ObjectType, testCase.InputFormation)
Expand All @@ -2771,7 +2878,7 @@ func TestServiceAssignFormation(t *testing.T) {
require.Nil(t, actual)
}

mock.AssertExpectationsForObjects(t, persist, uidService, applicationRepository, labelService, asaRepo, asaService, tenantSvc, labelDefService, runtimeContextRepo, formationRepo, formationTemplateRepo, webhookClient, notificationSvc, formationAssignmentSvc, constraintEngine, asaEngine)
mock.AssertExpectationsForObjects(t, persist, uidService, applicationRepository, labelService, asaRepo, asaService, tenantSvc, labelDefService, runtimeContextRepo, runtimeRepo, formationRepo, formationTemplateRepo, webhookClient, notificationSvc, formationAssignmentSvc, constraintEngine, asaEngine)
})
}
}
Loading

0 comments on commit 6a8c163

Please sign in to comment.