Skip to content

Commit

Permalink
[issue-368] knative integration with DataIndex and JobService: fix er…
Browse files Browse the repository at this point in the history
…rors after rebasing from main
  • Loading branch information
jianrongzhang89 committed Sep 6, 2024
1 parent b4f1f23 commit 449afcf
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 45 deletions.
17 changes: 13 additions & 4 deletions controllers/sonataflowplatform_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,19 @@ func TestSonataFlowPlatformController(t *testing.T) {
// Check with persistence set
ksp.Spec = v1alpha08.SonataFlowPlatformSpec{
Services: &v1alpha08.ServicesPlatformSpec{
DataIndex: &v1alpha08.ServiceSpec{
Persistence: &v1alpha08.PersistenceOptionsSpec{},
DataIndex: &v1alpha08.DataIndexServiceSpec{
ServiceSpec: v1alpha08.ServiceSpec{
Persistence: &v1alpha08.PersistenceOptionsSpec{
MigrateDBOnStartUp: false,
},
},
},
JobService: &v1alpha08.ServiceSpec{
Persistence: &v1alpha08.PersistenceOptionsSpec{},
JobService: &v1alpha08.JobServiceServiceSpec{
ServiceSpec: v1alpha08.ServiceSpec{
Persistence: &v1alpha08.PersistenceOptionsSpec{
MigrateDBOnStartUp: false,
},
},
},
},
Persistence: &v1alpha08.PlatformPersistenceOptionsSpec{
Expand Down Expand Up @@ -924,6 +932,7 @@ func TestSonataFlowPlatformController(t *testing.T) {

t.Run("verify that knative resources creation for job service and data index service with services level brokers is performed without error", func(t *testing.T) {
namespace := t.Name()

// Create a SonataFlowPlatform object with metadata and spec.
ksp := test.GetBasePlatformWithBrokerInReadyPhase(namespace)
brokerName := "default"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ spec:
dataIndex:
enabled: true
persistence:
migrateDBOnStartUp: true
postgresql:
jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=data-index-service
secretRef:
Expand All @@ -54,6 +55,7 @@ spec:
jobService:
enabled: true
persistence:
migrateDBOnStartUp: true
postgresql:
jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=jobs-service
secretRef:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ spec:
kind: Broker
name: di-source
persistence:
migrateDBOnStartUp: true
postgresql:
jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=data-index-service
secretRef:
Expand Down Expand Up @@ -68,6 +69,7 @@ spec:
kind: Broker
name: js-sink
persistence:
migrateDBOnStartUp: true
postgresql:
jdbcUrl: jdbc:postgresql://postgres:5432/sonataflow?currentSchema=jobs-service
secretRef:
Expand Down
104 changes: 63 additions & 41 deletions workflowproj/operator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,13 @@ func TestCreateNewManagedPropsConfigMap(t *testing.T) {
}}}},

map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"app.kubernetes.io/part-of": "someplatform",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"app.kubernetes.io/part-of": "someplatform",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
{
Expand All @@ -60,12 +62,14 @@ func TestCreateNewManagedPropsConfigMap(t *testing.T) {
Labels: map[string]string{}}}},

map[string]string{
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
// if the workflow is missing a platform then the managed properties won't have them
//"app.kubernetes.io/part-of": "someplatform",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
}
Expand Down Expand Up @@ -98,10 +102,12 @@ func TestCreateNewUserPropsConfigMap(t *testing.T) {
Name: t.Name() + "-props",
Namespace: "",
Labels: map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
Data: map[string]string{
Expand All @@ -122,11 +128,13 @@ func TestCreateNewUserPropsConfigMap(t *testing.T) {
Name: t.Name() + "-props",
Namespace: "",
Labels: map[string]string{
"older-label": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"older-label": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
Data: map[string]string{
Expand Down Expand Up @@ -158,12 +166,14 @@ func TestGetDefaultLabels(t *testing.T) {
Labels: map[string]string{}}}},

map[string]string{
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
// if the workflow is missing a platform then the managed properties won't have them
//"app.kubernetes.io/part-of": "someplatform",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
{
Expand All @@ -175,10 +185,12 @@ func TestGetDefaultLabels(t *testing.T) {
}}}},

map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
}
Expand Down Expand Up @@ -232,10 +244,12 @@ func TestGetMergedLabels(t *testing.T) {
},
}},
want: map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
{
Expand All @@ -249,11 +263,13 @@ func TestGetMergedLabels(t *testing.T) {
},
}},
want: map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"some-older-label": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
"some-older-label": t.Name(),
},
},
}
Expand Down Expand Up @@ -281,10 +297,12 @@ func TestGetSelectorLabels(t *testing.T) {
},
}},
want: map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
{
Expand All @@ -293,18 +311,22 @@ func TestGetSelectorLabels(t *testing.T) {
ObjectMeta: v1.ObjectMeta{
Name: t.Name(),
Labels: map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
}},
want: map[string]string{
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"app": t.Name(),
"app.kubernetes.io/name": t.Name(),
"app.kubernetes.io/component": "serverless-workflow",
"app.kubernetes.io/managed-by": "sonataflow-operator",
"sonataflow.org/workflow-app": t.Name(),
"sonataflow.org/workflow-namespace": "",
},
},
}
Expand Down

0 comments on commit 449afcf

Please sign in to comment.