Created
June 10, 2018 02:42
-
-
Save masiuchi/0bdb7f9bebccbd982961e72b6df89f33 to your computer and use it in GitHub Desktop.
Call MT create_entry endpoint many times in parallel.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
TOTAL_REQUEST_COUNT=100 | |
PARALLEL_COUNT=5 | |
if [ $# -ne 3 ]; then | |
echo '[usage]: bash create_entries.sh [Data API URL] [USERNAME] [PASSWORD]' | |
exit 1 | |
fi | |
DATAAPIURL=$1 | |
USERNAME=$2 | |
PASSWORD=$3 | |
RES_AUTH=`curl -s -d "username=$USERNAME" -d "password=$PASSWORD" -d 'clientId=curl' $DATAAPIURL/v2/authentication` | |
ACCESS_TOKEN=`echo $RES_AUTH | perl -pe 's/^.+"accessToken":"([^"]+)".+$/$1/'` | |
seq 1 $TOTAL_REQUEST_COUNT | xargs -L 1 -I XX -P $PARALLEL_COUNT curl -H "X-MT-Authorization: MTAuth accessToken=\"$ACCESS_TOKEN\"" -d 'entry={}' $DATAAPIURL/v3/sites/1/entries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment