diff --git a/e2e-test/qa/benchmark/benchmark-search.sh b/e2e-test/qa/benchmark/benchmark-search.sh index 78aeaffc8..2f88adb58 100755 --- a/e2e-test/qa/benchmark/benchmark-search.sh +++ b/e2e-test/qa/benchmark/benchmark-search.sh @@ -2,5 +2,57 @@ set -ex echo "Benchmark Search RestAPI" -# add here content of https://git.alfresco.com/search_discovery/BuildScripts/blob/feature/search-1506/qa/benchmark/search-data.sh -# use ALFRESCO_URL for full http+alfresco+port =>http://localhost:8081 (see Makefile) \ No newline at end of file +REQ_HOST="localhost:9080" +REQ_TESTS_API="http://$REQ_HOST/alfresco-bm-manager/api/v1/tests" +TEST_NAME="DataTest" + +echo -ne "Create Test Data\n" +#Create Test +curl -s $REQ_TESTS_API -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$TEST_NAME'","description":"Data","release":"alfresco-bm-load-data-3.0.1-SNAPSHOT","schema":"11"}' + +echo -ne "Set MongoDB Data\n" +#Set Mongo DB +IP=$(hostname -I | awk '{print $1}') +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/mongo.test.host" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$IP':27017"}' + +echo -ne "Set Alfresco related attributes Data\n" +#Set Alfresco related attributes +#ALF_SERVER=${bamboo.alfresco.url} +#ALF_SERVER="ec2-34-245-148-19.eu-west-1.compute.amazonaws.com" +ALF_SERVER=$(echo $ALFRESCO_URL | cut -d '/' -f3 | cut -d ':' -f1) +ALF_PORT=$(echo $ALFRESCO_URL | cut -d ':' -f3) +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.server" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALF_SERVER'"}' +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.url" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALFRESCO_URL'/"}' +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.port" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALF_PORT'"}' + +#Set Site attribute +SITE_NAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)-Site-%s-%05d +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/load.siteFormat" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$SITE_NAME'"}' + +echo -ne "Create test instance Data\n" +#Create test instance +INSTANCE_NAME="RunTestData1" +curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$INSTANCE_NAME'"}' + +echo -ne "Start the test Data\n" +#Start the test +curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs/"$INSTANCE_NAME"/schedule" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"scheduled":0}' + +completed=-1 +# Add 0 to the completed value to ensure it's a number. +while [ $((completed+0)) -eq -1 ] +do + sleep 10 + status=`curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8'` + #log "Status: $status" + # Update the completed timestamp value (which will be -1 if the test hasn't finished yet). + completed=`echo $status | sed 's|^.*"completed" : \([^ ]*\) .*$|\1|g'` + if [ $((completed+0)) -eq -1 ] + then + # Also check the "stopped" value if it hasn't completed. + completed=`echo $status | sed 's|^.*"stopped" : \([^ ]*\) .*$|\1|g'` + fi + #log "Progress: "`echo $status | sed 's|^.*"progress" : \([^ ]*\) .*$|\1|g'` +done + +curl -s -o search_data_results.xlsx -O -J $REQ_TESTS_API"/"$TEST_NAME"/runs/"$INSTANCE_NAME"/results/xlsx" \ No newline at end of file diff --git a/e2e-test/qa/benchmark/prepare-data.sh b/e2e-test/qa/benchmark/prepare-data.sh index 997295578..f957d8c96 100755 --- a/e2e-test/qa/benchmark/prepare-data.sh +++ b/e2e-test/qa/benchmark/prepare-data.sh @@ -2,9 +2,55 @@ set -ex REQ_HOST="localhost:9080" REQ_TESTS_API="http://$REQ_HOST/alfresco-bm-manager/api/v1/tests" - TEST_NAME="DataTest" -# add here content of https://git.alfresco.com/search_discovery/BuildScripts/blob/feature/search-1506/qa/benchmark/create-data.sh -# use ALFRESCO_URL for full http+alfresco+port =>http://localhost:8081 (see Makefile) +echo -ne "Create Test Data\n" +#Create Test +curl -s $REQ_TESTS_API -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$TEST_NAME'","description":"Data","release":"alfresco-bm-load-data-3.0.1-SNAPSHOT","schema":"11"}' +echo -ne "Set MongoDB Data\n" +#Set Mongo DB +IP=$(hostname -I | awk '{print $1}') +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/mongo.test.host" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$IP':27017"}' + +echo -ne "Set Alfresco related attributes Data\n" +#Set Alfresco related attributes +#ALF_SERVER=${bamboo.alfresco.url} +#ALF_SERVER="ec2-34-245-148-19.eu-west-1.compute.amazonaws.com" +ALF_SERVER=$(echo $ALFRESCO_URL | cut -d '/' -f3 | cut -d ':' -f1) +ALF_PORT=$(echo $ALFRESCO_URL | cut -d ':' -f3) +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.server" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALF_SERVER'"}' +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.url" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALFRESCO_URL'/"}' +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.port" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALF_PORT'"}' + +#Set Site attribute +SITE_NAME=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 4 | head -n 1)-Site-%s-%05d +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/load.siteFormat" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$SITE_NAME'"}' + +echo -ne "Create test instance Data\n" +#Create test instance +INSTANCE_NAME="RunTestData1" +curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$INSTANCE_NAME'"}' + +echo -ne "Start the test Data\n" +#Start the test +curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs/"$INSTANCE_NAME"/schedule" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"scheduled":0}' + +completed=-1 +# Add 0 to the completed value to ensure it's a number. +while [ $((completed+0)) -eq -1 ] +do + sleep 10 + status=`curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8'` + #log "Status: $status" + # Update the completed timestamp value (which will be -1 if the test hasn't finished yet). + completed=`echo $status | sed 's|^.*"completed" : \([^ ]*\) .*$|\1|g'` + if [ $((completed+0)) -eq -1 ] + then + # Also check the "stopped" value if it hasn't completed. + completed=`echo $status | sed 's|^.*"stopped" : \([^ ]*\) .*$|\1|g'` + fi + #log "Progress: "`echo $status | sed 's|^.*"progress" : \([^ ]*\) .*$|\1|g'` +done + +curl -s -o search_data_results.xlsx -O -J $REQ_TESTS_API"/"$TEST_NAME"/runs/"$INSTANCE_NAME"/results/xlsx" \ No newline at end of file diff --git a/e2e-test/qa/benchmark/prepare-users.sh b/e2e-test/qa/benchmark/prepare-users.sh index 4fdd50b33..1ed8cbdc2 100755 --- a/e2e-test/qa/benchmark/prepare-users.sh +++ b/e2e-test/qa/benchmark/prepare-users.sh @@ -2,9 +2,58 @@ set -ex REQ_HOST="localhost:9080" REQ_TESTS_API="http://$REQ_HOST/alfresco-bm-manager/api/v1/tests" +TEST_NAME="UserTest" -TEST_NAME="SearchTest" -curl -s ${REQ_TESTS_API} -H 'Host: ${REQ_HOST}' -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$TEST_NAME'","description":"Users","release":"alfresco-bm-rest-api-3.0.1-SNAPSHOT","schema":"12"}' -# add here content of https://git.alfresco.com/search_discovery/BuildScripts/blob/feature/search-1506/qa/benchmark/create-users.sh -# use ALFRESCO_URL for full http+alfresco+port =>http://localhost:8081 (see Makefile) +echo -ne "Create Test\n" +#Create Test +curl -s $REQ_TESTS_API -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$TEST_NAME'","description":"Users","release":"alfresco-bm-load-users-3.0.1-SNAPSHOT","schema":"9"}' + +echo -e "Set MongoDB\n" +#Set Mongo DB +IP=$(hostname -I | awk '{print $1}') +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/mongo.test.host" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$IP':27017"}' + +echo -e "Set Alfresco related attributes\n" +#Set Alfresco related attributes +#ALF_SERVER=${bamboo.alfresco.url} +#ALF_SERVER="ec2-34-245-148-19.eu-west-1.compute.amazonaws.com" +ALF_SERVER=$(echo $ALFRESCO_URL | cut -d '/' -f3 | cut -d ':' -f1) +ALF_PORT=$(echo $ALFRESCO_URL | cut -d ':' -f3) +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.server" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALF_SERVER'"}' +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.url" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"http://'$ALF_SERVER:$ALF_PORT'/"}' +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/alfresco.port" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$ALF_PORT'"}' + +echo -e "Create Users\n" +#Create Users +NO_USERS="300" +curl -s $REQ_TESTS_API"/"$TEST_NAME"/props/user.numberOfUsers" -X PUT -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"value":"'$NO_USERS'"}' + +echo -e "Create test instance\n" +#Create test instance +INSTANCE_NAME="RunTestUser1" +curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"name":"'$INSTANCE_NAME'"}' + +echo -r "Start the test\n" +#Start the test +curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs/"$INSTANCE_NAME"/schedule" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8' --data '{"version":0,"scheduled":0}' + +completed=-1 +# Add 0 to the completed value to ensure it's a number. +while [ $((completed+0)) -eq -1 ] +do + sleep 10 + status=`curl -s $REQ_TESTS_API"/"$TEST_NAME"/runs" -H "'Host: '"$REQ_HOST"/'" -H 'Content-Type: application/json;charset=utf-8'` + #log "Status: $status" + # Update the completed timestamp value (which will be -1 if the test hasn't finished yet). + completed=`echo $status | sed 's|^.*"completed" : \([^ ]*\) .*$|\1|g'` + if [ $((completed+0)) -eq -1 ] + then + # Also check the "stopped" value if it hasn't completed. + completed=`echo $status | sed 's|^.*"stopped" : \([^ ]*\) .*$|\1|g'` + fi + #log "Progress: "`echo $status | sed 's|^.*"progress" : \([^ ]*\) .*$|\1|g'` +done + +#log "Output the CSV results." +curl -s -o create_users_results.xlsx -O -J $REQ_TESTS_API"/"$TEST_NAME"/runs/"$INSTANCE_NAME"/results/xlsx" \ No newline at end of file