Skip to content

Commit d6feacb

Browse files
committed
Create/Delete applications
1 parent 4cc6036 commit d6feacb

File tree

5 files changed

+79
-20
lines changed

5 files changed

+79
-20
lines changed

adc.sh

+14
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,20 @@ register application_list List all applications available on the controller
509509
describe application_list << EOF
510510
List all applications available on the controller. This command requires no further arguments.
511511
EOF
512+
function application_create {
513+
apiCall -X POST -d "{\"name\": \"\${n}\", \"description\": \"\"}" "/controller/restui/allApplications/createApplication?applicationType=\${t}" "$@"
514+
}
515+
register application_create Create a new application
516+
describe application_create << EOF
517+
Create a new application. Provide a name and a type (APM or WEB) as parameter.
518+
EOF
519+
function application_delete {
520+
apiCall -X POST -d "\${a}" "/controller/restui/allApplications/deleteApplication" "$@"
521+
}
522+
register application_delete Delete an application
523+
describe application_delete << EOF
524+
Delete an application. Provide application id as parameter.
525+
EOF
512526
function application_export {
513527
local APPLICATION_ID=$*
514528
if [[ $APPLICATION_ID =~ ^[0-9]+$ ]]; then

commands/application/create.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
function application_create {
4+
apiCall -X POST -d "{\"name\": \"\${n}\", \"description\": \"\"}" "/controller/restui/allApplications/createApplication?applicationType=\${t}" "$@"
5+
}
6+
7+
register application_create Create a new application
8+
9+
describe application_create << EOF
10+
Create a new application. Provide a name and a type (APM or WEB) as parameter.
11+
EOF

commands/application/delete.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
3+
function application_delete {
4+
apiCall -X POST -d "\${a}" "/controller/restui/allApplications/deleteApplication" "$@"
5+
}
6+
7+
register application_delete Delete an application
8+
9+
describe application_delete << EOF
10+
Delete an application. Provide application id as parameter.
11+
EOF

main.sh

+2
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ source ./commands/portal/login.sh
5656
source ./commands/portal/download.sh
5757

5858
source ./commands/application/list.sh
59+
source ./commands/application/create.sh
60+
source ./commands/application/delete.sh
5961
source ./commands/application/export.sh
6062

6163
source ./commands/bt/list.sh

test.sh

+41-20
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ function assert_equals {
1717
fi
1818
}
1919

20+
function assert_empty {
21+
TEST_COUNTER=$TEST_COUNTER+1
22+
if [[ -z "$1" ]]; then
23+
SUCCESS_COUNTER=$SUCCESS_COUNTER+1
24+
echo -en "\033[0;32m.\033[0m"
25+
else
26+
echo -e "\n\033[0;31mTest failed: \033[0;33m$1\033[0;31m is not an empty string."
27+
fi
28+
}
29+
2030
function assert_contains_substring {
2131
TEST_COUNTER=$TEST_COUNTER+1
2232
if [[ $2 == *$1* ]]; then
@@ -50,36 +60,47 @@ assert_contains_substring "Login Successful" "`${ADC} controller login`"
5060
assert_contains_substring "<available>true</available>" "`${ADC} controller status`"
5161
assert_regex "[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+" "`${ADC} controller version`"
5262

53-
##### List different entities #####
54-
assert_contains_substring "<applications>" "`${ADC} application list`"
55-
assert_contains_substring "<tiers>" "`${ADC} tier list -a 5`"
56-
assert_contains_substring "<business-transactions>" "`${ADC} bt list -a 5`"
57-
58-
##### Error handling #####
59-
assert_equals "Error" "`env CONFIG_HTTP_TIMEOUT=1 ./adc.sh -H 127.0.0.2:8009 controller ping`"
60-
61-
##### Database Collector Create, List, Get, Delete #####
62-
CREATE="`${ADC} dbmon create -i adc_test_collector -h localhost -n db -u user -a "Default Database Agent" -t DB2 -p 1555 -s password`"
63-
assert_contains_substring '"name" : "adc_test_collector",' "$CREATE"
64-
assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon list`"
65-
if [[ $CREATE =~ \"id\"\ \:\ ([0-9]+) ]] ; then
66-
COLLECTOR_ID=${BASH_REMATCH[1]}
67-
assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon get $COLLECTOR_ID`"
68-
assert_contains_substring '"status" : "SUCCESS",' "`${ADC} dbmon delete $COLLECTOR_ID`"
69-
fi
63+
##### Create a test application
64+
APPNAME="ADC_TEST_APPLICATION_${RANDOM}"
65+
CREATE_APPLICATION="`${ADC} application create -t APM -n "$APPNAME"`"
66+
assert_contains_substring "\"name\" : \"${APPNAME}\"," "$CREATE_APPLICATION"
67+
if [[ $CREATE_APPLICATION =~ \"id\"\ \:\ ([0-9]+) ]] ; then
68+
APPLICATION_ID=${BASH_REMATCH[1]}
69+
70+
71+
##### List different entities #####
72+
assert_contains_substring "<applications>" "`${ADC} application list`"
73+
assert_contains_substring "<tiers>" "`${ADC} tier list -a $APPLICATION_ID`"
74+
assert_contains_substring "<business-transactions>" "`${ADC} bt list -a $APPLICATION_ID`"
75+
76+
##### Database Collector Create, List, Get, Delete #####
77+
CREATE_DBMON="`${ADC} dbmon create -i adc_test_collector -h localhost -n db -u user -a "Default Database Agent" -t DB2 -p 1555 -s password`"
78+
assert_contains_substring '"name" : "adc_test_collector",' "$CREATE_DBMON"
79+
assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon list`"
80+
if [[ $CREATE_DBMON =~ \"id\"\ \:\ ([0-9]+) ]] ; then
81+
COLLECTOR_ID=${BASH_REMATCH[1]}
82+
assert_contains_substring '"name" : "adc_test_collector",' "`${ADC} dbmon get $COLLECTOR_ID`"
83+
assert_contains_substring '"status" : "SUCCESS",' "`${ADC} dbmon delete $COLLECTOR_ID`"
84+
fi
7085

86+
##### Error handling #####
87+
assert_equals "Error" "`env CONFIG_HTTP_TIMEOUT=1 ./adc.sh -H 127.0.0.2:8009 controller ping`"
88+
89+
##### Delete the test application
90+
assert_empty "`${ADC} application delete $APPLICATION_ID`"
91+
fi
7192
#### END TESTS ####
7293

7394
declare -i PERCENTAGE
7495

7596
PERCENTAGE=$((($SUCCESS_COUNTER*100)/($TEST_COUNTER)))
7697

7798
if [ $PERCENTAGE -eq 100 ]; then
78-
echo -e "\033[0;32m"
99+
echo -e "\033[0;32m"
79100
elif [ $PERCENTAGE -ge 80 ]; then
80-
echo -e "\033[0;33m"
101+
echo -e "\033[0;33m"
81102
else
82-
echo -e "\033[0;31m"
103+
echo -e "\033[0;31m"
83104
fi
84105

85106
rm $COOKIE_PATH

0 commit comments

Comments
 (0)