From 4f1a5d7d39370ee3cd791be822d9bb730d903794 Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Fri, 15 Mar 2019 18:38:24 +0100 Subject: [PATCH 1/2] [KIECLOUD-149] Fix trial environments Signed-off-by: Ruben Romero Montes --- config/dbs/h2.yaml | 26 ------------------- config/envs/rhdm-authoring.yaml | 10 ++++--- config/envs/rhdm-trial.yaml | 11 +++++--- config/envs/rhpam-authoring.yaml | 10 ++++--- config/envs/rhpam-trial.yaml | 11 +++++--- .../crs/kieapp_rhdm_production-immutable.yaml | 2 +- pkg/controller/kieapp/constants/constants.go | 2 +- .../kieapp/defaults/defaults_test.go | 19 ++++++++------ pkg/controller/kieapp/defaults/merge_test.go | 16 ++++++------ 9 files changed, 49 insertions(+), 58 deletions(-) diff --git a/config/dbs/h2.yaml b/config/dbs/h2.yaml index 67d675734..01a669394 100644 --- a/config/dbs/h2.yaml +++ b/config/dbs/h2.yaml @@ -13,32 +13,6 @@ servers: spec: containers: - name: "[[.KieName]]" - env: - ## H2 driver settings BEGIN - - name: DATASOURCES - value: "RHPAM" - - name: RHPAM_DATABASE - value: "rhpam7" - - name: RHPAM_JNDI - value: "java:/jboss/datasources/rhpam" - - name: RHPAM_JTA - value: "true" - - name: KIE_SERVER_PERSISTENCE_DS - value: "java:/jboss/datasources/rhpam" - - name: RHPAM_DRIVER - value: "h2" - - name: RHPAM_USERNAME - value: "sa" - - name: RHPAM_PASSWORD - value: "[[$.AdminPassword]]" - - name: RHPAM_SERVICE_HOST - value: "dummy_ignored" - - name: RHPAM_SERVICE_PORT - value: "12345" - - name: KIE_SERVER_PERSISTENCE_DIALECT - value: "org.hibernate.dialect.H2Dialect" - - name: RHPAM_XA_CONNECTION_PROPERTY_URL - value: "jdbc:h2:/opt/eap/standalone/data/rhpam" volumeMounts: - name: "[[.KieName]]-h2-pvol" mountPath: "/opt/eap/standalone/data" diff --git a/config/envs/rhdm-authoring.yaml b/config/envs/rhdm-authoring.yaml index f0cd56619..186fc3691 100644 --- a/config/envs/rhdm-authoring.yaml +++ b/config/envs/rhdm-authoring.yaml @@ -23,13 +23,17 @@ console: requests: storage: 1Gi services: - - spec: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: ports: - name: git-ssh port: 8001 targetPort: 8001 - metadata: - name: "[[.ApplicationName]]-[[.Console.Name]]" + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" ## KIE smartrouter BEGIN smartRouter: omit: true diff --git a/config/envs/rhdm-trial.yaml b/config/envs/rhdm-trial.yaml index b019c934e..9278ea6bd 100644 --- a/config/envs/rhdm-trial.yaml +++ b/config/envs/rhdm-trial.yaml @@ -27,6 +27,10 @@ console: - name: git-ssh port: 8001 targetPort: 8001 + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" routes: - id: "[[.ApplicationName]]-[[.Console.Name]]-http" metadata: @@ -63,10 +67,9 @@ servers: containers: - name: "[[.KieName]]" env: - - name: KIE_SERVER_ROUTE_NAME - value: "[[.KieName]]-http" - - name: KIE_SERVER_PROTOCOL - - name: KIE_SERVER_PORT + - name: JGROUPS_PING_PROTOCOL + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + - name: OPENSHIFT_DNS_PING_SERVICE_PORT - name: FILTERS value: "AC_ALLOW_ORIGIN,AC_ALLOW_METHODS,AC_ALLOW_HEADERS,AC_ALLOW_CREDENTIALS,AC_MAX_AGE" - name: AC_ALLOW_ORIGIN_FILTER_RESPONSE_HEADER_NAME diff --git a/config/envs/rhpam-authoring.yaml b/config/envs/rhpam-authoring.yaml index f0cd56619..186fc3691 100644 --- a/config/envs/rhpam-authoring.yaml +++ b/config/envs/rhpam-authoring.yaml @@ -23,13 +23,17 @@ console: requests: storage: 1Gi services: - - spec: + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]" + spec: ports: - name: git-ssh port: 8001 targetPort: 8001 - metadata: - name: "[[.ApplicationName]]-[[.Console.Name]]" + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" ## KIE smartrouter BEGIN smartRouter: omit: true diff --git a/config/envs/rhpam-trial.yaml b/config/envs/rhpam-trial.yaml index b019c934e..9278ea6bd 100644 --- a/config/envs/rhpam-trial.yaml +++ b/config/envs/rhpam-trial.yaml @@ -27,6 +27,10 @@ console: - name: git-ssh port: 8001 targetPort: 8001 + - metadata: + name: "[[.ApplicationName]]-[[.Console.Name]]-ping" + annotations: + delete: "true" routes: - id: "[[.ApplicationName]]-[[.Console.Name]]-http" metadata: @@ -63,10 +67,9 @@ servers: containers: - name: "[[.KieName]]" env: - - name: KIE_SERVER_ROUTE_NAME - value: "[[.KieName]]-http" - - name: KIE_SERVER_PROTOCOL - - name: KIE_SERVER_PORT + - name: JGROUPS_PING_PROTOCOL + - name: OPENSHIFT_DNS_PING_SERVICE_NAME + - name: OPENSHIFT_DNS_PING_SERVICE_PORT - name: FILTERS value: "AC_ALLOW_ORIGIN,AC_ALLOW_METHODS,AC_ALLOW_HEADERS,AC_ALLOW_CREDENTIALS,AC_MAX_AGE" - name: AC_ALLOW_ORIGIN_FILTER_RESPONSE_HEADER_NAME diff --git a/deploy/crs/kieapp_rhdm_production-immutable.yaml b/deploy/crs/kieapp_rhdm_production-immutable.yaml index 0125d788d..12aa43407 100644 --- a/deploy/crs/kieapp_rhdm_production-immutable.yaml +++ b/deploy/crs/kieapp_rhdm_production-immutable.yaml @@ -12,4 +12,4 @@ spec: uri: https://github.com/jboss-container-images/rhdm-7-openshift-image.git reference: master contextDir: quickstarts/hello-rules/hellorules - deployments: 2 + diff --git a/pkg/controller/kieapp/constants/constants.go b/pkg/controller/kieapp/constants/constants.go index 27e818507..bd4313ed7 100644 --- a/pkg/controller/kieapp/constants/constants.go +++ b/pkg/controller/kieapp/constants/constants.go @@ -47,7 +47,7 @@ var rhdmAppConstants = v1.AppConstants{Product: RhdmPrefix, Prefix: "rhdmcentr", var ReplicasTrial = v1.ReplicaConstants{ Console: v1.Replicas{Replicas: 1, DenyScale: true}, - Server: v1.Replicas{Replicas: 2}, + Server: v1.Replicas{Replicas: 1}, SmartRouter: v1.Replicas{Replicas: 1}, } var replicasRhpamProductionImmutable = v1.ReplicaConstants{ diff --git a/pkg/controller/kieapp/defaults/defaults_test.go b/pkg/controller/kieapp/defaults/defaults_test.go index 9ae898e60..a937e5730 100644 --- a/pkg/controller/kieapp/defaults/defaults_test.go +++ b/pkg/controller/kieapp/defaults/defaults_test.go @@ -130,8 +130,7 @@ func TestRHPAMTrialEnvironment(t *testing.T) { pingService := getService(wbServices, "test-rhpamcentr-ping") assert.NotNil(t, pingService, "Ping service not found") - assert.Len(t, pingService.Spec.Ports, 1, "The ping service should have only one port") - assert.True(t, hasPort(pingService, 8888), "The ping service should listen on port 8888") + assert.False(t, hasPort(pingService, 8888), "The ping service should listen on port 8888") assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", cr.Spec.CommonConfig.ApplicationName, len(env.Servers)), env.Servers[len(env.Servers)-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Name, "the container name should have incremented") assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) @@ -164,9 +163,7 @@ func TestRHDMTrialEnvironment(t *testing.T) { assert.True(t, hasPort(mainService, 8001), "The rhdmcentr service should listen on port 8001") pingService := getService(wbServices, "test-rhdmcentr-ping") - assert.NotNil(t, pingService, "Ping service not found") - assert.Len(t, pingService.Spec.Ports, 1, "The ping service should have only one port") - assert.Equal(t, int32(8888), pingService.Spec.Ports[0].Port, "The ping service should listen on port 8888") + assert.False(t, hasPort(pingService, 8888), "The ping service should not listen on port 8888") assert.Equal(t, fmt.Sprintf("%s-kieserver-%d", cr.Spec.CommonConfig.ApplicationName, len(env.Servers)), env.Servers[len(env.Servers)-1].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Name, "the container name should have incremented") assert.Equal(t, "test-rhdmcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, fmt.Sprintf("rhdm%s-decisioncentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) @@ -189,6 +186,10 @@ func TestRhpamcentrMonitoringEnvironment(t *testing.T) { assert.Equal(t, "test-rhpamcentrmon", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-monitoring-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + + pingService := getService(env.Console.Services, "test-rhpamcentrmon-ping") + assert.Len(t, pingService.Spec.Ports, 1, "The ping service should have only one port") + assert.True(t, hasPort(pingService, 8888), "The ping service should listen on port 8888") for i := 0; i < len(env.Servers); i++ { assert.Equal(t, "PRODUCTION", getEnvVariable(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "KIE_SERVER_MODE")) } @@ -229,6 +230,10 @@ func TestRhpamAuthoringHAEnvironment(t *testing.T) { assert.Equal(t, "test-rhpamcentr", env.Console.DeploymentConfigs[0].ObjectMeta.Name) assert.Equal(t, fmt.Sprintf("rhpam%s-businesscentral-openshift", cr.Spec.CommonConfig.Version), env.Console.DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Image) + pingService := getService(env.Console.Services, "test-rhpamcentr-ping") + assert.Len(t, pingService.Spec.Ports, 1, "The ping service should have only one port") + assert.True(t, hasPort(pingService, 8888), "The ping service should listen on port 8888") + } func TestRhdmProdImmutableEnvironment(t *testing.T) { @@ -781,7 +786,7 @@ func TestMergeTrialAndCommonConfig(t *testing.T) { Name: "KIE_ADMIN_PWD", Value: "RedHat", }) - assert.Contains(t, env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{ + assert.NotContains(t, env.Servers[0].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].Env, corev1.EnvVar{ Name: "KIE_SERVER_PROTOCOL", Value: "", }) @@ -1461,7 +1466,6 @@ func TestDatabaseH2(t *testing.T) { assert.Equal(t, fmt.Sprintf("test-kieserver%s-ping", idx), env.Servers[i].Services[1].ObjectMeta.Name) assert.Equal(t, 1, len(env.Servers[i].DeploymentConfigs)) assert.Equal(t, fmt.Sprintf("test-kieserver%s", idx), env.Servers[i].DeploymentConfigs[0].Name) - assert.Equal(t, "h2", getEnvVariable(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "RHPAM_DRIVER")) assert.Equal(t, 2, len(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].VolumeMounts)) assert.Equal(t, fmt.Sprintf("test-kieserver%s-h2-pvol", idx), env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].VolumeMounts[1].Name) assert.Equal(t, 2, len(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Volumes)) @@ -1509,7 +1513,6 @@ func TestDatabaseH2Ephemeral(t *testing.T) { assert.Equal(t, fmt.Sprintf("test-kieserver%s-ping", idx), env.Servers[i].Services[1].ObjectMeta.Name) assert.Equal(t, 1, len(env.Servers[i].DeploymentConfigs)) assert.Equal(t, fmt.Sprintf("test-kieserver%s", idx), env.Servers[i].DeploymentConfigs[0].Name) - assert.Equal(t, "h2", getEnvVariable(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0], "RHPAM_DRIVER")) assert.Equal(t, 2, len(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].VolumeMounts)) assert.Equal(t, fmt.Sprintf("test-kieserver%s-h2-pvol", idx), env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Containers[0].VolumeMounts[1].Name) assert.Equal(t, 2, len(env.Servers[i].DeploymentConfigs[0].Spec.Template.Spec.Volumes)) diff --git a/pkg/controller/kieapp/defaults/merge_test.go b/pkg/controller/kieapp/defaults/merge_test.go index 853049c8d..3f304a523 100644 --- a/pkg/controller/kieapp/defaults/merge_test.go +++ b/pkg/controller/kieapp/defaults/merge_test.go @@ -46,19 +46,19 @@ func TestMergeServices(t *testing.T) { overwrite.Console.Services = append(overwrite.Console.Services, *service5) mergedEnv, _ := merge(baseline, *overwrite) - assert.Equal(t, 4, len(mergedEnv.Console.Services), "Expected 4 services") + assert.Equal(t, 3, len(mergedEnv.Console.Services), "Expected 4 services") finalService1 := mergedEnv.Console.Services[0] + finalService2 := mergedEnv.Console.Services[1] finalService3 := mergedEnv.Console.Services[2] - finalService4 := mergedEnv.Console.Services[3] assert.Equal(t, "true", finalService1.Labels["baseline"], "Expected the baseline label to be set") assert.Equal(t, "true", finalService1.Labels["overwrite"], "Expected the overwrite label to also be set as part of the merge") assert.Equal(t, "overwrite", finalService1.Labels["source"], "Expected the source label to have been overwritten by merge") - assert.Equal(t, "true", finalService3.Labels["baseline"], "Expected the baseline label to be set") - assert.Equal(t, "baseline", finalService3.Labels["source"], "Expected the source label to be baseline") - assert.Equal(t, "true", finalService4.Labels["overwrite"], "Expected the overwrite label to be set") - assert.Equal(t, "overwrite", finalService4.Labels["source"], "Expected the source label to be overwrite") - assert.Equal(t, "test-rhpamcentr-2", finalService3.Name, "Second service name should end with -2") - assert.Equal(t, "test-rhpamcentr-3", finalService4.Name, "Second service name should end with -3") + assert.Equal(t, "true", finalService2.Labels["baseline"], "Expected the baseline label to be set") + assert.Equal(t, "baseline", finalService2.Labels["source"], "Expected the source label to be baseline") + assert.Equal(t, "true", finalService3.Labels["overwrite"], "Expected the overwrite label to be set") + assert.Equal(t, "overwrite", finalService3.Labels["source"], "Expected the source label to be overwrite") + assert.Equal(t, "test-rhpamcentr-2", finalService2.Name, "Second service name should end with -2") + assert.Equal(t, "test-rhpamcentr-3", finalService3.Name, "Second service name should end with -3") } func TestMergeRoutes(t *testing.T) { From 7cc2d0359e7020ccf53e8ba433e397fc1021ba0a Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Mon, 18 Mar 2019 14:30:41 +0100 Subject: [PATCH 2/2] [KIECLOUD-149] Fix test message Signed-off-by: Ruben Romero Montes --- pkg/controller/kieapp/defaults/merge_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/kieapp/defaults/merge_test.go b/pkg/controller/kieapp/defaults/merge_test.go index 3f304a523..ce8818e97 100644 --- a/pkg/controller/kieapp/defaults/merge_test.go +++ b/pkg/controller/kieapp/defaults/merge_test.go @@ -46,7 +46,7 @@ func TestMergeServices(t *testing.T) { overwrite.Console.Services = append(overwrite.Console.Services, *service5) mergedEnv, _ := merge(baseline, *overwrite) - assert.Equal(t, 3, len(mergedEnv.Console.Services), "Expected 4 services") + assert.Equal(t, 3, len(mergedEnv.Console.Services), "Expected 3 services") finalService1 := mergedEnv.Console.Services[0] finalService2 := mergedEnv.Console.Services[1] finalService3 := mergedEnv.Console.Services[2]