Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #324 -Migrate e2e tests to BDD test #432

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 100 additions & 0 deletions .github/workflows/e2e-bdd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: E2E checks

on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
paths-ignore:
- "LICENSE"
- "**/.gitignore"
- "**.md"
- "**.adoc"
- "*.txt"
- "docsimg/**"
- ".ci/jenkins/**"

env:
GO_VERSION: 1.21
PYTHON_VERSION: "3.10"
KIND_VERSION: v0.20.0
OPERATOR_IMAGE_NAME: "127.0.0.1:5001/kogito-serverless-operator:0.0.1"

jobs:
e2e:
concurrency:
group: sonataflow-operator-e2e-tests-${{ github.head_ref }}
cancel-in-progress: true
timeout-minutes: 120
runs-on: ubuntu-latest
name: End-to-end tests (Kind)
steps:
- name: Install dependencies
run: |
sudo apt-get update && \
sudo apt-get -y install --no-install-recommends \
btrfs-progs \
libgpgme-dev \
libbtrfs-dev \
libdevmapper-dev \
libkrb5-dev
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}

- name: Install Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true

- name: Setup Python for cekit
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_VERSION }}
cache-dependency-path: images/requirements.txt
cache: 'pip'

- name: Install Cekit
run: |
pip install -r images/requirements.txt
cekit --version

- name: Setup Kind cluster
run: make KIND_VERSION=${{ env.KIND_VERSION }} create-cluster

- name: Set OPERATOR_IMAGE_NAME to point to Kind's local registry
run: echo "OPERATOR_IMAGE_NAME=${{ env.OPERATOR_IMAGE_NAME }}" >> $GITHUB_ENV

- name: Build and load operator image
run: |
make
make container-build BUILDER=docker IMG=${{ env.OPERATOR_IMAGE_NAME }}
kind load docker-image ${{ env.OPERATOR_IMAGE_NAME }}

- name: Check pods
run: |
kubectl version
kubectl get pods -A

- name: Run tests
run: make run-tests cr_deployment_only=true local_cluster=true operator_image_tag=${{ env.OPERATOR_IMAGE_NAME }}

- name: Retrieve cluster events and list pods
if: failure()
run: |
kubectl get events
kubectl get pod -A

- name: Export kind logs
if: always()
run: |
mkdir -p /tmp/kind/logs
kind export logs --loglevel=debug /tmp/kind/logs

- name: Upload kind logs
if: always()
uses: actions/upload-artifact@v3
with:
name: kind-logs-${{ env.JOB_NAME }}-${{ github.run_id }}
path: /tmp/kind/logs
retention-days: 1
7 changes: 6 additions & 1 deletion bddframework/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const (
defaultOperatorProfilingDataAccessYamlURI = "../profiling/kogito-operator-profiling-data-access.yaml"
defaultOperatorProfilingOutputFileURI = "./bdd-cover.out"

defaultKogitoExamplesURI = "https://github.com/kiegroup/kogito-examples"
defaultKogitoExamplesURI = "https://github.com/apache/incubator-kie-kogito-examples"

defaultLoadFactor = 1
defaultHTTPRetryNumber = 3
Expand Down Expand Up @@ -330,6 +330,11 @@ func GetOperatorYamlURI() string {
return env.operatorYamlURI
}

// GetPostgresYamlURI return the uri for postgres.yaml file
func GetPostgresYamlURI() string {
return "../test/testdata/persistence/postgres/01-postgres.yaml"
}

// GetRhpamOperatorYamlURI return the uri for rhpam-kogito-operator.yaml file
func GetRhpamOperatorYamlURI() string {
return env.rhpamOperatorYamlURI
Expand Down
5 changes: 4 additions & 1 deletion bddframework/pkg/framework/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ func WaitForFailedHTTPRequest(namespace string, requestInfo HTTPRequestInfo, tim
})
}

// TODO: implement a ExecuteHTTPRequest using a curl image, so we can query the services from within the cluster
// TODO: kubectl run -n $NS -it --rm --image=curlimages/curl curly -- http://10.96.83.64

