Skip to content

Commit 67b952c

Browse files
Refactor selenium tests
1 parent 984619d commit 67b952c

File tree

82 files changed

+3113
-1149
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

82 files changed

+3113
-1149
lines changed

deps/rabbitmq_management/selenium/README.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,34 @@ To run the tests we need:
1111

1212
All test cases and their configuration files are under the `test` folder and grouped into subfolders based on the area of functionality they are testing. For instance, under `oauth` folder, we have test cases about OAuth 2.0.
1313
Furthermore, within an area of functionality like OAuth 2.0 we want to test under different configuration.
14-
For instance under `test/oauth/with-uaa` we group all test cases which run against UAA. Whereas
15-
under `test/oauth/with-uaa-down` we group all test cases which run against a UAA which is down.
16-
17-
And under `suites` folder we have the test suites where we literally script the following:
18-
- the suite's **setup**, e.g. start RabbitMQ and UAA with a specific configuration
19-
- the path to the test cases
20-
- the path to the test case configuration
21-
- the suite's **teardown**, e.g. stop RabbitMQ and UAA
22-
- and save all logs and screen captures if any
14+
For instance under `test/oauth/with-sp-initiated` we group all test cases which run against an Authorization server via the Authorization Code Flow. Whereas under `test/oauth/with-idp-down` we group all test cases which run against an Authorization server which is down.
15+
16+
And under `suites` folder we have the test suites. A test suite is a script which executes all test cases
17+
under a folder and using a given configuration and launching a number of components the test suite depends on.
18+
19+
Some test cases only depend on RabbitMQ such as the `basic-auth.sh`. In this test suite, we specify the location of the test case relative to the `test` folder.
20+
And we call the function `run`. We always have to source the file under `bin/suite_template`.
21+
22+
```
23+
TEST_CASES_PATH=/basic-auth
24+
25+
source $SCRIPT/../bin/suite_template
26+
run
27+
````
28+
29+
When our test suite requires of other components such as UAA, we use the function call `runWith` as we see below for the test case `oauth-with-uaa.sh`. In this test case, in addition to declaring the location of the test case, we also specify the location of the configuration files required to launch the components this suite
30+
depends on. We also specify which profiles are activated which in turn defines the settings and configuration files used in the suite. And said earlier, the suite runs via the function `runWith` specifying the components that should be started and stopped and its logs captured too.
31+
32+
```
33+
TEST_CASES_PATH=/oauth/with-sp-initiated
34+
TEST_CONFIG_PATH=/oauth
35+
PROFILES="uaa uaa-oauth-provider"
36+
37+
source $SCRIPT/../bin/suite_template
38+
runWith uaa
39+
40+
```
41+
2342
2443
# How to run the tests
2544
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env bash
2+
3+
TEST_PATH=${1:?"First parameter must be the test path"}
4+
TEMPLATE_FILE_PREFIX=${2:?"Second parameter must be the template file prefix"}
5+
TEMPLATE_FILE_SUFFIX=${3:-""}
6+
TEST_PARENT_PATH="$(dirname "$TEST_PATH")"
7+
8+
find_templates_files() {
9+
find_template_files_in $TEST_PARENT_PATH
10+
find_template_files_in $TEST_PATH
11+
12+
}
13+
find_template_files_in() {
14+
15+
for file in $1/${TEMPLATE_FILE_PREFIX}.*${TEMPLATE_FILE_SUFFIX}
16+
do
17+
if [ ! -f $file ]
18+
then
19+
continue
20+
fi
21+
entry="$(basename $file)"
22+
prefix=${entry#$TEMPLATE_FILE_PREFIX.*}
23+
if [[ $prefix == $TEMPLATE_FILE_SUFFIX ]]
24+
then
25+
echo "$1/${TEMPLATE_FILE_PREFIX}.${TEMPLATE_FILE_SUFFIX}"
26+
else
27+
profiles=${prefix%.$TEMPLATE_FILE_SUFFIX}
28+
matched_entry=true
29+
for p in ${profiles//./ }
30+
do
31+
if [[ "$PROFILES" != *"$p"* && $matched_entry == true ]]; then
32+
matched_entry=false
33+
fi
34+
done
35+
if [[ $matched_entry == true ]]; then
36+
echo "$file"
37+
fi
38+
fi
39+
40+
done
41+
}
42+
43+
44+
find_templates_files
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
4+
ENV_FILE="/tmp/rabbitmq/.env"
5+
FIND_PATH=$1
6+
ENV_FILE=$2
7+
FIND_PARENT_PATH="$(dirname "$FIND_PATH")"
8+
9+
generate_env_file() {
10+
parentdir="$(dirname "$ENV_FILE")"
11+
mkdir -p $parentdir
12+
echo "" > $ENV_FILE
13+
14+
for f in $($SCRIPT/find-template-files $FIND_PATH ".env")
15+
do
16+
cat $f >> $ENV_FILE
17+
done
18+
}
19+
20+
generate_env_file
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
4+
5+
#set -x
6+
7+
KEYCLOAK_PATH=${1:?First parameter is the directory env and config files are relative to}
8+
ENV_FILE=${2:?Second parameter is a comma-separated list of .env file which has exported template variables}
9+
FINAL_CONFIG_FILE=${3:?Forth parameter is the name of the final config file. It is relative to where this script is run from}
10+
11+
source $ENV_FILE
12+
13+
echo "" > $FINAL_CONFIG_FILE
14+
15+
for f in $($SCRIPT/find-template-files $KEYCLOAK_PATH "test-realm" "json")
16+
do
17+
envsubst < $f >> $FINAL_CONFIG_FILE
18+
done
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
4+
#set -x
5+
6+
TEST_PATH=${1:?First parameter is the directory env and config files are relative to}
7+
ENV_FILE=${2:?Second parameter is a comma-separated list of .env file which has exported template variables}
8+
FINAL_CONFIG_FILE=${3:?Forth parameter is the name of the final config file. It is relative to where this script is run from}
9+
10+
source $ENV_FILE
11+
12+
echo "" > $FINAL_CONFIG_FILE
13+
14+
for f in $($SCRIPT/find-template-files $TEST_PATH "rabbitmq" "conf")
15+
do
16+
envsubst < $f >> $FINAL_CONFIG_FILE
17+
done
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env bash
2+
SCRIPT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
3+
4+
#set -x
5+
6+
UAA_PATH=${1:?First parameter is the directory env and config files are relative to}
7+
ENV_FILE=${2:?Second parameter is a comma-separated list of .env file which has exported template variables}
8+
FINAL_CONFIG_FILE=${3:?Forth parameter is the name of the final config file. It is relative to where this script is run from}
9+
10+
source $ENV_FILE
11+
12+
echo "" > $FINAL_CONFIG_FILE
13+
14+
for f in $($SCRIPT/find-template-files $UAA_PATH "uaa" "yml")
15+
do
16+
envsubst < $f >> $FINAL_CONFIG_FILE
17+
done

0 commit comments

Comments
 (0)