Skip to content

Commit

Permalink
Merge pull request #100 from ruromero/trial-fix
Browse files Browse the repository at this point in the history
[KIECLOUD-149] Fix trial environments
  • Loading branch information
openshift-merge-robot authored Mar 18, 2019
2 parents 9032ba1 + 7cc2d03 commit b8013b2
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 58 deletions.
26 changes: 0 additions & 26 deletions config/dbs/h2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 7 additions & 3 deletions config/envs/rhdm-authoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions config/envs/rhdm-trial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
10 changes: 7 additions & 3 deletions config/envs/rhpam-authoring.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions config/envs/rhpam-trial.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion deploy/crs/kieapp_rhdm_production-immutable.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

2 changes: 1 addition & 1 deletion pkg/controller/kieapp/constants/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
19 changes: 11 additions & 8 deletions pkg/controller/kieapp/defaults/defaults_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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"))
}
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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: "",
})
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
Expand Down
16 changes: 8 additions & 8 deletions pkg/controller/kieapp/defaults/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 3 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) {
Expand Down

0 comments on commit b8013b2

Please sign in to comment.