Skip to content

Commit

Permalink
[KOGITO-2123] - Remove duplicate BATS test (#169)
Browse files Browse the repository at this point in the history
Signed-off-by: spolti <fspolti@redhat.com>
  • Loading branch information
spolti authored Jun 3, 2020
1 parent 08b22ec commit 04f9b9c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 104 deletions.
91 changes: 0 additions & 91 deletions modules/kogito-data-index/tests/bats/kogito-data-index.bats
Original file line number Diff line number Diff line change
Expand Up @@ -10,101 +10,10 @@ cp $BATS_TEST_DIRNAME/../../../kogito-logging/added/logging.sh ${KOGITO_HOME}/la
load ${KOGITO_HOME}/launch/kogito-infinispan-properties.sh
load $BATS_TEST_DIRNAME/../../added/launch/kogito-data-index.sh

function setup(){
function log_error() { echo "ERROR ${1}"; }
}

teardown() {
rm -rf ${KOGITO_HOME}
}

function clear_vars() {
unset INFINISPAN_USEAUTH
unset INFINISPAN_USERNAME
unset INFINISPAN_PASSWORD
unset INFINISPAN_AUTHREALM
unset INFINISPAN_SASLMECHANISM
}

@test "check if infinispan properties is blank" {
clear_vars
local expected=" -Dquarkus.infinispan-client.use-auth=false"
configure_infinispan_props
echo "Result is ${INFINISPAN_PROPERTIES} and expected is ${expected}" >&2
[ "${expected}" = "${INFINISPAN_PROPERTIES}" ]
}

@test "check if infinispan auth is false" {
clear_vars
export INFINISPAN_USEAUTH="false"
local expected=" -Dquarkus.infinispan-client.use-auth=false"
configure_infinispan_props
echo "Result is ${INFINISPAN_PROPERTIES} and expected is ${expected}" >&2
[ "${expected}" = "${INFINISPAN_PROPERTIES}" ]
}

@test "check if infinispan has auth props" {
clear_vars
export INFINISPAN_USERNAME="developer"
export INFINISPAN_USEAUTH="true"
export INFINISPAN_PASSWORD="developer"
export INFINISPAN_AUTHREALM="default"
export INFINISPAN_SASLMECHANISM="PLAIN"

local expected=" -Dquarkus.infinispan-client.auth-username=developer -Dquarkus.infinispan-client.auth-password=developer -Dquarkus.infinispan-client.use-auth=true -Dquarkus.infinispan-client.auth-realm=default -Dquarkus.infinispan-client.sasl-mechanism=PLAIN"
configure_infinispan_props

echo "Result is ${INFINISPAN_PROPERTIES} and expected is ${expected}" >&2
[ "${expected}" = "${INFINISPAN_PROPERTIES}" ]
}

@test "setting username, useauth is true" {
clear_vars
export INFINISPAN_USERNAME="developer"
export INFINISPAN_USEAUTH="false"
local expected=" -Dquarkus.infinispan-client.auth-username=developer -Dquarkus.infinispan-client.use-auth=true"

configure_infinispan_props

echo "Result is ${INFINISPAN_PROPERTIES} and expected is ${expected}" >&2
[ "${expected}" = "${INFINISPAN_PROPERTIES}" ]
}

@test "when use auth is set to nonsense and no credentials" {
clear_vars
export INFINISPAN_USEAUTH="dsadsadasdsa"
local expected=" -Dquarkus.infinispan-client.use-auth=false"

configure_infinispan_props

echo "Result is ${INFINISPAN_PROPERTIES} and expected is ${expected}" >&2
[ "${expected}" = "${INFINISPAN_PROPERTIES}" ]
}

@test "when use auth is set to nonsense and has credentials" {
clear_vars
export INFINISPAN_USEAUTH="dsadsadasdsa"
export INFINISPAN_USERNAME="developer"
local expected=" -Dquarkus.infinispan-client.auth-username=developer -Dquarkus.infinispan-client.use-auth=true"

configure_infinispan_props

echo "Result is ${INFINISPAN_PROPERTIES} and expected is ${expected}" >&2
[ "${expected}" = "${INFINISPAN_PROPERTIES}" ]
}

@test "when use auth is set to true and no credentials" {
clear_vars
export INFINISPAN_USEAUTH="true"

run configure_infinispan_props

expected="ERROR Flag INFINISPAN_USEAUTH set to true, but no username or password informed. Please use INFINISPAN_USERNAME and INFINISPAN_PASSWORD variables to set the right credentials."
echo "Result is ${output} and expected is ${expected}"
echo "Expected status is 1, outcome status is ${status}"
[ "$status" -eq 1 ]
[ "${output}" = "${expected}" ]
}

@test "http port configuration default value" {
configure_data_index_http_port
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ cp $BATS_TEST_DIRNAME/../../../kogito-logging/added/logging.sh ${KOGITO_HOME}/la
# import
load $BATS_TEST_DIRNAME/../../added/kogito-infinispan-properties.sh

function setup(){
function log_error() { echo "ERROR ${1}"; }
}

function clear_vars() {
unset INFINISPAN_USEAUTH
unset INFINISPAN_USERNAME
Expand Down Expand Up @@ -88,9 +92,13 @@ function clear_vars() {
@test "when use auth is set to true and no credentials" {
clear_vars
export INFINISPAN_USEAUTH="true"

run configure_infinispan_props
# exit
echo "Status: ${status}"

expected="ERROR Flag INFINISPAN_USEAUTH set to true, but no username or password informed. Please use INFINISPAN_USERNAME and INFINISPAN_PASSWORD variables to set the right credentials."
echo "Result is ${output} and expected is ${expected}"
echo "Expected status is 1, outcome status is ${status}"
[ "$status" -eq 1 ]
[ "${output}" = "${expected}" ]
}

13 changes: 2 additions & 11 deletions modules/kogito-jobs-service/tests/bats/kogito-jobs-service.bats
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ teardown() {
rm -rf ${KOGITO_HOME}
}


@test "test enable persistence without set infinispan server list" {
export ENABLE_PERSISTENCE="true"
run configure_jobs_service
Expand All @@ -25,7 +24,6 @@ teardown() {
[ "${output}" = "${expected}" ]
}


@test "check if the backoffRetryMillis is correctly set" {
export BACKOFF_RETRY="2000"
configure_jobs_service
Expand All @@ -34,7 +32,6 @@ teardown() {
[ "${KOGITO_JOBS_PROPS}" = "${expected}" ]
}


@test "check if the maxIntervalLimitToRetryMillis is correctly set" {
export MAX_INTERVAL_LIMIT_RETRY="8000"
configure_jobs_service
Expand All @@ -43,7 +40,6 @@ teardown() {
[ "${KOGITO_JOBS_PROPS}" = "${expected}" ]
}


@test "check if the maxIntervalLimitToRetryMillis and backoffRetryMillis are correctly set" {
export MAX_INTERVAL_LIMIT_RETRY="8000"
export BACKOFF_RETRY="2000"
Expand All @@ -53,18 +49,13 @@ teardown() {
[ "${KOGITO_JOBS_PROPS}" = "${expected}" ]
}


@test "check if the persistence is correctly configured with auth" {
export ENABLE_PERSISTENCE="true"
export INFINISPAN_CLIENT_SERVER_LIST="localhost:11222"
export INFINISPAN_USEAUTH="true"
export INFINISPAN_USERNAME="nevermind"
export INFINISPAN_PASSWORD="impossible2gues"
configure_jobs_service
configure_infinispan_props

result="${KOGITO_JOBS_PROPS} ${INFINISPAN_PROPERTIES}"
expected=" -Dkogito.jobs-service.persistence=infinispan -Dquarkus.infinispan-client.server-list=localhost:11222 -Dquarkus.infinispan-client.auth-username=nevermind -Dquarkus.infinispan-client.auth-password=impossible2gues -Dquarkus.infinispan-client.use-auth=true"
result="${KOGITO_JOBS_PROPS}"
expected=" -Dkogito.jobs-service.persistence=infinispan -Dquarkus.infinispan-client.server-list=localhost:11222"

echo "Result is ${result} and expected is ${expected}"
[ "${result}" = "${expected}" ]
Expand Down

0 comments on commit 04f9b9c

Please sign in to comment.