diff --git a/.gitignore b/.gitignore index 0344ad1a..0bf30100 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,4 @@ node_modules/ ideas *_err.log *.swp +package-lock.json diff --git a/.travis.yml b/.travis.yml index 09e0123f..443e6104 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,18 @@ language: node_js +node_js: + - "iojs" + - "8" sudo: required before_install: - - 'if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi' - wget "http://static.druid.io/artifacts/releases/druid-0.8.3-bin.tar.gz" - tar -zxvf druid-0.8.3-bin.tar.gz - wget "https://archive.apache.org/dist/kafka/0.8.2.0/kafka_2.10-0.8.2.0.tgz" - tar -zxvf kafka_2.10-0.8.2.0.tgz install: - - npm -s install - - mvn -q clean install -f ./infinispan_example_app/pom.xml + - npm install + - mvn clean install -f ./infinispan_example_app/pom.xml script: + - node --version - ./infispector.sh help - ./infispector.sh prepare - ./infispector.sh nodes diff --git a/gruntFile.js b/gruntFile.js index 5f470b1e..c673b9d6 100644 --- a/gruntFile.js +++ b/gruntFile.js @@ -195,7 +195,7 @@ serverFile: 'app.js', shell: { nodemon: { - command: 'nodemon <%= serverFile %>', + command: '${infispector_location}/node_modules/nodemon/bin/nodemon.js <%= serverFile %>', options: { stdout: true, stderr: true, @@ -218,4 +218,4 @@ }); -}; \ No newline at end of file +}; diff --git a/infinispan_example_app/pom.xml b/infinispan_example_app/pom.xml index 3e0a3d63..3dbf3233 100644 --- a/infinispan_example_app/pom.xml +++ b/infinispan_example_app/pom.xml @@ -8,8 +8,8 @@ UTF-8 - 1.7 - 1.7 + 1.8 + 1.8 7.4.Final diff --git a/infispector.sh b/infispector.sh index 6ed5380d..c4eed772 100755 --- a/infispector.sh +++ b/infispector.sh @@ -7,23 +7,16 @@ cleanUp() { pkill -f grunt -e } -#colors -NC='\033[0m' -WHITE='\033[1;37m' -GREEN='\033[0;32m' -RED='\033[0;31m' - -if [ "$#" -eq "0" ] || [ $1 == "help" ] -then +printHelp() { printf " - _____ __ _ _ - |_ _| / _|(_) | | - | | _ __ | |_ _ ___ _ __ ___ ___ | |_ ___ _ __ + _____ __ _ _ + |_ _| / _|(_) | | + | | _ __ | |_ _ ___ _ __ ___ ___ | |_ ___ _ __ | | | '_ \ | _|| |/ __|| '_ \ / _ \ / __|| __| / _ \ | '__| - _| |_ | | | || | | |\__ \| |_) || __/| (__ | |_ | (_) || | - |_____||_| |_||_| |_||___/| .__/ \___| \___| \__| \___/ |_| - | | - |_| + _| |_ | | | || | | |\__ \| |_) || __/| (__ | |_ | (_) || | + |_____||_| |_||_| |_||___/| .__/ \___| \___| \__| \___/ |_| + | | + |_| commands: @@ -34,54 +27,60 @@ ${GREEN}infispector stop${NC} - stops infispector ${GREEN}infispector nodes${NC} - starts 4 instances ${GREEN}infispector nodes ${RED}NUMBER${NC} - starts specified ${RED}NUMBER${NC} of instances " - exit 0 -fi - -#paths -DRUID_LOCATION=`find /home -type d -name druid-0.8.3 2> /dev/null` -KAFKA_LOCATION=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` -INFISPECTOR_LOCATION=`find /home -type d -iname infispector 2> /dev/null | awk '{ print length, $0 }' | sort -n -s | head -n1 | cut -f 2 -d ' '` - -DEFAULT="4" -NUMBER_CHECK='^[0-9]+$' -cnt="0" -TIMEOUT="0" - -if [ -z $DRUID_LOCATION ] -then - printf "Druid not found. Druid must be in /home/* directory\n" >&2 - exit 1 -fi - -if [ -z $KAFKA_LOCATION ] -then - printf "Kafka not found. Kafka must be in /home/* directory\n" >&2 - exit 1 -fi +} -if [ -z $INFISPECTOR_LOCATION ] -then - printf "Infispector not found. Infispector must be in /home/* directory\n" >&2 - exit 1 -fi +getInfispectorLocation() { + result="" + if [ -z "$infispector_location" ] + then + result=`find /home -type d -iname infispector 2> /dev/null | awk '{ print length, $0 }' | sort -n -s | head -n1 | cut -f 2 -d ' '` + else + result="$infispector_location" + fi + if [ -z "$result" ] + then + printf "Infispector not found. Infispector must be in /home/* directory\n" >&2 + exit 1 + fi + echo "$result" +} -if [ $EUID -eq 0 ] -then - printf "Please, run this as a ${WHITE}normal${NC} user, not root.\n" >$2 - exit 1 -fi +getDruidLocation() { + result=`find /home -type d -name druid-0.8.3 2> /dev/null` + if [ -z "$result" ] + then + printf "Druid not found. Druid must be in /home/* directory\n" >&2 + exit 1 + fi + echo "$result" +} -if [ "$#" -gt "2" ] || { [ "$#" -eq "2" ] && [ "$1" != "nodes" ]; } -#if [ \( "$#" -gt "2" \) -o \( "$g" "$#" -eq "2" -a "$1" -ne "nodes" \) ] -then - printf "Invalid number of arguments!\n" >$2 - exit 1 -fi +getKafkaLocation() { + result=`find /home -type d -name kafka_2.10-0.8.2.0 2> /dev/null` + if [ -z "$result" ] + then + printf "Kafka not found. Kafka must be in /home/* directory\n" >&2 + exit 1 + fi + echo "$result" +} +checkUserAndParams() { + if [ $EUID -eq 0 ] + then + printf "Please, run this as a ${WHITE}normal${NC} user, not root.\n" >&2 + exit 1 + fi + + if [ "$#" -gt "2" ] || { [ "$#" -eq "2" ] && [ "$1" != "nodes" ]; } + then + printf "Invalid number of arguments!\n" >&2 + exit 1 + fi +} -if [ $1 == "prepare" ] -then - cd $KAFKA_LOCATION +startKafka() { + cd $KAFKA_LOCATION printf "Starting zookeeper ...." bin/zookeeper-server-start.sh config/zookeeper.properties > /dev/null & sleep 1 @@ -104,8 +103,11 @@ then else printf " ${GREEN}OK${NC}\n" fi +} - cd $DRUID_LOCATION +startDruid() { + TIMEOUT="0" + cd $DRUID_LOCATION printf "Starting druid ...." java -Xmx512m -Duser.timezone=UTC -Dfile.encoding=UTF-8 -Ddruid.realtime.specFile=$INFISPECTOR_LOCATION/kafka_druid_infrastructure/infispectorDruid.spec -classpath "config/_common:config/realtime:lib/*" io.druid.cli.Main server realtime > log.txt 2> log_err.txt & if echo $INFISPECTOR_LOCATION | grep travis > /dev/null @@ -119,38 +121,33 @@ then then break fi - if [ $TIMEOUT -eq "20" ] + if [[ "$TIMEOUT" -eq 20 ]] then printf " ${RED}FAIL${NC}\n" cleanUp exit 1 fi TIMEOUT=$[$TIMEOUT + 1] - sleep 1 + sleep 1 done - printf " ${GREEN}OK${NC}\n" +} + +prepare() { + startKafka + startDruid + printf " ${GREEN}OK${NC}\n" printf "Infispector is ready to be started!\n" - exit 0 -fi +} -if [ $1 == "start" ] -then - cd $INFISPECTOR_LOCATION +start() { + cd $INFISPECTOR_LOCATION grunt - exit 0 -fi - -if [ $1 == "stop" ] -then - cleanUp - exit 0 -fi - +} -if [ $1 == "nodes" ] -then - cd $INFISPECTOR_LOCATION/infinispan_example_app - if ! [[ -z "$2" ]] +setNumberOfNodes() { + result="4" + NUMBER_CHECK='^[0-9]+$' + if ! [[ -z "$2" ]] then if ! [[ $2 =~ $NUMBER_CHECK ]] then @@ -171,6 +168,14 @@ then done fi fi + echo "$result" +} + +nodes() { + DEFAULT=$(setNumberOfNodes) + cnt="0" + cd $INFISPECTOR_LOCATION/infinispan_example_app + printf "Starting $DEFAULT nodes ...." while [ $cnt -ne $DEFAULT ] do @@ -190,7 +195,31 @@ then printf " ${RED}FAIL${NC}\n" exit 1 fi +} + +#paths +DRUID_LOCATION=$(getDruidLocation) +KAFKA_LOCATION=$(getKafkaLocation) +INFISPECTOR_LOCATION=$(getInfispectorLocation) + +#colors +NC='\033[0m' +WHITE='\033[1;37m' +GREEN='\033[0;32m' +RED='\033[0;31m' + +checkUserAndParams +if [ $# -eq 0 ] +then + printHelp + exit 0 fi -printf "Invalid argument!\n" >&2 -exit 1 +case $1 in +("prepare") prepare ;; +("start") start ;; +("stop") cleanUp ;; +("nodes") nodes ;; +("help") printHelp ;; +(*) echo "invalid argument"; echo "usage: " ; printHelp ;; +esac \ No newline at end of file diff --git a/install.sh b/install.sh index 78609c90..df66b45e 100755 --- a/install.sh +++ b/install.sh @@ -2,7 +2,7 @@ downloadMaven() { printf "Downloading maven...\n" - wget -q --show-progress $URL_MAVEN + wget $_PROGRESS_OPT $URL_MAVEN tar zxvf apache-maven-3.5.2-bin.tar.gz -C $HOME > /dev/null /bin/rm apache-maven-3.5.2-bin.tar.gz > /dev/null M2_HOME=$HOME/apache-maven-3.5.2 @@ -48,6 +48,10 @@ then exit 1 fi +#set wget options +wget --help | grep -q '\--show-progress' && \ + _PROGRESS_OPT="-q --show-progress" || _PROGRESS_OPT="" + printf "Looking for a druid-0.8.3 folder in device ...." druid_location=`find /home -type d -name druid-0.8.3 2> /dev/null` if echo $druid_location | grep "Trash" > /dev/null @@ -59,7 +63,7 @@ fi if [ -z "$druid_location" ] then printf " ${RED}NOT FOUND${NC}.\n" - wget -q --show-progress $URL_DRUID + wget $_PROGRESS_OPT $URL_DRUID if [ $? -eq 0 ] then tar -xvzf druid-0.8.3-bin.tar.gz -C $HOME > /dev/null @@ -84,7 +88,7 @@ fi if [ -z "$kafka_location" ] then printf " ${RED}NOT FOUND${NC}.\n" - wget -q --show-progress $URL_KAFKA + wget $_PROGRESS_OPT $URL_KAFKA if [ $? -eq 0 ] then tar -xvzf kafka_2.10-0.8.2.0.tgz -C $HOME > /dev/null @@ -94,7 +98,7 @@ then printf "Kafka download failed\n" >&2 fi else - printf " ${GREEN}FOUND${NC}. Download will be skipped.\n" + printf " ${GREEN}FOUND${NC}.\nDownload will be skipped.\n" fi #sets alias infispector to start script infispector.sh @@ -116,6 +120,8 @@ fi if ! grep "alias infispector='${infispector_location}/infispector.sh'" < ~/.bashrc > /dev/null then printf "alias infispector='${infispector_location}/infispector.sh'\n" >> ~/.bashrc + printf "infispector_location='${infispector_location}'\n" >> ~/.bashrc + printf "export infispector_location\n" >> ~/.bashrc fi #create new file with autocomplete - requires permission @@ -189,7 +195,7 @@ then fi printf "mvn install ...." cd $infispector_location/infinispan_example_app/ -mvn -q clean install 2> $infispector_location/mvn_err.log +mvn clean install 2> $infispector_location/mvn_err.log if [ $? -eq 0 ] then printf " ${GREEN}OK${NC}\n" diff --git a/package.json b/package.json index 2253556f..1b2dd21f 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,11 @@ "mongoose": ">= 3.6.1", "infinispan": "0.2.0", "jsonfile": "2.3.0", - "rsvp":"3.2.1", + "rsvp": "3.2.1", "crypto": ">= 0.0.3", "passport": ">= 0.1.6", "passport-local": ">= 0.1.6", "nodemailer": ">= 0.4.1", - "nodemon": "1.3.7", "is-online": ">=7.0.0", "jasmine": "^2.8.0", "request": "2.81.0" @@ -39,10 +38,11 @@ "grunt-nodemon": "^0.4.0", "grunt-processhtml": "~0.2.7", "grunt-shell": "^1.1.2", - "load-grunt-tasks": "^3.1.0" + "load-grunt-tasks": "^3.1.0", + "nodemon": "^1.18.3" }, "scripts": { - "start": "node app.js", + "start": "node app.js", "test": "jasmine spec/postRequestsTest.js" } } diff --git a/testFunctionality.sh b/testFunctionality.sh index 44d67e16..8da20c8d 100755 --- a/testFunctionality.sh +++ b/testFunctionality.sh @@ -7,6 +7,8 @@ cleanUp() { rm tmp2 } +$SHELL --version +export infispector_location=`readlink -f .` grunt > tmp & while true