// ExecuteHTTPRequest executes an HTTP request
func ExecuteHTTPRequest(namespace string, requestInfo HTTPRequestInfo) (*http.Response, error) {
// Setup a retry in case the first time it did not work
Expand Down Expand Up @@ -303,7 +306,7 @@ func runRequestRoutine(threadID int, waitGroup *sync.WaitGroup, client *http.Cli
results[threadID] = HTTPRequestResultSuccess
}

// IsHTTPResponseArraySize makes and checks whether an http request returns an array of a specific size
// IsHTTPResponseArraySize makes and checks whether a http request returns an array of a specific size
func IsHTTPResponseArraySize(namespace string, requestInfo HTTPRequestInfo, arraySize int) (bool, error) {
var httpResponseArray []map[string]interface{}
err := ExecuteHTTPRequestWithUnmarshalledResponse(namespace, requestInfo, &httpResponseArray)
Expand Down
2 changes: 1 addition & 1 deletion bddframework/pkg/framework/kogitojobsservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func GetKogitoJobsService(namespace string) (*v1beta1.KogitoSupportingService, e

// WaitForKogitoJobsServiceLogContainsTextWithinMinutes waits until any pods contains a text
func WaitForKogitoJobsServiceLogContainsTextWithinMinutes(namespace, logText string, timeoutInMin int) error {
return WaitForAnyPodsByDeploymentToContainTextInLog(namespace, getJobsServiceName(), logText, timeoutInMin)
return WaitForAnyPodsByDeploymentToContainTextInLog(namespace, getJobsServiceName(), getJobsServiceName(), logText, timeoutInMin)
}

func getJobsServiceName() string {
Expand Down
15 changes: 8 additions & 7 deletions bddframework/pkg/framework/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,26 @@ func WaitForAllPodsByDeploymentConfigToContainTextInLog(namespace, dcName, logTe
}

// WaitForAllPodsByDeploymentToContainTextInLog waits for pods of specified deployment to contain specified text in log
func WaitForAllPodsByDeploymentToContainTextInLog(namespace, dName, logText string, timeoutInMin int) error {
return waitForPodsByDeploymentToContainTextInLog(namespace, dName, logText, timeoutInMin, checkAllPodsContainingTextInLog)
func WaitForAllPodsByDeploymentToContainTextInLog(namespace, dName, dContainerName, logText string, timeoutInMin int) error {
return waitForPodsByDeploymentToContainTextInLog(namespace, dName, dContainerName, logText, timeoutInMin, checkAllPodsContainingTextInLog)
}

// WaitForAnyPodsByDeploymentToContainTextInLog waits for pods of specified deployment to contain specified text in log
func WaitForAnyPodsByDeploymentToContainTextInLog(namespace, dName, logText string, timeoutInMin int) error {
return waitForPodsByDeploymentToContainTextInLog(namespace, dName, logText, timeoutInMin, checkAnyPodsContainingTextInLog)
func WaitForAnyPodsByDeploymentToContainTextInLog(namespace, dName, dContainerName, logText string, timeoutInMin int) error {
return waitForPodsByDeploymentToContainTextInLog(namespace, dName, dContainerName, logText, timeoutInMin, checkAnyPodsContainingTextInLog)
}

func waitForPodsByDeploymentToContainTextInLog(namespace, dName, logText string, timeoutInMin int, predicate func(string, []corev1.Pod, string, string) (bool, error)) error {
func waitForPodsByDeploymentToContainTextInLog(namespace, dName, dContainerName, logText string, timeoutInMin int, predicate func(string, []corev1.Pod, string, string) (bool, error)) error {
return WaitForOnOpenshift(namespace, fmt.Sprintf("Pods for deployment '%s' contain text '%s'", dName, logText), timeoutInMin,
func() (bool, error) {
pods, err := GetPodsByDeployment(namespace, dName)
if err != nil {
return false, err
}

// Container name is equal to deployment config name
return predicate(namespace, pods, dName, logText)
// Container name is equal to deployment config name, for sonataflow it is workflow so I added variable that can be set
// TODO: Extract this to sonataflow.go as this is so far only useful for us
return predicate(namespace, pods, dContainerName, logText)
}, CheckPodsByDeploymentInError(namespace, dName))
}

Expand Down
4 changes: 2 additions & 2 deletions bddframework/pkg/framework/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ package framework

import (
"fmt"
"io/ioutil"
"os"
"strings"

"github.com/apache/incubator-kie-kogito-serverless-operator/bddframework/pkg/config"
Expand Down Expand Up @@ -165,7 +165,7 @@ func (mvnCmd *mavenCommandStruct) setSettingsXML() error {
}

// Create settings.xml in directory
if err := ioutil.WriteFile(fmt.Sprintf("%s/settings.xml", mvnCmd.directory), []byte(settings.Generate()), 0644); err != nil {
if err := os.WriteFile(fmt.Sprintf("%s/settings.xml", mvnCmd.directory), []byte(settings.Generate()), 0644); err != nil {
return err
}

Expand Down
181 changes: 0 additions & 181 deletions bddframework/pkg/framework/postgresql.go

This file was deleted.

1 change: 0 additions & 1 deletion bddframework/pkg/steps/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ func (data *Data) RegisterAllSteps(ctx *godog.ScenarioContext) {
registerMavenSteps(ctx, data)
registerMongoDBSteps(ctx, data)
registerOpenShiftSteps(ctx, data)
registerPostgresqlSteps(ctx, data)
registerPrometheusSteps(ctx, data)
registerProcessSteps(ctx, data)
registerTaskSteps(ctx, data)
Expand Down
2 changes: 1 addition & 1 deletion bddframework/pkg/steps/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,5 @@ func (data *Data) deploymentHasResourcesWithinMinutes(dName string, podNb, timeo
}

func (data *Data) deploymentPodsLogContainsTextWithinMinutes(dName, logText string, timeoutInMin int) error {
return framework.WaitForAllPodsByDeploymentToContainTextInLog(data.Namespace, dName, logText, timeoutInMin)
return framework.WaitForAllPodsByDeploymentToContainTextInLog(data.Namespace, dName, dName, logText, timeoutInMin)
}
Loading
Loading