diff --git a/bddframework/features/cli/cli_deploy_quarkus_service.feature b/bddframework/features/cli/cli_deploy_quarkus_service.feature deleted file mode 100644 index 0100710f2..000000000 --- a/bddframework/features/cli/cli_deploy_quarkus_service.feature +++ /dev/null @@ -1,60 +0,0 @@ -@cli -@quarkus -Feature: CLI: Deploy quarkus service - - Background: - Given Namespace is created - - Scenario Outline: CLI deploy drools-quarkus-example service - Given Kogito Operator is deployed - - When CLI deploy quarkus example service "drools-quarkus-example" with native - - Then Kogito application "drools-quarkus-example" has 1 pods running within minutes - And HTTP GET request on service "drools-quarkus-example" with path "persons/all" is successful within 2 minutes - - @smoke - Examples: Non Native - | native | minutes | - | "disabled" | 10 | - - @native - Examples: Native - | native | minutes | - | "enabled" | 20 | - -##### - - @persistence - Scenario Outline: CLI deploy jbpm-quarkus-example service with persistence - Given Kogito Operator is deployed with Infinispan operator - And CLI deploy quarkus example service "jbpm-quarkus-example" with persistence enabled and native - And Kogito application "jbpm-quarkus-example" has 1 pods running within minutes - And HTTP GET request on service "jbpm-quarkus-example" with path "orders" is successful within 3 minutes - And HTTP POST request on service "jbpm-quarkus-example" with path "orders" and body: - """json - { - "approver" : "john", - "order" : { - "orderNumber" : "12345", - "shipped" : false - } - } - """ - And HTTP GET request on service "jbpm-quarkus-example" with path "orders" should return an array of size 1 within 1 minutes - - When Scale Kogito application "jbpm-quarkus-example" to 0 pods within 2 minutes - And Scale Kogito application "jbpm-quarkus-example" to 1 pods within 2 minutes - - Then HTTP GET request on service "jbpm-quarkus-example" with path "orders" should return an array of size 1 within 2 minutes - - Examples: Non Native - | native | minutes | - | "disabled" | 10 | - - # Disabled as long as https://issues.redhat.com/browse/KOGITO-842 is not solved - @disabled - @native - Examples: Native - | native | minutes | - | "enabled" | 20 | \ No newline at end of file diff --git a/bddframework/features/cli/cli_deploy_springboot_service.feature b/bddframework/features/cli/cli_deploy_springboot_service.feature deleted file mode 100644 index 6583aca18..000000000 --- a/bddframework/features/cli/cli_deploy_springboot_service.feature +++ /dev/null @@ -1,42 +0,0 @@ -@cli -@springboot -Feature: CLI: Deploy spring boot service - - Background: - Given Namespace is created - - @smoke - Scenario: CLI deploy jbpm-springboot-example service - Given Kogito Operator is deployed - - When CLI deploy spring boot example service "jbpm-springboot-example" - - Then Kogito application "jbpm-springboot-example" has 1 pods running within 10 minutes - And HTTP GET request on service "jbpm-springboot-example" with path "orders" is successful within 2 minutes - -##### - - # Disabled because of https://issues.redhat.com/browse/KOGITO-948 - @disabled - @persistence - Scenario: CLI deploy jbpm-springboot-example service with persistence - Given Kogito Operator is deployed with Infinispan operator - And CLI deploy spring boot example service "jbpm-springboot-example" with persistence enabled - And Kogito application "jbpm-springboot-example" has 1 pods running within 10 minutes - And HTTP GET request on service "jbpm-springboot-example" with path "orders" is successful within 3 minutes - And HTTP POST request on service "jbpm-springboot-example" with path "orders" and body: - """json - { - "approver" : "john", - "order" : { - "orderNumber" : "12345", - "shipped" : false - } - } - """ - And HTTP GET request on service "jbpm-springboot-example" with path "orders" should return an array of size 1 within 1 minutes - - When Scale Kogito application "jbpm-springboot-example" to 0 pods within 2 minutes - And Scale Kogito application "jbpm-springboot-example" to 1 pods within 2 minutes - - Then HTTP GET request on service "jbpm-springboot-example" with path "orders" should return an array of size 1 within 2 minutes \ No newline at end of file diff --git a/bddframework/features/cli/cli_install_dataindex.feature b/bddframework/features/cli/cli_install_dataindex.feature deleted file mode 100644 index f81b7b447..000000000 --- a/bddframework/features/cli/cli_install_dataindex.feature +++ /dev/null @@ -1,20 +0,0 @@ -@cli -@dataindex -Feature: CLI: Install Kogito Data Index - - @smoke - Scenario: CLI install Kogito Data Index - Given Namespace is created - And Kogito Operator is deployed with Infinispan and Kafka operators - - When CLI install Kogito Data Index with 1 replicas - - Then Kogito Data Index has 1 pods running within 10 minutes - And GraphQL request on service "kogito-data-index" is successful within 2 minutes with path "graphql" and query: - """ - { - ProcessInstances{ - id - } - } - """ diff --git a/bddframework/features/cli/cli_install_jobsservice.feature b/bddframework/features/cli/cli_install_jobsservice.feature deleted file mode 100644 index 6cd4408b0..000000000 --- a/bddframework/features/cli/cli_install_jobsservice.feature +++ /dev/null @@ -1,47 +0,0 @@ -@cli -@jobsservice -Feature: CLI: Install Kogito Jobs Service - - Background: - Given Namespace is created - - @smoke - Scenario: CLI install Kogito Jobs Service - Given Kogito Operator is deployed - - When CLI install Kogito Jobs Service with 1 replicas - And Kogito Jobs Service has 1 pods running within 5 minutes - And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: - """json - { - "id": "1", - "priority": "1", - "expirationTime": "2100-01-29T18:19:00Z", - "callbackEndpoint": "http://localhost:8080/callback" - } - """ - - Then HTTP GET request on service "kogito-jobs-service" with path "jobs/1" is successful within 1 minutes - -##### - - @persistence - Scenario: CLI install Kogito Jobs Service with persistence - Given Kogito Operator is deployed with Infinispan operator - - When CLI install Kogito Jobs Service with persistence and 1 replicas - And Kogito Jobs Service has 1 pods running within 5 minutes - And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: - """json - { - "id": "1", - "priority": "1", - "expirationTime": "2100-01-29T18:19:00Z", - "callbackEndpoint": "http://localhost:8080/callback" - } - """ - And HTTP GET request on service "kogito-jobs-service" with path "jobs/1" is successful within 1 minutes - And Scale Kogito Jobs Service to 0 pods within 2 minutes - And Scale Kogito Jobs Service to 1 pods within 2 minutes - - Then HTTP GET request on service "kogito-jobs-service" with path "jobs/1" is successful within 1 minutes \ No newline at end of file diff --git a/bddframework/features/cli/cli_install_kogitoinfra_components.feature b/bddframework/features/cli/cli_install_kogitoinfra_components.feature deleted file mode 100644 index 8ccaebfb6..000000000 --- a/bddframework/features/cli/cli_install_kogitoinfra_components.feature +++ /dev/null @@ -1,31 +0,0 @@ -@cli -Feature: CLI: Install Kogito Infra Component - - Background: - Given Namespace is created - And Kogito Operator is deployed with Infinispan, Kafka and Keycloak operators - - Scenario Outline: CLI install Kogito Infra Component - When CLI install Kogito Infra - - Then Kogito Infra should be running within minutes - - Examples: - | component | timeoutInMinutes | - | Infinispan | 5 | - | Kafka | 10 | - | Keycloak | 10 | - - Scenario Outline: CLI remove Kogito Infra Component - Given Install Kogito Infra - And Kogito Infra should be running within minutes - - When CLI remove Kogito Infra - - Then Kogito Infra should NOT be running within minutes - - Examples: - | component | installTimeoutInMinutes | removeTimeoutInMinutes | - | Infinispan | 5 | 2 | - | Kafka | 10 | 2 | - | Keycloak | 10 | 5 | \ No newline at end of file diff --git a/bddframework/features/cr/install_kogitoinfra.feature b/bddframework/features/cr/install_kogitoinfra.feature deleted file mode 100644 index 11d0a28da..000000000 --- a/bddframework/features/cr/install_kogitoinfra.feature +++ /dev/null @@ -1,31 +0,0 @@ -@cr -Feature: CR: Kogito Infra - - Background: - Given Namespace is created - And Kogito Operator is deployed with Infinispan, Kafka and Keycloak operators - - Scenario Outline: CR install Kogito Infra component - When Install Kogito Infra - - Then Kogito Infra should be running within minutes - - Examples: - | component | timeoutInMinutes | - | Infinispan | 5 | - | Kafka | 5 | - | Keycloak | 10 | - - Scenario Outline: CR remove Kogito Infra Component - Given Install Kogito Infra - And Kogito Infra should be running within minutes - - When Remove Kogito Infra - - Then Kogito Infra should NOT be running within minutes - - Examples: - | component | installTimeoutInMinutes | removeTimeoutInMinutes | - | Infinispan | 5 | 2 | - | Kafka | 10 | 2 | - | Keycloak | 10 | 5 | \ No newline at end of file diff --git a/bddframework/features/cr/deploy_quarkus_service.feature b/bddframework/features/deploy_quarkus_service.feature similarity index 58% rename from bddframework/features/cr/deploy_quarkus_service.feature rename to bddframework/features/deploy_quarkus_service.feature index 09d5746e1..eae012d63 100644 --- a/bddframework/features/cr/deploy_quarkus_service.feature +++ b/bddframework/features/deploy_quarkus_service.feature @@ -1,33 +1,46 @@ -@cr @quarkus -Feature: CR: Deploy quarkus service +Feature: Deploy quarkus service Background: Given Namespace is created - Scenario Outline: CR deploy drools-quarkus-example service + Scenario Outline: Deploy drools-quarkus-example service without persistence Given Kogito Operator is deployed - When Deploy quarkus example service "drools-quarkus-example" with native + When "" deploy quarkus example service "drools-quarkus-example" with native "" Then Kogito application "drools-quarkus-example" has 1 pods running within minutes And HTTP GET request on service "drools-quarkus-example" with path "persons/all" is successful within 2 minutes - Examples: Non Native - | native | minutes | - | "disabled" | 10 | + @cr + Examples: CR Non Native + | installer | native | minutes | + | CR | false | 10 | + @cr @native - Examples: Native - | native | minutes | - | "enabled" | 20 | + Examples: CR Native + | installer | native | minutes | + | CR | true | 20 | + + @smoke + @cli + Examples: CLI Non Native + | installer | native | minutes | + | CLI | false | 10 | + + @cli + @native + Examples: CLI Native + | installer | native | minutes | + | CLI | true | 20 | ##### @persistence - Scenario Outline: CR deploy jbpm-quarkus-example service with persistence + Scenario Outline: Deploy jbpm-quarkus-example service with persistence Given Kogito Operator is deployed with Infinispan operator - And Deploy quarkus example service "jbpm-quarkus-example" with persistence enabled and native + And "" deploy quarkus example service "jbpm-quarkus-example" with native "" and persistence And Kogito application "jbpm-quarkus-example" has 1 pods running within minutes And HTTP GET request on service "jbpm-quarkus-example" with path "orders" is successful within 3 minutes And HTTP POST request on service "jbpm-quarkus-example" with path "orders" and body: @@ -47,25 +60,42 @@ Feature: CR: Deploy quarkus service Then HTTP GET request on service "jbpm-quarkus-example" with path "orders" should return an array of size 1 within 2 minutes - Examples: Non Native - | native | minutes | - | "disabled" | 10 | + @cr + Examples: CR Non Native + | installer | native | minutes | + | CR | false | 10 | # Disabled as long as https://issues.redhat.com/browse/KOGITO-842 is not solved @disabled + @cr @native - Examples: - | native | minutes | - | "enabled" | 20 | + Examples: CR Native + | installer | native | minutes | + | CR | true | 20 | + + @cli + Examples: CLI Non Native + | installer | native | minutes | + | CLI | false | 10 | + + # Disabled as long as https://issues.redhat.com/browse/KOGITO-842 is not solved + @disabled + @cli + @native + Examples: CLI Native + | installer | native | minutes | + | CLI | true | 20 | ##### # Disabled as long as https://issues.redhat.com/browse/KOGITO-1163 and https://issues.redhat.com/browse/KOGITO-1166 is not solved @disabled - Scenario Outline: CR deploy timer-quarkus-example service with Jobs service + @cr + @jobsservice + Scenario Outline: Deploy timer-quarkus-example service with Jobs service Given Kogito Operator is deployed - And Deploy Kogito Jobs Service with 1 replicas - And Deploy quarkus example service "timer-quarkus-example" with native + And "CR" install Kogito Jobs Service with 1 replicas + And "CR" deploy quarkus example service "timer-quarkus-example" with native "" And Kogito application "timer-quarkus-example" has 1 pods running within minutes When HTTP POST request on service "timer-quarkus-example" is successful within 2 minutes with path "timer" and body: @@ -79,11 +109,11 @@ Feature: CR: Deploy quarkus service Examples: Non Native | native | minutes | - | "disabled" | 10 | + | false | 10 | # Disabled as long as https://issues.redhat.com/browse/KOGITO-1179 is not solved @disabled @native - Examples: + Examples: Native | native | minutes | - | "enabled" | 20 | + | true | 20 | diff --git a/bddframework/features/cr/deploy_springboot_service.feature b/bddframework/features/deploy_springboot_service.feature similarity index 73% rename from bddframework/features/cr/deploy_springboot_service.feature rename to bddframework/features/deploy_springboot_service.feature index b199a5bf0..c2916b686 100644 --- a/bddframework/features/cr/deploy_springboot_service.feature +++ b/bddframework/features/deploy_springboot_service.feature @@ -1,26 +1,36 @@ -@cr @springboot -Feature: CR: Deploy spring boot service with persistence +Feature: Deploy spring boot service Background: Given Namespace is created - Scenario: CR deploy jbpm-springboot-example service + Scenario Outline: Deploy jbpm-springboot-example service without persistence Given Kogito Operator is deployed - When Deploy spring boot example service "jbpm-springboot-example" + When "" deploy spring boot example service "jbpm-springboot-example" Then Kogito application "jbpm-springboot-example" has 1 pods running within 10 minutes And HTTP GET request on service "jbpm-springboot-example" with path "orders" is successful within 2 minutes + @cr + Examples: CR + | installer | + | CR | + + @smoke + @cli + Examples: CLI + | installer | + | CLI | + ##### # Disabled because of https://issues.redhat.com/browse/KOGITO-948 @disabled @persistence - Scenario: CR deploy jbpm-springboot-example service with persistence + Scenario Outline: Deploy jbpm-springboot-example service with persistence Given Kogito Operator is deployed with Infinispan operator - And Deploy spring boot example service "jbpm-springboot-example" with persistence enabled + And "" deploy spring boot example service "jbpm-springboot-example" with persistence And Kogito application "jbpm-springboot-example" has 1 pods running within 10 minutes And HTTP GET request on service "jbpm-springboot-example" with path "orders" is successful within 3 minutes And HTTP POST request on service "jbpm-springboot-example" with path "orders" and body: @@ -40,14 +50,25 @@ Feature: CR: Deploy spring boot service with persistence Then HTTP GET request on service "jbpm-springboot-example" with path "orders" should return an array of size 1 within 2 minutes + @cr + Examples: CR + | installer | + | CR | + + @cli + Examples: CLI + | installer | + | CLI | ##### # Disabled as long as https://issues.redhat.com/browse/KOGITO-1163 and https://issues.redhat.com/browse/KOGITO-1166 is not solved @disabled + @cr + @jobsservice Scenario: CR deploy timer-springboot-example service with Jobs service Given Kogito Operator is deployed - And Deploy Kogito Jobs Service with 1 replicas - And Deploy spring boot example service "timer-springboot-example" + And "CR" install Kogito Jobs Service with 1 replicas + And "CR" deploy spring boot example service "timer-springboot-example" And Kogito application "timer-springboot-example" has 1 pods running within 10 minutes When HTTP POST request on service "timer-springboot-example" is successful within 2 minutes with path "timer" and body: diff --git a/bddframework/features/cr/install_dataindex_service.feature b/bddframework/features/install_dataindex.feature similarity index 60% rename from bddframework/features/cr/install_dataindex_service.feature rename to bddframework/features/install_dataindex.feature index 8a0c85ad5..62ca1af3b 100644 --- a/bddframework/features/cr/install_dataindex_service.feature +++ b/bddframework/features/install_dataindex.feature @@ -1,15 +1,14 @@ -@cr @dataindex -Feature: CR: Install Kogito Data Index +Feature: Kogito Data Index Background: Given Namespace is created And Kogito Operator is deployed with Infinispan and Kafka operators - Scenario: CR: Install Kogito Data Index - When Install Kogito Data Index with 1 replicas + Scenario Outline: Install Kogito Data Index + When "" install Kogito Data Index with 1 replicas - Then Kogito Data Index has 1 pods running within 5 minutes + Then Kogito Data Index has 1 pods running within 10 minutes And GraphQL request on service "kogito-data-index" is successful within 2 minutes with path "graphql" and query: """ { @@ -19,13 +18,25 @@ Feature: CR: Install Kogito Data Index } """ + @cr + Examples: CR + | installer | + | CR | + + @smoke + @cli + Examples: CLI + | installer | + | CLI | + ##### + @cr @events @persistence - Scenario Outline: CR: Process instance events are stored in Data Index - Given Install Kogito Data Index with 1 replicas - And Deploy quarkus example service "jbpm-quarkus-example" with persistence enabled and native and events "enabled" + Scenario Outline: Process instance events are stored in Data Index + Given "CR" install Kogito Data Index with 1 replicas + And "CR" deploy quarkus example service "jbpm-quarkus-example" with native "" and persistence and events And Kogito application "jbpm-quarkus-example" has 1 pods running within minutes And HTTP GET request on service "jbpm-quarkus-example" with path "orders" is successful within 3 minutes @@ -42,13 +53,13 @@ Feature: CR: Install Kogito Data Index Then GraphQL request on Data Index service returns ProcessInstances processName "orders" within 2 minutes - Examples: + Examples: Non native | native | minutes | - | "disabled" | 10 | + | false | 10 | # Disabled as long as https://issues.redhat.com/browse/KOGITO-842 is not solved @disabled @native - Examples: + Examples: Native | native | minutes | - | "enabled" | 20 | \ No newline at end of file + | true | 20 | \ No newline at end of file diff --git a/bddframework/features/cr/install_jobs_service.feature b/bddframework/features/install_jobs_service.feature similarity index 67% rename from bddframework/features/cr/install_jobs_service.feature rename to bddframework/features/install_jobs_service.feature index 203ea83fa..2d9eb486a 100644 --- a/bddframework/features/cr/install_jobs_service.feature +++ b/bddframework/features/install_jobs_service.feature @@ -1,14 +1,13 @@ -@cr @jobsservice -Feature: CR: Install Kogito Jobs Service +Feature: Install Kogito Jobs Service Background: Given Namespace is created - Scenario: CR install Kogito Jobs Service + Scenario Outline: Install Kogito Jobs Service without persistence Given Kogito Operator is deployed - When Deploy Kogito Jobs Service with 1 replicas + When "" install Kogito Jobs Service with 1 replicas And Kogito Jobs Service has 1 pods running within 5 minutes And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: """json @@ -22,13 +21,24 @@ Feature: CR: Install Kogito Jobs Service Then HTTP GET request on service "kogito-jobs-service" with path "jobs/1" is successful within 1 minutes + @cr + Examples: CR + | installer | + | CR | + + @smoke + @cli + Examples: CLI + | installer | + | CLI | + ##### @persistence - Scenario: CR install Kogito Jobs Service with persistence + Scenario Outline: Install Kogito Jobs Service with persistence Given Kogito Operator is deployed with Infinispan operator - When Deploy Kogito Jobs Service with persistence and 1 replicas + When "" install Kogito Jobs Service with 1 replicas and persistence And Kogito Jobs Service has 1 pods running within 5 minutes And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: """json @@ -43,4 +53,14 @@ Feature: CR: Install Kogito Jobs Service And Scale Kogito Jobs Service to 0 pods within 2 minutes And Scale Kogito Jobs Service to 1 pods within 2 minutes - Then HTTP GET request on service "kogito-jobs-service" with path "jobs/1" is successful within 1 minutes \ No newline at end of file + Then HTTP GET request on service "kogito-jobs-service" with path "jobs/1" is successful within 1 minutes + + @cr + Examples: CR + | installer | + | CR | + + @cli + Examples: CLI + | installer | + | CLI | \ No newline at end of file diff --git a/bddframework/features/install_kogitoinfra.feature b/bddframework/features/install_kogitoinfra.feature new file mode 100644 index 000000000..d7758976f --- /dev/null +++ b/bddframework/features/install_kogitoinfra.feature @@ -0,0 +1,27 @@ +@infra +Feature: Kogito Infra + + Background: + Given Namespace is created + + Scenario Outline: Install/Remove Kogito Infra + Given Kogito Operator is deployed with operator + When "" install Kogito Infra "" + Then Kogito Infra "" should be running within minutes + + When "" remove Kogito Infra "" + Then Kogito Infra "" should NOT be running within minutes + + @cr + Examples: CR install/Remove + | installer | component | installTimeoutInMinutes | removeTimeoutInMinutes | + | CR | Infinispan | 10 | 5 | + | CR | Kafka | 10 | 5 | + | CR | Keycloak | 10 | 5 | + + @cli + Examples: CLI install/Remove + | installer | component | installTimeoutInMinutes | removeTimeoutInMinutes | + | CLI | Infinispan | 10 | 5 | + | CLI | Kafka | 10 | 5 | + | CLI | Keycloak | 10 | 5 | \ No newline at end of file diff --git a/bddframework/features/olm/cli_install_operator.feature b/bddframework/features/olm/cli_install_operator.feature index 4415cb778..02b53bd55 100644 --- a/bddframework/features/olm/cli_install_operator.feature +++ b/bddframework/features/olm/cli_install_operator.feature @@ -15,7 +15,7 @@ Feature: CLI: Install Kogito Operator ##### Scenario: CLI install operator with Kogito Data Index - When CLI install Kogito operator with Kogito Data Index enabled + When CLI install Kogito operator with Kogito Data Index Then Kogito Data Index has 1 pods running within 5 minutes And GraphQL request on service "kogito-data-index" is successful within 2 minutes with path "graphql" and query: @@ -32,7 +32,7 @@ Feature: CLI: Install Kogito Operator # Disabled until https://issues.redhat.com/browse/KOGITO-910 has been implemented @disabled Scenario: CLI install operator with Kogito Jobs Service - When CLI install Kogito operator with Kogito Jobs Service enabled + When CLI install Kogito operator with Kogito Jobs Service Then Kogito Jobs Service has 1 pods running within 5 minutes And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: diff --git a/bddframework/features/olm/cli_new_project.feature b/bddframework/features/olm/cli_new_project.feature index da6e2c55e..9fafa6ddf 100644 --- a/bddframework/features/olm/cli_new_project.feature +++ b/bddframework/features/olm/cli_new_project.feature @@ -12,7 +12,7 @@ Feature: CLI: Project ##### Scenario: CLI create project with Kogito Data Index - When CLI create namespace with Kogito Data Index enabled + When CLI create namespace with Kogito Data Index Then Kogito Data Index has 1 pods running within 5 minutes And GraphQL request on service "kogito-data-index" is successful within 2 minutes with path "graphql" and query: @@ -29,7 +29,7 @@ Feature: CLI: Project # Disabled until https://issues.redhat.com/browse/KOGITO-910 has been implemented @disabled Scenario: CLI create new project with Kogito Jobs Service - When CLI create namespace with Kogito Jobs Service enabled + When CLI create namespace with Kogito Jobs Service Then Kogito Jobs Service has 1 pods running within 5 minutes And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: diff --git a/bddframework/features/olm/cli_use_project.feature b/bddframework/features/olm/cli_use_project.feature index 4c4d3a038..82665c7af 100644 --- a/bddframework/features/olm/cli_use_project.feature +++ b/bddframework/features/olm/cli_use_project.feature @@ -15,7 +15,7 @@ Feature: CLI: Project ##### Scenario: CLI use project and set Kogito Data Index - When CLI use namespace with Kogito Data Index enabled + When CLI use namespace with Kogito Data Index Then Kogito Data Index has 1 pods running within 5 minutes And GraphQL request on service "kogito-data-index" is successful within 2 minutes with path "graphql" and query: @@ -32,7 +32,7 @@ Feature: CLI: Project # Disabled until https://issues.redhat.com/browse/KOGITO-910 has been implemented @disabled Scenario: CLI use project and set Kogito Jobs Service (use-project --install-data-index) - When CLI use namespace with Kogito Jobs Service enabled + When CLI use namespace with Kogito Jobs Service Then Kogito Jobs Service has 1 pods running within 5 minutes And HTTP POST request on service "kogito-jobs-service" is successful within 2 minutes with path "jobs" and body: diff --git a/bddframework/features/deploy_prometheus.feature b/bddframework/features/prometheus.feature similarity index 93% rename from bddframework/features/deploy_prometheus.feature rename to bddframework/features/prometheus.feature index ab0639510..4a641cf03 100644 --- a/bddframework/features/deploy_prometheus.feature +++ b/bddframework/features/prometheus.feature @@ -1,5 +1,6 @@ # Disabled until image metadata label processing is fixed in OCP 4.x or https://issues.redhat.com/browse/KOGITO-731 is implemented @disabled +@cr Feature: Service Deployment: Prometheus Background: @@ -9,7 +10,7 @@ Feature: Service Deployment: Prometheus Scenario: Deploy hr service and verify that it successfully connects to Prometheus Given Prometheus instance is deployed, monitoring services with label name "app" and value "hr" - And Deploy quarkus example service "onboarding-example/hr" with native "disabled" + And "CR" deploy quarkus example service "onboarding-example/hr" with native "false" And Kogito application "hr" has 1 pods running within 10 minutes When HTTP POST request on service "hr" is successful within 2 minutes with path "id" and body: diff --git a/bddframework/features/cr/service_discovery.feature b/bddframework/features/service_discovery.feature similarity index 77% rename from bddframework/features/cr/service_discovery.feature rename to bddframework/features/service_discovery.feature index 7cdf12787..c7b2d96fc 100644 --- a/bddframework/features/cr/service_discovery.feature +++ b/bddframework/features/service_discovery.feature @@ -8,17 +8,17 @@ Feature: Discovery with onboarding Scenario Outline: Deploy onboarding example Given Kogito Operator is deployed - When Deploy quarkus example service "onboarding-example/hr" with native and labels + When "CR" deploy quarkus example service "onboarding-example/hr" with native "" and labels | department | process | | id | process | | employeeValidation | process | - And Deploy quarkus example service "onboarding-example/payroll" with native and labels + And "CR" deploy quarkus example service "onboarding-example/payroll" with native "" and labels | taxes/rate | process | | vacations/days | process | | payments/date | process | - And Deploy quarkus example service "onboarding-example/onboarding" with native and labels + And "CR" deploy quarkus example service "onboarding-example/onboarding" with native "" and labels | onboarding | process | And Kogito application "hr" has 1 pods running within minutes @@ -45,9 +45,9 @@ Feature: Discovery with onboarding Examples: Non Native | native | minutes | - | "disabled" | 10 | + | false | 10 | @native Examples: Native | native | minutes | - | "enabled" | 20 | \ No newline at end of file + | true | 20 | \ No newline at end of file diff --git a/bddframework/framework/cli.go b/bddframework/framework/cli.go index 25638da62..726706b49 100644 --- a/bddframework/framework/cli.go +++ b/bddframework/framework/cli.go @@ -15,12 +15,8 @@ package framework import ( - "fmt" "os" "os/exec" - - "github.com/kiegroup/kogito-cloud-operator/pkg/framework" - "github.com/kiegroup/kogito-cloud-operator/pkg/infrastructure" ) // CheckCliBinaryExist checks if the CLI binary does exist @@ -56,73 +52,3 @@ func ExecuteCliCommandInNamespace(namespace string, args ...string) (string, err args = append(args, "-p", namespace) return ExecuteCliCommand(namespace, args...) } - -// CliDeployQuarkusExample deploy a Quarkus example with the CLI -func CliDeployQuarkusExample(namespace, appName, contextDir string, native, persistence bool) error { - GetLogger(namespace).Infof("CLI Deploy quarkus example %s with name %s, native %v and persistence %v", contextDir, appName, native, persistence) - return CliDeployExample(namespace, appName, contextDir, "quarkus", native, persistence) -} - -// CliDeploySpringBootExample deploys a Spring boot example with the CLI -func CliDeploySpringBootExample(namespace, appName, contextDir string, persistence bool) error { - GetLogger(namespace).Infof("CLI Deploy spring boot example %s with name %s and persistence %v", contextDir, appName, persistence) - return CliDeployExample(namespace, appName, contextDir, "springboot", false, persistence) -} - -// CliDeployExample deploys an example with the CLI -func CliDeployExample(namespace, appName, contextDir, runtime string, native, persistence bool) error { - cmd := []string{"deploy-service", appName, GetConfigExamplesRepositoryURI()} - - cmd = append(cmd, "-c", contextDir) - cmd = append(cmd, "-r", runtime) - if native { - cmd = append(cmd, "--native") - } - if ref := GetConfigExamplesRepositoryRef(); len(ref) > 0 { - cmd = append(cmd, "-b", ref) - } - - if mavenMirrorURL := GetConfigMavenMirrorURL(); len(mavenMirrorURL) > 0 { - cmd = append(cmd, "--maven-mirror-url", mavenMirrorURL) - } - - if persistence { - cmd = append(cmd, "--install-infinispan", "Always") - cmd = append(cmd, "--build-env", fmt.Sprintf("%s=-Ppersistence", mavenArgsAppendEnvVar)) - } - - cmd = append(cmd, "--image-version", GetConfigBuildImageVersion()) - - _, err := ExecuteCliCommandInNamespace(namespace, cmd...) - return err -} - -// CliInstallDataIndex installs the Kogito Data Index -func CliInstallDataIndex(namespace string, replicas int) error { - cmd := []string{"install", "data-index"} - - // Get correct image tag - image := framework.ConvertImageTagToImage(infrastructure.DefaultDataIndexImage) - image.Tag = GetConfigServicesImageVersion() - cmd = append(cmd, "--image", framework.ConvertImageToImageTag(image)) - - _, err := ExecuteCliCommandInNamespace(namespace, cmd...) - return err -} - -// CliInstallKogitoJobsService installs the Kogito Jobs Service -func CliInstallKogitoJobsService(namespace string, replicas int, persistence bool) error { - cmd := []string{"install", "jobs-service"} - - if persistence { - cmd = append(cmd, "--enable-persistence") - } - - // Get correct image tag - image := framework.ConvertImageTagToImage(infrastructure.DefaultJobsServiceImageFullTag) - image.Tag = GetConfigServicesImageVersion() - cmd = append(cmd, "--image", framework.ConvertImageToImageTag(image)) - - _, err := ExecuteCliCommandInNamespace(namespace, cmd...) - return err -} diff --git a/bddframework/framework/installer.go b/bddframework/framework/installer.go new file mode 100644 index 000000000..8ae6c5af4 --- /dev/null +++ b/bddframework/framework/installer.go @@ -0,0 +1,47 @@ +// Copyright 2020 Red Hat, Inc. and/or its affiliates +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package framework + +import ( + "fmt" + "strings" +) + +// InstallerType defines the type of installer for services +type InstallerType string + +const ( + cliInstallerKey = "cli" + crInstallerKey = "cr" +) + +var ( + // CLIInstallerType defines the CLI installer + CLIInstallerType InstallerType = cliInstallerKey + // CRInstallerType defines the CR installer + CRInstallerType InstallerType = crInstallerKey +) + +// MustParseInstallerType returns the correct installer type, based on the given string +func MustParseInstallerType(typeStr string) InstallerType { + switch t := strings.ToLower(typeStr); t { + case cliInstallerKey: + return CLIInstallerType + case crInstallerKey: + return CRInstallerType + default: + panic(fmt.Errorf("Unknown installer type %s", typeStr)) + } +} diff --git a/bddframework/framework/kogitoapp.go b/bddframework/framework/kogitoapp.go index 744150735..d75e773e9 100644 --- a/bddframework/framework/kogitoapp.go +++ b/bddframework/framework/kogitoapp.go @@ -16,6 +16,7 @@ package framework import ( "fmt" + "strings" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -30,61 +31,111 @@ const ( mavenMirrorURLEnvVar = "MAVEN_MIRROR_URL" ) -// DeployQuarkusExample deploy a Quarkus example -func DeployQuarkusExample(namespace, appName, contextDir string, native, persistence, events bool, labels map[string]string) error { - GetLogger(namespace).Infof("Deploy quarkus example %s with name %s, native %v and persistence %v", contextDir, appName, native, persistence) - return DeployExample(namespace, appName, contextDir, "quarkus", native, persistence, events, labels) +// KogitoAppDeployment defines the elements for the deployment of a kogito application +type KogitoAppDeployment struct { + AppName string + ContextDir string + Runtime v1alpha1.RuntimeType + Native bool + Persistence bool + Events bool + Labels map[string]string } -// DeploySpringBootExample deploys a Spring boot example -func DeploySpringBootExample(namespace, appName, contextDir string, persistence, events bool, labels map[string]string) error { - GetLogger(namespace).Infof("Deploy spring boot example %s with name %s and persistence %v", contextDir, appName, persistence) - return DeployExample(namespace, appName, contextDir, "springboot", false, persistence, events, labels) +// DeployExample deploy a Kogito example +func DeployExample(namespace string, installerType InstallerType, kogitoAppDeployment KogitoAppDeployment) error { + GetLogger(namespace).Infof("%s deploy %s example %s with name %s, native %v, persistence %v, events %v and labels %v", installerType, kogitoAppDeployment.Runtime, kogitoAppDeployment.ContextDir, kogitoAppDeployment.AppName, kogitoAppDeployment.Native, kogitoAppDeployment.Persistence, kogitoAppDeployment.Events, kogitoAppDeployment.Labels) + switch installerType { + case CLIInstallerType: + return cliDeployExample(namespace, kogitoAppDeployment) + case CRInstallerType: + return crDeployExample(namespace, kogitoAppDeployment) + default: + panic(fmt.Errorf("Unknown installer type %s", installerType)) + } } // DeployExample deploys an example -func DeployExample(namespace, appName, contextDir, runtime string, native, persistence, events bool, labels map[string]string) error { - kogitoApp := getKogitoAppStub(namespace, appName, labels) - if runtime == "quarkus" { - kogitoApp.Spec.Runtime = v1alpha1.QuarkusRuntimeType - } else if runtime == "springboot" { - kogitoApp.Spec.Runtime = v1alpha1.SpringbootRuntimeType - } +func crDeployExample(namespace string, kogitoAppDeployment KogitoAppDeployment) error { + kogitoApp := getKogitoAppStub(namespace, kogitoAppDeployment.AppName, kogitoAppDeployment.Labels) + kogitoApp.Spec.Runtime = kogitoAppDeployment.Runtime gitProjectURI := GetConfigExamplesRepositoryURI() - kogitoApp.Spec.Build.Native = native + kogitoApp.Spec.Build.Native = kogitoAppDeployment.Native kogitoApp.Spec.Build.GitSource.URI = &gitProjectURI - kogitoApp.Spec.Build.GitSource.ContextDir = contextDir + kogitoApp.Spec.Build.GitSource.ContextDir = kogitoAppDeployment.ContextDir kogitoApp.Spec.Build.GitSource.Reference = GetConfigExamplesRepositoryRef() // Add namespace for service discovery // Can be removed once https://issues.redhat.com/browse/KOGITO-675 is done appendNewEnvToKogitoApp(kogitoApp, "NAMESPACE", namespace) - profiles := "" - if persistence { - profiles = profiles + "persistence," + var profiles []string + if kogitoAppDeployment.Persistence { + profiles = append(profiles, "persistence") kogitoApp.Spec.Infra.InstallInfinispan = v1alpha1.KogitoAppInfraInstallInfinispanAlways } - if events { - profiles = profiles + "events," + if kogitoAppDeployment.Events { + profiles = append(profiles, "events") kogitoApp.Spec.Infra.InstallKafka = v1alpha1.KogitoAppInfraInstallKafkaAlways appendNewEnvToKogitoApp(kogitoApp, "MP_MESSAGING_OUTGOING_KOGITO_PROCESSINSTANCES_EVENTS_BOOTSTRAP_SERVERS", "") appendNewEnvToKogitoApp(kogitoApp, "MP_MESSAGING_OUTGOING_KOGITO_USERTASKINSTANCES_EVENTS_BOOTSTRAP_SERVERS", "") } if len(profiles) > 0 { - appendNewEnvToKogitoAppBuild(kogitoApp, mavenArgsAppendEnvVar, "-P"+profiles) + appendNewEnvToKogitoAppBuild(kogitoApp, mavenArgsAppendEnvVar, "-P"+strings.Join(profiles, ",")) } setupBuildImageStreams(kogitoApp) if _, err := kubernetes.ResourceC(kubeClient).CreateIfNotExists(kogitoApp); err != nil { - return fmt.Errorf("Error creating example service %s: %v", appName, err) + return fmt.Errorf("Error creating example service %s: %v", kogitoAppDeployment.AppName, err) } return nil } +func cliDeployExample(namespace string, kogitoAppDeployment KogitoAppDeployment) error { + cmd := []string{"deploy-service", kogitoAppDeployment.AppName, GetConfigExamplesRepositoryURI()} + + cmd = append(cmd, "-c", kogitoAppDeployment.ContextDir) + cmd = append(cmd, "-r", fmt.Sprintf("%s", kogitoAppDeployment.Runtime)) + if kogitoAppDeployment.Native { + cmd = append(cmd, "--native") + } + if ref := GetConfigExamplesRepositoryRef(); len(ref) > 0 { + cmd = append(cmd, "-b", ref) + } + + if mavenMirrorURL := GetConfigMavenMirrorURL(); len(mavenMirrorURL) > 0 { + cmd = append(cmd, "--maven-mirror-url", mavenMirrorURL) + } + + var profiles []string + if kogitoAppDeployment.Persistence { + profiles = append(profiles, "persistence") + cmd = append(cmd, "--install-infinispan", "Always") + } + if kogitoAppDeployment.Events { + profiles = append(profiles, "events") + cmd = append(cmd, "--install-kafka", "Always") + cmd = append(cmd, "--env", "MP_MESSAGING_OUTGOING_KOGITO_PROCESSINSTANCES_EVENTS_BOOTSTRAP_SERVERS=") + cmd = append(cmd, "--env", "MP_MESSAGING_OUTGOING_KOGITO_USERTASKINSTANCES_EVENTS_BOOTSTRAP_SERVERS=") + } + + if len(profiles) > 0 { + cmd = append(cmd, "--build-env", fmt.Sprintf("%s=-P%s", mavenArgsAppendEnvVar, strings.Join(profiles, ","))) + } + + for labelKey, labelValue := range kogitoAppDeployment.Labels { + cmd = append(cmd, "--svc-labels", fmt.Sprintf("%s=%s", labelKey, labelValue)) + } + + cmd = append(cmd, "--image-version", GetConfigBuildImageVersion()) + + _, err := ExecuteCliCommandInNamespace(namespace, cmd...) + return err +} + // SetKogitoAppReplicas sets the number of replicas for a Kogito application func SetKogitoAppReplicas(namespace, name string, nbPods int) error { GetLogger(namespace).Infof("Set Kogito application %s replica number to %d", name, nbPods) diff --git a/bddframework/framework/kogitodataindexservice.go b/bddframework/framework/kogitodataindex.go similarity index 70% rename from bddframework/framework/kogitodataindexservice.go rename to bddframework/framework/kogitodataindex.go index 665d3d48d..ffb7eac93 100644 --- a/bddframework/framework/kogitodataindexservice.go +++ b/bddframework/framework/kogitodataindex.go @@ -27,8 +27,20 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) -// DeployKogitoDataIndexService deploy the Kogito Data Index service -func DeployKogitoDataIndexService(namespace string, replicas int) error { +// InstallKogitoDataIndexService deploy the Kogito Data Index service +func InstallKogitoDataIndexService(namespace string, installerType InstallerType, replicas int) error { + GetLogger(namespace).Infof("%s install Kogito Data Index with %d replicas", installerType, replicas) + switch installerType { + case CLIInstallerType: + return cliInstallKogitoDataIndex(namespace, replicas) + case CRInstallerType: + return crInstallKogitoDataIndex(namespace, replicas) + default: + panic(fmt.Errorf("Unknown installer type %s", installerType)) + } +} + +func crInstallKogitoDataIndex(namespace string, replicas int) error { // Get correct image tag image := framework.ConvertImageTagToImage(infrastructure.DefaultDataIndexImage) image.Tag = GetConfigServicesImageVersion() @@ -50,6 +62,18 @@ func DeployKogitoDataIndexService(namespace string, replicas int) error { return nil } +func cliInstallKogitoDataIndex(namespace string, replicas int) error { + cmd := []string{"install", "data-index"} + + // Get correct image tag + image := framework.ConvertImageTagToImage(infrastructure.DefaultDataIndexImage) + image.Tag = GetConfigServicesImageVersion() + cmd = append(cmd, "--image", framework.ConvertImageToImageTag(image)) + + _, err := ExecuteCliCommandInNamespace(namespace, cmd...) + return err +} + // GetKogitoDataIndexDeployment retrieves the running data index deployment func GetKogitoDataIndexDeployment(namespace string) (*apps.Deployment, error) { return GetDeployment(namespace, infrastructure.DefaultDataIndexName) diff --git a/bddframework/framework/kogitoinfra.go b/bddframework/framework/kogitoinfra.go index 3f5f504ad..cffe750aa 100644 --- a/bddframework/framework/kogitoinfra.go +++ b/bddframework/framework/kogitoinfra.go @@ -16,96 +16,147 @@ package framework import ( "fmt" + "strings" "time" "github.com/kiegroup/kogito-cloud-operator/pkg/infrastructure" ) -// InstallKogitoInfraInfinispan sets kogitoinfra to install Infinispan -func InstallKogitoInfraInfinispan(namespace string) error { - _, _, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithInfinispan().Apply() - return err +// KogitoInfraComponent defines the KogitoInfra component +type KogitoInfraComponent struct { + name string } -// RemoveKogitoInfraInfinispan sets kogitoinfra to remove Infinispan -func RemoveKogitoInfraInfinispan(namespace string) error { - _, _, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithoutInfinispan().Apply() - return err -} +const ( + infinispanKey = "infinispan" + kafkaKey = "kafka" + keycloakKey = "keycloak" +) -// WaitForKogitoInfraInfinispan waits for Infinispan to be installed -func WaitForKogitoInfraInfinispan(namespace string, shouldRun bool, timeoutInMin int) error { - return WaitFor(namespace, getWaitRunningMessage("infinispan", shouldRun), time.Duration(timeoutInMin)*time.Minute, func() (bool, error) { - run, err := IsKogitoInfraInfinispanRunning(namespace) - if !shouldRun { - return !run, err - } - return run, err - }) -} +var ( + // InfinispanKogitoInfraComponent is for infinispan + InfinispanKogitoInfraComponent KogitoInfraComponent = KogitoInfraComponent{name: infinispanKey} + // KafkaKogitoInfraComponent is for kafka + KafkaKogitoInfraComponent KogitoInfraComponent = KogitoInfraComponent{name: kafkaKey} + // KeycloakKogitoInfraComponent is for keycloak + KeycloakKogitoInfraComponent KogitoInfraComponent = KogitoInfraComponent{name: keycloakKey} +) -// IsKogitoInfraInfinispanRunning checks whether Infinispan is running from KogitoInfra -func IsKogitoInfraInfinispanRunning(namespace string) (bool, error) { - _, ready, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithInfinispan().Apply() - return ready, err +// ParseKogitoInfraComponent retrieves the correspoding KogitoInfraComponent +func ParseKogitoInfraComponent(component string) KogitoInfraComponent { + switch cmp := strings.ToLower(component); cmp { + case infinispanKey: + return InfinispanKogitoInfraComponent + case kafkaKey: + return KafkaKogitoInfraComponent + case keycloakKey: + return KeycloakKogitoInfraComponent + default: + return KogitoInfraComponent{name: cmp} + } } -// InstallKogitoInfraKafka sets kogitoinfra to install Kafka -func InstallKogitoInfraKafka(namespace string) error { - // Setup Kogitoinfra to true - _, _, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithKafka().Apply() - return err +// InstallKogitoInfraComponent installs the desired component with the given installer type +func InstallKogitoInfraComponent(namespace string, installerType InstallerType, component KogitoInfraComponent) error { + GetLogger(namespace).Infof("%s install Kogito Infra Component %s", installerType, component.name) + switch installerType { + case CLIInstallerType: + return cliInstallKogitoInfraComponent(namespace, component) + case CRInstallerType: + return crInstallKogitoInfraComponent(namespace, component) + default: + panic(fmt.Errorf("Unknown installer type %s", installerType)) + } } -// RemoveKogitoInfraKafka sets kogitoinfra to remove Kafka -func RemoveKogitoInfraKafka(namespace string) error { - _, _, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithoutKafka().Apply() +func crInstallKogitoInfraComponent(namespace string, component KogitoInfraComponent) error { + ensureComponent := infrastructure.EnsureKogitoInfra(namespace, kubeClient) + switch component { + case InfinispanKogitoInfraComponent: + ensureComponent = ensureComponent.WithInfinispan() + case KafkaKogitoInfraComponent: + ensureComponent = ensureComponent.WithKafka() + case KeycloakKogitoInfraComponent: + ensureComponent = ensureComponent.WithKeycloak() + } + _, _, err := ensureComponent.Apply() return err } -// WaitForKogitoInfraKafka waits for Kafka to be installed -func WaitForKogitoInfraKafka(namespace string, shouldRun bool, timeoutInMin int) error { - return WaitFor(namespace, getWaitRunningMessage("kafka", shouldRun), time.Duration(timeoutInMin)*time.Minute, func() (bool, error) { - run, err := IsKogitoInfraKafkaRunning(namespace) - if !shouldRun { - return !run, err - } - return run, err - }) +func cliInstallKogitoInfraComponent(namespace string, component KogitoInfraComponent) error { + _, err := ExecuteCliCommandInNamespace(namespace, "install", component.name) + return err } -// IsKogitoInfraKafkaRunning checks whether Kafka is running from KogitoInfra -func IsKogitoInfraKafkaRunning(namespace string) (bool, error) { - _, ready, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithKafka().Apply() - return ready, err +// RemoveKogitoInfraComponent removes the desired component with the given installer type +func RemoveKogitoInfraComponent(namespace string, installerType InstallerType, component KogitoInfraComponent) error { + GetLogger(namespace).Infof("%s remove Kogito Infra Component %s", installerType, component.name) + switch installerType { + case CLIInstallerType: + return cliRemoveKogitoInfraComponent(namespace, component) + case CRInstallerType: + return crRemoveKogitoInfraComponent(namespace, component) + default: + panic(fmt.Errorf("Unknown installer type %s", installerType)) + } } -// InstallKogitoInfraKeycloak sets kogitoinfra to install Keycloak -func InstallKogitoInfraKeycloak(namespace string) error { - _, _, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithKeycloak().Apply() +func crRemoveKogitoInfraComponent(namespace string, component KogitoInfraComponent) error { + ensureComponent := infrastructure.EnsureKogitoInfra(namespace, kubeClient) + switch component { + case InfinispanKogitoInfraComponent: + ensureComponent = ensureComponent.WithoutInfinispan() + case KafkaKogitoInfraComponent: + ensureComponent = ensureComponent.WithoutKafka() + case KeycloakKogitoInfraComponent: + ensureComponent = ensureComponent.WithoutKeycloak() + } + _, _, err := ensureComponent.Apply() return err } -// RemoveKogitoInfraKeycloak sets kogitoinfra to remove Keycloak -func RemoveKogitoInfraKeycloak(namespace string) error { - _, _, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithoutKeycloak().Apply() +func cliRemoveKogitoInfraComponent(namespace string, component KogitoInfraComponent) error { + _, err := ExecuteCliCommandInNamespace(namespace, "remove", component.name) return err } -// WaitForKogitoInfraKeycloak waits for Keycloak to be installed -func WaitForKogitoInfraKeycloak(namespace string, shouldRun bool, timeoutInMin int) error { - return WaitFor(namespace, getWaitRunningMessage("keycloak", shouldRun), time.Duration(timeoutInMin)*time.Minute, func() (bool, error) { - run, err := IsKogitoInfraKeycloakRunning(namespace) - if !shouldRun { - return !run, err +// WaitForKogitoInfraComponent waits for the given component to be installed or removed +func WaitForKogitoInfraComponent(namespace string, component KogitoInfraComponent, shouldRun bool, timeoutInMin int) error { + return WaitFor(namespace, getWaitRunningMessage(component.name, shouldRun), time.Duration(timeoutInMin)*time.Minute, func() (bool, error) { + if shouldRun { + return IsKogitoInfraComponentRunning(namespace, component) } - return run, err + return IsKogitoInfraComponentTerminated(namespace, component) }) } -// IsKogitoInfraKeycloakRunning checks whether Keycloak is running from KogitoInfra -func IsKogitoInfraKeycloakRunning(namespace string) (bool, error) { - _, ready, err := infrastructure.EnsureKogitoInfra(namespace, kubeClient).WithKeycloak().Apply() +// IsKogitoInfraComponentRunning checks whether the given component is running from KogitoInfra +func IsKogitoInfraComponentRunning(namespace string, component KogitoInfraComponent) (bool, error) { + ensureComponent := infrastructure.EnsureKogitoInfra(namespace, kubeClient) + switch component { + case InfinispanKogitoInfraComponent: + ensureComponent = ensureComponent.WithInfinispan() + case KafkaKogitoInfraComponent: + ensureComponent = ensureComponent.WithKafka() + case KeycloakKogitoInfraComponent: + ensureComponent = ensureComponent.WithKeycloak() + } + _, ready, err := ensureComponent.Apply() + return ready, err +} + +// IsKogitoInfraComponentTerminated checks whether the given component is terminated from KogitoInfra +func IsKogitoInfraComponentTerminated(namespace string, component KogitoInfraComponent) (bool, error) { + ensureComponent := infrastructure.EnsureKogitoInfra(namespace, kubeClient) + switch component { + case InfinispanKogitoInfraComponent: + ensureComponent = ensureComponent.WithoutInfinispan() + case KafkaKogitoInfraComponent: + ensureComponent = ensureComponent.WithoutKafka() + case KeycloakKogitoInfraComponent: + ensureComponent = ensureComponent.WithoutKeycloak() + } + _, ready, err := ensureComponent.Apply() return ready, err } diff --git a/bddframework/framework/kogitojobsservice.go b/bddframework/framework/kogitojobsservice.go index d8cbd3ca5..c48dbd927 100644 --- a/bddframework/framework/kogitojobsservice.go +++ b/bddframework/framework/kogitojobsservice.go @@ -22,14 +22,26 @@ import ( "github.com/kiegroup/kogito-cloud-operator/pkg/client/kubernetes" "github.com/kiegroup/kogito-cloud-operator/pkg/framework" "github.com/kiegroup/kogito-cloud-operator/pkg/infrastructure" + apps "k8s.io/api/apps/v1" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/types" ) -// DeployKogitoJobsService deploy the Kogito Jobs service -func DeployKogitoJobsService(namespace string, replicas int, persistence bool) error { - GetLogger(namespace).Infof("Deploy Kogito jobs service") +// InstallKogitoJobsService deploy the Kogito Jobs service +func InstallKogitoJobsService(namespace string, installerType InstallerType, replicas int, persistence bool) error { + GetLogger(namespace).Infof("%s install Kogito Jobs Service with %d replicas and persistence %v", installerType, replicas, persistence) + switch installerType { + case CLIInstallerType: + return cliInstallKogitoJobsService(namespace, replicas, persistence) + case CRInstallerType: + return crInstallKogitoJobsService(namespace, replicas, persistence) + default: + panic(fmt.Errorf("Unknown installer type %s", installerType)) + } +} + +func crInstallKogitoJobsService(namespace string, replicas int, persistence bool) error { service := getJobsServiceStub(namespace, replicas, persistence) if _, err := kubernetes.ResourceC(kubeClient).CreateIfNotExists(service); err != nil { @@ -38,6 +50,22 @@ func DeployKogitoJobsService(namespace string, replicas int, persistence bool) e return nil } +func cliInstallKogitoJobsService(namespace string, replicas int, persistence bool) error { + cmd := []string{"install", "jobs-service"} + + if persistence { + cmd = append(cmd, "--enable-persistence") + } + + // Get correct image tag + image := framework.ConvertImageTagToImage(infrastructure.DefaultJobsServiceImageFullTag) + image.Tag = GetConfigServicesImageVersion() + cmd = append(cmd, "--image", framework.ConvertImageToImageTag(image)) + + _, err := ExecuteCliCommandInNamespace(namespace, cmd...) + return err +} + // GetKogitoJobsService retrieves the running jobs service func GetKogitoJobsService(namespace string) (*v1alpha1.KogitoJobsService, error) { service := &v1alpha1.KogitoJobsService{} @@ -49,17 +77,22 @@ func GetKogitoJobsService(namespace string) (*v1alpha1.KogitoJobsService, error) return service, nil } +// GetKogitoJobsServiceDeployment retrieves the running jobs service deployment +func GetKogitoJobsServiceDeployment(namespace string) (*apps.Deployment, error) { + return GetDeployment(namespace, infrastructure.DefaultJobsServiceName) +} + // WaitForKogitoJobsService waits that the jobs service has a certain number of replicas func WaitForKogitoJobsService(namespace string, replicas, timeoutInMin int) error { return WaitFor(namespace, "Kogito jobs service running", time.Duration(timeoutInMin)*time.Minute, func() (bool, error) { - service, err := GetKogitoJobsService(namespace) + service, err := GetKogitoJobsServiceDeployment(namespace) if err != nil { return false, err } if service == nil { return false, nil } - return service.Status.DeploymentStatus.AvailableReplicas == int32(replicas), nil + return service.Status.Replicas == int32(replicas) && service.Status.AvailableReplicas == int32(replicas), nil }) } diff --git a/bddframework/framework/kubernetes.go b/bddframework/framework/kubernetes.go index 6815f0b66..95c3d6bd2 100644 --- a/bddframework/framework/kubernetes.go +++ b/bddframework/framework/kubernetes.go @@ -78,6 +78,16 @@ func IsNamespace(namespace string) (bool, error) { return ns != nil, nil } +// OperateOnNamespaceIfExists do some operations on the namespace if that one exists +func OperateOnNamespaceIfExists(namespace string, operate func(namespace string) error) error { + if ok, er := IsNamespace(namespace); er != nil { + return fmt.Errorf("Error while checking namespace: %v", er) + } else if ok { + return operate(namespace) + } + return nil +} + // WaitForPods waits for pods with specific label to be available and running func WaitForPods(namespace, labelName, labelValue string, numberOfPods, timeoutInMin int) error { return WaitFor(namespace, fmt.Sprintf("Pods with label name '%s' and value '%s' available and running", labelName, labelValue), time.Duration(timeoutInMin)*time.Minute, func() (bool, error) { diff --git a/bddframework/framework/logging.go b/bddframework/framework/logging.go index 18f9e0c16..a5fdb0baa 100644 --- a/bddframework/framework/logging.go +++ b/bddframework/framework/logging.go @@ -61,8 +61,7 @@ func GetLogger(namespace string) *zap.SugaredLogger { func FlushLogger(namespace string) error { opts, exists := getLoggerOpts(namespace) if !exists { - GetMainLogger().Warnf("Logger %s does not exist... skipping", namespace) - return nil + return fmt.Errorf("Logger %s does not exist... skipping", namespace) } if writer, ok := opts.Output.(io.Closer); ok { err := writer.Close() @@ -331,21 +330,22 @@ var eventKeys = []string{ } // BumpEvents will bump all events into events.log file -func BumpEvents(namespace string) { +func BumpEvents(namespace string) error { eventList, err := kubernetes.EventC(kubeClient).GetEvents(namespace) if err != nil { - GetMainLogger().Errorf("Error retrieving events from namespace %s: %v", namespace, err) + return fmt.Errorf("Error retrieving events from namespace %s: %v", namespace, err) } fileWriter, err := os.Create(getLogFile(namespace, "events")) if err != nil { - GetMainLogger().Errorf("Error while creating filewriter: %v", err) + return fmt.Errorf("Error while creating filewriter: %v", err) } PrintDataMap(eventKeys, mapEvents(eventList), fileWriter) if err := fileWriter.Close(); err != nil { - GetMainLogger().Errorf("Error while closing filewriter: %v", err) + return fmt.Errorf("Error while closing filewriter: %v", err) } + return nil } func mapEvents(eventList *v1beta1.EventList) []map[string]string { diff --git a/bddframework/framework/util.go b/bddframework/framework/util.go index 99dfa5e57..8cce79a05 100644 --- a/bddframework/framework/util.go +++ b/bddframework/framework/util.go @@ -129,7 +129,7 @@ func PrintDataMap(keys []string, dataMaps []map[string]string, writer io.StringW // Write events for _, dataMap := range dataMaps { - for _, key := range eventKeys { + for _, key := range keys { writer.WriteString(dataMap[key]) writer.WriteString(getWhitespaceStr(maxStringSizeMap[key] - len(dataMap[key]) + 1)) writer.WriteString(" | ") diff --git a/bddframework/main_test.go b/bddframework/main_test.go index dc9e4e56a..44d8375ac 100644 --- a/bddframework/main_test.go +++ b/bddframework/main_test.go @@ -156,14 +156,13 @@ func FeatureContext(s *godog.Suite) { } func deleteNamespaceIfExists(namespace string) { - if ok, er := framework.IsNamespace(namespace); er != nil { - framework.GetLogger(namespace).Errorf("Error while checking namespace: %v", er) - } else if ok { + framework.OperateOnNamespaceIfExists(namespace, func(namespace string) error { framework.GetLogger(namespace).Infof("Delete created namespace %s", namespace) if e := framework.DeleteNamespace(namespace); e != nil { - framework.GetLogger(namespace).Errorf("Error while deleting the namespace: %v", e) + return fmt.Errorf("Error while deleting the namespace: %v", e) } - } + return nil + }) } func matchingFeature(tags string, features []*gherkin.Feature) bool { diff --git a/bddframework/steps/cli.go b/bddframework/steps/cli.go deleted file mode 100644 index f2ea33f7a..000000000 --- a/bddframework/steps/cli.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2019 Red Hat, Inc. and/or its affiliates -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -package steps - -import ( - "path/filepath" - - "github.com/cucumber/godog" - "github.com/kiegroup/kogito-cloud-operator/test/framework" -) - -// RegisterCliSteps register all CLI steps existing -func registerCliSteps(s *godog.Suite, data *Data) { - s.Step(`^CLI create namespace$`, data.cliCreateNamespace) - s.Step(`^CLI use namespace$`, data.cliUseNamespace) - - s.Step(`^CLI install Kogito operator$`, data.cliInstallOperator) - s.Step(`^CLI install Kogito Data Index with (\d+) replicas$`, data.cliInstallDataIndexWithReplicas) - s.Step(`^CLI install Kogito Jobs Service with (\d+) replicas$`, data.cliInstallKogitoJobsServiceWithReplicas) - s.Step(`^CLI install Kogito Jobs Service with persistence and (\d+) replicas$`, data.cliInstallKogitoJobsServiceWithPersistenceAndReplicas) - s.Step(`^CLI install Kogito Infra Infinispan$`, data.cliInstallKogitoInfraInfinispan) - s.Step(`^CLI install Kogito Infra Kafka$`, data.cliInstallKogitoInfraKafka) - s.Step(`^CLI install Kogito Infra Keycloak$`, data.cliInstallKogitoInfraKeycloak) - - s.Step(`^CLI remove Kogito Infra Infinispan$`, data.cliRemoveKogitoInfraInfinispan) - s.Step(`^CLI remove Kogito Infra Kafka$`, data.cliRemoveKogitoInfraKafka) - s.Step(`^CLI remove Kogito Infra Keycloak$`, data.cliRemoveKogitoInfraKeycloak) - - s.Step(`^CLI deploy quarkus example service "([^"]*)" with native "([^"]*)"$`, data.cliDeployQuarkusExampleServiceWithNative) - s.Step(`^CLI deploy quarkus example service "([^"]*)" with persistence enabled and native "([^"]*)"$`, data.cliDeployQuarkusExampleServiceWithPersistenceAndNative) - s.Step(`^CLI deploy spring boot example service "([^"]*)"$`, data.cliDeploySpringBootExampleService) - s.Step(`^CLI deploy spring boot example service "([^"]*)" with persistence enabled$`, data.cliDeploySpringBootExampleServiceWithPersistence) -} - -// cliCreateNamespace create a namespace with the CLI -func (data *Data) cliCreateNamespace() error { - _, err := framework.ExecuteCliCommand(data.Namespace, "new-project", data.Namespace) - return err -} - -// cliUseNamespace use an existing namespace with the CLI -func (data *Data) cliUseNamespace() error { - _, err := framework.ExecuteCliCommand(data.Namespace, "use-project", data.Namespace) - return err -} - -// cliInstallOperator install the Kogito Operator with the CLI -func (data *Data) cliInstallOperator() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "install", "operator") - return err -} - -func (data *Data) cliDeployQuarkusExampleServiceWithNative(contextDir, native string) error { - return framework.CliDeployQuarkusExample(data.Namespace, filepath.Base(contextDir), contextDir, native == "enabled", false) -} - -func (data *Data) cliDeployQuarkusExampleServiceWithPersistenceAndNative(contextDir, native string) error { - return framework.CliDeployQuarkusExample(data.Namespace, filepath.Base(contextDir), contextDir, native == "enabled", true) -} - -func (data *Data) cliDeploySpringBootExampleService(contextDir string) error { - return framework.CliDeploySpringBootExample(data.Namespace, filepath.Base(contextDir), contextDir, false) -} - -func (data *Data) cliDeploySpringBootExampleServiceWithPersistence(contextDir string) error { - return framework.CliDeploySpringBootExample(data.Namespace, filepath.Base(contextDir), contextDir, true) -} - -func (data *Data) cliInstallDataIndexWithReplicas(replicas int) error { - return framework.CliInstallDataIndex(data.Namespace, replicas) -} - -func (data *Data) cliInstallKogitoJobsServiceWithReplicas(replicas int) error { - return framework.CliInstallKogitoJobsService(data.Namespace, replicas, false) -} - -func (data *Data) cliInstallKogitoJobsServiceWithPersistenceAndReplicas(replicas int) error { - return framework.CliInstallKogitoJobsService(data.Namespace, replicas, true) -} - -func (data *Data) cliInstallKogitoInfraInfinispan() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "install", "infinispan") - return err -} - -func (data *Data) cliInstallKogitoInfraKafka() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "install", "kafka") - return err -} - -func (data *Data) cliInstallKogitoInfraKeycloak() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "install", "keycloak") - return err -} - -func (data *Data) cliRemoveKogitoInfraInfinispan() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "remove", "infinispan") - return err -} - -func (data *Data) cliRemoveKogitoInfraKafka() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "remove", "kafka") - return err -} - -func (data *Data) cliRemoveKogitoInfraKeycloak() error { - _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "remove", "keycloak") - return err -} diff --git a/bddframework/steps/data.go b/bddframework/steps/data.go index e071d5777..35e0a175b 100644 --- a/bddframework/steps/data.go +++ b/bddframework/steps/data.go @@ -16,6 +16,7 @@ package steps import ( "fmt" + "strings" "time" "github.com/cucumber/godog" @@ -31,7 +32,6 @@ type Data struct { // RegisterAllSteps register all steps available to the test suite func (data *Data) RegisterAllSteps(s *godog.Suite) { - registerCliSteps(s, data) registerGraphQLSteps(s, data) registerHTTPSteps(s, data) registerKogitoAppSteps(s, data) @@ -54,9 +54,18 @@ func (data *Data) BeforeScenario(s interface{}) { // AfterScenario executes some actions on data after a scenario is finished func (data *Data) AfterScenario(s interface{}, err error) { - framework.StopPodLogCollector(data.Namespace) - framework.FlushLogger(data.Namespace) - framework.BumpEvents(data.Namespace) + framework.OperateOnNamespaceIfExists(data.Namespace, func(namespace string) error { + if err := framework.StopPodLogCollector(namespace); err != nil { + framework.GetMainLogger().Errorf("Error stopping log collector on namespace %s: %v", namespace, err) + } + if err := framework.FlushLogger(namespace); err != nil { + framework.GetMainLogger().Errorf("Error flushing running logs for namespace %s: %v", namespace, err) + } + if err := framework.BumpEvents(data.Namespace); err != nil { + framework.GetMainLogger().Errorf("Error bumping events for namespace %s: %v", namespace, err) + } + return nil + }) logScenarioDuration(data, s) handleScenarioResult(data, s, err) @@ -69,7 +78,8 @@ func logScenarioDuration(data *Data, s interface{}) { } func handleScenarioResult(data *Data, s interface{}, err error) { - newLogFolderName := fmt.Sprintf("%s - %s", framework.GetScenarioName(s), data.Namespace) + scenarioName := strings.ReplaceAll(framework.GetScenarioName(s), "/", "_") + newLogFolderName := fmt.Sprintf("%s - %s", scenarioName, data.Namespace) if err != nil { framework.GetLogger(data.Namespace).Errorf("Error in scenario '%s': %v", framework.GetScenarioName(s), err) diff --git a/bddframework/steps/graphql.go b/bddframework/steps/graphql.go index 0ef88320e..a8b54a406 100644 --- a/bddframework/steps/graphql.go +++ b/bddframework/steps/graphql.go @@ -26,11 +26,11 @@ import ( // registerHTTPSteps register all HTTP steps existing func registerGraphQLSteps(s *godog.Suite, data *Data) { - s.Step(`^GraphQL request on service "([^"]*)" is successful within (\d+) minutes with path "([^"]*)" and query:$`, data.graphqlRequestOnServiceWithPathAndBodyIsSuccessfulWithinMinutes) - s.Step(`^GraphQL request on Data Index service returns ProcessInstances processName "([^"]*)" within (\d+) minutes$`, data.graphqlProcessNameRequestOnDataIndexIsSuccessfulWithinMinutes) + s.Step(`^GraphQL request on service "([^"]*)" is successful within (\d+) minutes with path "([^"]*)" and query:$`, data.graphqlRequestOnServiceIsSuccessfulWithinMinutesWithPathAndQuery) + s.Step(`^GraphQL request on Data Index service returns ProcessInstances processName "([^"]*)" within (\d+) minutes$`, data.graphqlRequestOnDataIndexReturnsProcessInstancesProcessNameWithinMinutes) } -func (data *Data) graphqlRequestOnServiceWithPathAndBodyIsSuccessfulWithinMinutes(serviceName string, timeoutInMin int, path string, query *gherkin.DocString) error { +func (data *Data) graphqlRequestOnServiceIsSuccessfulWithinMinutesWithPathAndQuery(serviceName string, timeoutInMin int, path string, query *gherkin.DocString) error { framework.GetLogger(data.Namespace).Debugf("graphqlRequestOnServiceWithPathAndBodyIsSuccessfulWithinMinutes with service %s, path %s, query %s and timeout %d", serviceName, path, query, timeoutInMin) routeURI, err := framework.WaitAndRetrieveRouteURI(data.Namespace, serviceName) if err != nil { @@ -39,7 +39,7 @@ func (data *Data) graphqlRequestOnServiceWithPathAndBodyIsSuccessfulWithinMinute return framework.WaitForSuccessfulGraphQLRequest(data.Namespace, routeURI, path, query.Content, timeoutInMin) } -func (data *Data) graphqlProcessNameRequestOnDataIndexIsSuccessfulWithinMinutes(processName string, timeoutInMin int) error { +func (data *Data) graphqlRequestOnDataIndexReturnsProcessInstancesProcessNameWithinMinutes(processName string, timeoutInMin int) error { query := getProcessInstancesNameQuery path := "graphql" serviceName := infrastructure.DefaultDataIndexName diff --git a/bddframework/steps/kogitoapp.go b/bddframework/steps/kogitoapp.go index 54734288b..ccf40f378 100644 --- a/bddframework/steps/kogitoapp.go +++ b/bddframework/steps/kogitoapp.go @@ -19,6 +19,8 @@ import ( "github.com/cucumber/godog" "github.com/cucumber/godog/gherkin" + "github.com/kiegroup/kogito-cloud-operator/pkg/apis/app/v1alpha1" + "github.com/kiegroup/kogito-cloud-operator/pkg/util" "github.com/kiegroup/kogito-cloud-operator/test/framework" "github.com/rdumont/assistdog" ) @@ -28,12 +30,12 @@ var assist = assistdog.NewDefault() // RegisterCliSteps register all CLI steps existing func registerKogitoAppSteps(s *godog.Suite, data *Data) { // Deploy steps - s.Step(`^Deploy quarkus example service "([^"]*)" with native "([^"]*)"$`, data.deployQuarkusExampleServiceWithNative) - s.Step(`^Deploy quarkus example service "([^"]*)" with native "([^"]*)" and labels$`, data.deployQuarkusExampleServiceWithNativeAndLabels) - s.Step(`^Deploy quarkus example service "([^"]*)" with persistence enabled and native "([^"]*)"$`, data.deployQuarkusExampleServiceWithPersistenceAndNative) - s.Step(`^Deploy quarkus example service "([^"]*)" with persistence enabled and native "([^"]*)" and events "([^"]*)"$`, data.deployQuarkusExampleServiceWithPersistenceAndNativeAndEvents) - s.Step(`^Deploy spring boot example service "([^"]*)"$`, data.deploySpringBootExampleService) - s.Step(`^Deploy spring boot example service "([^"]*)" with persistence enabled$`, data.deploySpringBootExampleServiceWithPersistence) + s.Step(`^"([^"]*)" deploy quarkus example service "([^"]*)" with native "([^"]*)"$`, data.deployQuarkusExampleServiceWithNative) + s.Step(`^"([^"]*)" deploy quarkus example service "([^"]*)" with native "([^"]*)" and labels$`, data.deployQuarkusExampleServiceWithNativeAndLabels) + s.Step(`^"([^"]*)" deploy quarkus example service "([^"]*)" with native "([^"]*)" and persistence$`, data.deployQuarkusExampleServiceWithNativeAndPersistence) + s.Step(`^"([^"]*)" deploy quarkus example service "([^"]*)" with native "([^"]*)" and persistence and events$`, data.deployQuarkusExampleServiceWithNativeAndPersistenceAndEvents) + s.Step(`^"([^"]*)" deploy spring boot example service "([^"]*)"$`, data.deploySpringBootExampleService) + s.Step(`^"([^"]*)" deploy spring boot example service "([^"]*)" with persistence$`, data.deploySpringBootExampleServiceWithPersistence) // Build steps s.Step(`^Build "([^"]*)" is complete after (\d+) minutes$`, data.buildIsCompleteAfterMinutes) @@ -49,32 +51,86 @@ func registerKogitoAppSteps(s *godog.Suite, data *Data) { } // Deploy service steps -func (data *Data) deployQuarkusExampleServiceWithNative(contextDir, native string) error { - return framework.DeployQuarkusExample(data.Namespace, filepath.Base(contextDir), contextDir, native == "enabled", false, false, nil) +func (data *Data) deployQuarkusExampleServiceWithNative(installerType, contextDir, native string) error { + return framework.DeployExample(data.Namespace, framework.MustParseInstallerType(installerType), + framework.KogitoAppDeployment{ + AppName: filepath.Base(contextDir), + ContextDir: contextDir, + Runtime: v1alpha1.QuarkusRuntimeType, + Native: util.MustParseBool(native), + Persistence: false, + Events: false, + Labels: nil, + }) } -func (data *Data) deployQuarkusExampleServiceWithNativeAndLabels(contextDir, native string, dt *gherkin.DataTable) error { +func (data *Data) deployQuarkusExampleServiceWithNativeAndLabels(installerType, contextDir, native string, dt *gherkin.DataTable) error { labels, err := assist.ParseMap(dt) if err != nil { return err } - return framework.DeployQuarkusExample(data.Namespace, filepath.Base(contextDir), contextDir, native == "enabled", false, false, labels) + return framework.DeployExample(data.Namespace, framework.MustParseInstallerType(installerType), + framework.KogitoAppDeployment{ + AppName: filepath.Base(contextDir), + ContextDir: contextDir, + Runtime: v1alpha1.QuarkusRuntimeType, + Native: util.MustParseBool(native), + Persistence: false, + Events: false, + Labels: labels, + }) } -func (data *Data) deployQuarkusExampleServiceWithPersistenceAndNative(contextDir, native string) error { - return framework.DeployQuarkusExample(data.Namespace, filepath.Base(contextDir), contextDir, native == "enabled", true, false, nil) +func (data *Data) deployQuarkusExampleServiceWithNativeAndPersistence(installerType, contextDir, native string) error { + return framework.DeployExample(data.Namespace, framework.MustParseInstallerType(installerType), + framework.KogitoAppDeployment{ + AppName: filepath.Base(contextDir), + ContextDir: contextDir, + Runtime: v1alpha1.QuarkusRuntimeType, + Native: util.MustParseBool(native), + Persistence: true, + Events: false, + Labels: nil, + }) } -func (data *Data) deployQuarkusExampleServiceWithPersistenceAndNativeAndEvents(contextDir, native, events string) error { - return framework.DeployQuarkusExample(data.Namespace, filepath.Base(contextDir), contextDir, native == "enabled", true, events == "enabled", nil) +func (data *Data) deployQuarkusExampleServiceWithNativeAndPersistenceAndEvents(installerType, contextDir, native string) error { + return framework.DeployExample(data.Namespace, framework.MustParseInstallerType(installerType), + framework.KogitoAppDeployment{ + AppName: filepath.Base(contextDir), + ContextDir: contextDir, + Runtime: v1alpha1.QuarkusRuntimeType, + Native: util.MustParseBool(native), + Persistence: true, + Events: true, + Labels: nil, + }) } -func (data *Data) deploySpringBootExampleService(contextDir string) error { - return framework.DeploySpringBootExample(data.Namespace, filepath.Base(contextDir), contextDir, false, false, nil) +func (data *Data) deploySpringBootExampleService(installerType, contextDir string) error { + return framework.DeployExample(data.Namespace, framework.MustParseInstallerType(installerType), + framework.KogitoAppDeployment{ + AppName: filepath.Base(contextDir), + ContextDir: contextDir, + Runtime: v1alpha1.SpringbootRuntimeType, + Native: false, + Persistence: false, + Events: false, + Labels: nil, + }) } -func (data *Data) deploySpringBootExampleServiceWithPersistence(contextDir string) error { - return framework.DeploySpringBootExample(data.Namespace, filepath.Base(contextDir), contextDir, true, false, nil) +func (data *Data) deploySpringBootExampleServiceWithPersistence(installerType, contextDir string) error { + return framework.DeployExample(data.Namespace, framework.MustParseInstallerType(installerType), + framework.KogitoAppDeployment{ + AppName: filepath.Base(contextDir), + ContextDir: contextDir, + Runtime: v1alpha1.SpringbootRuntimeType, + Native: false, + Persistence: true, + Events: false, + Labels: nil, + }) } // Build steps diff --git a/bddframework/steps/kogitodataindex.go b/bddframework/steps/kogitodataindex.go index 0bb98c159..464088639 100644 --- a/bddframework/steps/kogitodataindex.go +++ b/bddframework/steps/kogitodataindex.go @@ -20,12 +20,12 @@ import ( ) func registerKogitoDataIndexServiceSteps(s *godog.Suite, data *Data) { - s.Step(`^Install Kogito Data Index with (\d+) replicas$`, data.deployKogitoDataIndexServiceWithReplicas) + s.Step(`^"([^"]*)" install Kogito Data Index with (\d+) replicas$`, data.installKogitoDataIndexServiceWithReplicas) s.Step(`^Kogito Data Index has (\d+) pods running within (\d+) minutes$`, data.kogitoDataIndexHasPodsRunningWithinMinutes) } -func (data *Data) deployKogitoDataIndexServiceWithReplicas(replicas int) error { - return framework.DeployKogitoDataIndexService(data.Namespace, replicas) +func (data *Data) installKogitoDataIndexServiceWithReplicas(installerType string, replicas int) error { + return framework.InstallKogitoDataIndexService(data.Namespace, framework.MustParseInstallerType(installerType), replicas) } func (data *Data) kogitoDataIndexHasPodsRunningWithinMinutes(podNb, timeoutInMin int) error { diff --git a/bddframework/steps/kogitoinfra.go b/bddframework/steps/kogitoinfra.go index d6abc4fa0..010677c21 100644 --- a/bddframework/steps/kogitoinfra.go +++ b/bddframework/steps/kogitoinfra.go @@ -21,67 +21,24 @@ import ( // registerKogitoInfraSteps register all Kogito Infra steps existing func registerKogitoInfraSteps(s *godog.Suite, data *Data) { - s.Step(`^Install Kogito Infra Infinispan$`, data.installKogitoInfraInfinispan) - s.Step(`^Install Kogito Infra Kafka$`, data.installKogitoInfraKafka) - s.Step(`^Install Kogito Infra Keycloak$`, data.installKogitoInfraKeycloak) - - s.Step(`^Remove Kogito Infra Infinispan$`, data.removeKogitoInfraInfinispan) - s.Step(`^Remove Kogito Infra Kafka$`, data.removeKogitoInfraKafka) - s.Step(`^Remove Kogito Infra Keycloak$`, data.removeKogitoInfraKeycloak) - - s.Step(`^Kogito Infra Infinispan should be running within (\d+) minutes$`, data.kogitoInfraInfinispanShouldBeRunningWithinMinutes) - s.Step(`^Kogito Infra Kafka should be running within (\d+) minutes$`, data.kogitoInfraKafkaShouldBeRunningWithinMinutes) - s.Step(`^Kogito Infra Keycloak should be running within (\d+) minutes$`, data.kogitoInfraKeycloakShouldBeRunningWithinMinutes) - - s.Step(`^Kogito Infra Infinispan should NOT be running within (\d+) minutes$`, data.kogitoInfraInfinispanShouldNOTBeRunningWithinMinutes) - s.Step(`^Kogito Infra Kafka should NOT be running within (\d+) minutes$`, data.kogitoInfraKafkaShouldNOTBeRunningWithinMinutes) - s.Step(`^Kogito Infra Keycloak should NOT be running within (\d+) minutes$`, data.kogitoInfraKeycloakShouldNOTBeRunningWithinMinutes) -} - -func (data *Data) installKogitoInfraInfinispan() error { - return framework.InstallKogitoInfraInfinispan(data.Namespace) -} - -func (data *Data) installKogitoInfraKafka() error { - return framework.InstallKogitoInfraKafka(data.Namespace) -} - -func (data *Data) installKogitoInfraKeycloak() error { - return framework.InstallKogitoInfraKeycloak(data.Namespace) -} - -func (data *Data) removeKogitoInfraInfinispan() error { - return framework.RemoveKogitoInfraInfinispan(data.Namespace) -} - -func (data *Data) removeKogitoInfraKafka() error { - return framework.RemoveKogitoInfraKafka(data.Namespace) -} - -func (data *Data) removeKogitoInfraKeycloak() error { - return framework.RemoveKogitoInfraKeycloak(data.Namespace) -} - -func (data *Data) kogitoInfraInfinispanShouldBeRunningWithinMinutes(timeoutInMin int) error { - return framework.WaitForKogitoInfraInfinispan(data.Namespace, true, timeoutInMin) -} - -func (data *Data) kogitoInfraKafkaShouldBeRunningWithinMinutes(timeoutInMin int) error { - return framework.WaitForKogitoInfraKafka(data.Namespace, true, timeoutInMin) + s.Step(`^"([^"]*)" install Kogito Infra "([^"]*)"$`, data.installKogitoInfra) + s.Step(`^"([^"]*)" remove Kogito Infra "([^"]*)"$`, data.removeKogitoInfra) + s.Step(`^Kogito Infra "([^"]*)" should be running within (\d+) minutes$`, data.kogitoInfraShouldBeRunningWithinMinutes) + s.Step(`^Kogito Infra "([^"]*)" should NOT be running within (\d+) minutes$`, data.kogitoInfraShouldNOTBeRunningWithinMinutes) } -func (data *Data) kogitoInfraKeycloakShouldBeRunningWithinMinutes(timeoutInMin int) error { - return framework.WaitForKogitoInfraKeycloak(data.Namespace, true, timeoutInMin) +func (data *Data) installKogitoInfra(installerType, component string) error { + return framework.InstallKogitoInfraComponent(data.Namespace, framework.MustParseInstallerType(installerType), framework.ParseKogitoInfraComponent(component)) } -func (data *Data) kogitoInfraInfinispanShouldNOTBeRunningWithinMinutes(timeoutInMin int) error { - return framework.WaitForKogitoInfraInfinispan(data.Namespace, false, timeoutInMin) +func (data *Data) removeKogitoInfra(installerType, component string) error { + return framework.RemoveKogitoInfraComponent(data.Namespace, framework.MustParseInstallerType(installerType), framework.ParseKogitoInfraComponent(component)) } -func (data *Data) kogitoInfraKafkaShouldNOTBeRunningWithinMinutes(timeoutInMin int) error { - return framework.WaitForKogitoInfraKafka(data.Namespace, false, timeoutInMin) +func (data *Data) kogitoInfraShouldBeRunningWithinMinutes(component string, timeoutInMin int) error { + return framework.WaitForKogitoInfraComponent(data.Namespace, framework.ParseKogitoInfraComponent(component), true, timeoutInMin) } -func (data *Data) kogitoInfraKeycloakShouldNOTBeRunningWithinMinutes(timeoutInMin int) error { - return framework.WaitForKogitoInfraKeycloak(data.Namespace, false, timeoutInMin) +func (data *Data) kogitoInfraShouldNOTBeRunningWithinMinutes(component string, timeoutInMin int) error { + return framework.WaitForKogitoInfraComponent(data.Namespace, framework.ParseKogitoInfraComponent(component), false, timeoutInMin) } diff --git a/bddframework/steps/kogitojobsservice.go b/bddframework/steps/kogitojobsservice.go index a8b32c613..b300748ad 100644 --- a/bddframework/steps/kogitojobsservice.go +++ b/bddframework/steps/kogitojobsservice.go @@ -21,18 +21,18 @@ import ( // RegisterCliSteps register all CLI steps existing func registerKogitoJobsServiceSteps(s *godog.Suite, data *Data) { - s.Step(`^Deploy Kogito Jobs Service with (\d+) replicas$`, data.deployKogitoJobsServiceWithReplicas) - s.Step(`^Deploy Kogito Jobs Service with persistence and (\d+) replicas$`, data.deployKogitoJobsServiceWithPersistenceAndReplicas) + s.Step(`^"([^"]*)" install Kogito Jobs Service with (\d+) replicas$`, data.installKogitoJobsServiceWithReplicas) + s.Step(`^"([^"]*)" install Kogito Jobs Service with (\d+) replicas and persistence$`, data.installKogitoJobsServiceWithReplicasAndPersistence) s.Step(`^Kogito Jobs Service has (\d+) pods running within (\d+) minutes$`, data.kogitoJobsServiceHasPodsRunningWithinMinutes) s.Step(`^Scale Kogito Jobs Service to (\d+) pods within (\d+) minutes$`, data.scaleKogitoJobsServiceToPodsWithinMinutes) } -func (data *Data) deployKogitoJobsServiceWithReplicas(replicas int) error { - return framework.DeployKogitoJobsService(data.Namespace, replicas, false) +func (data *Data) installKogitoJobsServiceWithReplicas(installerType string, replicas int) error { + return framework.InstallKogitoJobsService(data.Namespace, framework.MustParseInstallerType(installerType), replicas, false) } -func (data *Data) deployKogitoJobsServiceWithPersistenceAndReplicas(replicas int) error { - return framework.DeployKogitoJobsService(data.Namespace, replicas, true) +func (data *Data) installKogitoJobsServiceWithReplicasAndPersistence(installerType string, replicas int) error { + return framework.InstallKogitoJobsService(data.Namespace, framework.MustParseInstallerType(installerType), replicas, true) } func (data *Data) kogitoJobsServiceHasPodsRunningWithinMinutes(pods, timeoutInMin int) error { diff --git a/bddframework/steps/kubernetes.go b/bddframework/steps/kubernetes.go index 971bb3758..bc18a6fed 100644 --- a/bddframework/steps/kubernetes.go +++ b/bddframework/steps/kubernetes.go @@ -25,6 +25,9 @@ import ( func registerKubernetesSteps(s *godog.Suite, data *Data) { s.Step(`^Namespace is created$`, data.namespaceIsCreated) s.Step(`^Namespace is deleted$`, data.namespaceIsDeleted) + + s.Step(`^CLI create namespace$`, data.cliCreateNamespace) + s.Step(`^CLI use namespace$`, data.cliUseNamespace) } func (data *Data) namespaceIsCreated() error { @@ -47,3 +50,13 @@ func (data *Data) namespaceIsDeleted() error { } return nil } + +func (data *Data) cliCreateNamespace() error { + _, err := framework.ExecuteCliCommand(data.Namespace, "new-project", data.Namespace) + return err +} + +func (data *Data) cliUseNamespace() error { + _, err := framework.ExecuteCliCommand(data.Namespace, "use-project", data.Namespace) + return err +} diff --git a/bddframework/steps/operator.go b/bddframework/steps/operator.go index 756b21f1f..d1867921a 100644 --- a/bddframework/steps/operator.go +++ b/bddframework/steps/operator.go @@ -27,6 +27,8 @@ func registerOperatorSteps(s *godog.Suite, data *Data) { s.Step(`^Kogito operator should be installed with dependencies$`, data.kogitoOperatorShouldBeInstalledWithDependencies) s.Step(`^Kogito Operator is deployed$`, data.kogitoOperatorIsDeployed) s.Step(`^Kogito Operator is deployed with ((?:Infinispan|Kafka|Keycloak|, | and )+) (?:operator|operators)$`, data.kogitoOperatorIsDeployedWithDependencies) + + s.Step(`^CLI install Kogito operator$`, data.cliInstallKogitoOperator) } func (data *Data) kogitoOperatorShouldBeInstalledWithDependencies() error { @@ -78,3 +80,8 @@ func (data *Data) kogitoOperatorIsDeployedWithDependencies(dependencies string) return nil } + +func (data *Data) cliInstallKogitoOperator() error { + _, err := framework.ExecuteCliCommandInNamespace(data.Namespace, "install", "operator") + return err +}