correct jq in dev-env (#463)

* correct jq in dev-env

* Remove references to lsof and dead scripts that called lsof since it is no longer in dev-env
This commit is contained in:
Brian Healey 2019-04-12 16:44:15 -04:00 committed by GitHub
parent 1326596795
commit b594fcffc1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1 additions and 233 deletions

View File

@ -1,84 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -u
# options
PORT_RANGES=${PORT_RANGES:-"8000:8100 9000:9100 20000:20100 6865:6866"}
SHOULD_FAIL_BUILD=${SHOULD_FAIL_BUILD:-true}
SHOULD_KILL_PROCESSES=${SHOULD_KILL_PROCESSES:-false}
# internal global variables
PROCESS_DETECTED=false
function scan_ports()
{
local port_range=$1
local start_port=${port_range%%:*}
local end_port=${port_range##*:}
local sleep_before_reporting_process=10
echo -e "\nStarting scanning port range $start_port:$end_port ... \n"
for port in $(seq $start_port $end_port); do
pid=$(lsof -stcp:LISTEN -t -i :$port)
if [[ $? -eq 0 ]]; then
echo "process $pid detected on port $port, waiting for $sleep_before_reporting_process seconds ... "
sleep $sleep_before_reporting_process
pid=$(lsof -stcp:LISTEN -t -i :$port)
if [[ $? -eq 0 ]]; then
echo "process $pid still running and will be reported ..."
PROCESS_DETECTED=true
ps -wwfp $pid
if [[ $SHOULD_KILL_PROCESSES == true ]]; then
echo -e "\nKilling process $pid\n"
kill -9 $pid
pid=$(lsof -stcp:LISTEN -t -i :$port)
if [[ $? -eq 0 ]]; then
echo -e "\nCouldnt kill the process $pid with kill -9 \n"
else
echo -e "\n Able to force kill process $pid with kill -9 \n"
PROCESS_DETECTED=false
fi
fi
fi
fi
done
}
### MAIN
echo "
Checking for open ports (tcp:LISTENING)
This is useful to invoke as a diagnostic tool before running
processes expecting fixed ports to be available.
Using the following options:
- PORT_RANGES=${PORT_RANGES}
- SHOULD_FAIL_BUILD=${SHOULD_FAIL_BUILD}
- SHOULD_KILL_PROCESSES=${SHOULD_KILL_PROCESSES}
You can override the values by using environment variables.
You can specify multiple port ranges, separated by space ' '
e.g. PORT_RANGES=\"8000:8100 8200:8300\"
"
for port_range in $PORT_RANGES; do
scan_ports $port_range
done
if [[ $PROCESS_DETECTED == true ]]; then
if [[ $SHOULD_FAIL_BUILD == true ]]; then
echo -e "\n\nWill fail build as hanging processes have been detected"
exit 1
fi
else
echo -e "\n\nNo processes have been detected on $PORT_RANGES port range"
fi
exit 0

View File

@ -1,5 +1,4 @@
#!/usr/bin/env bash
DADE_CURRENT_SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source "$DADE_CURRENT_SCRIPT_DIR/../lib/dade-common"
buildTool lsof out 0
nix-store --gc

View File

@ -1 +1 @@
../lib/dade-exec-nix-tool
../lib/dade-exec-nix-bin-tool

View File

@ -1,4 +0,0 @@
#!/usr/bin/env sh
# Perform git checkout like hydra does
export NIX_PREFETCH_GIT_CHECKOUT_HOOK="find \"\$dir\" -type f -name .gitignore -exec rm {} \;"
nix-prefetch-git "$@"

View File

@ -1,84 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -euxo pipefail
#Run this from the ledger dir
PATH="${PATH}:/usr/sbin" #lsof is not on the PATH by default
WORKING_DIR=$(pwd)
PORT=6865
function get_pid_listening_on_port () {
echo $(lsof -i:${PORT} -t)
}
function cleanup() {
PID=$(get_pid_listening_on_port) || "" #Handling error from lsof if there is no such process
if [ -z ${PID} ]
then
exit 0
else
kill ${PID}
fi
}
trap cleanup EXIT
function wait_for_unbind () {
while nc -z 127.0.0.1 $1; do
sleep 0.1
done
}
function wait_for_bind () {
while ! nc -z 127.0.0.1 $1; do
sleep 0.1
done
}
function getTime () {
TIME_NANOS=$(date +%s%N | sed -E "s/^([0-9]+)N$/\1000000000/g")
echo $((${TIME_NANOS}/1000000))
}
function run_startup_benchmark () {
JAR_FILE=$1
PORT=$2
START=$(getTime)
java -jar ${JAR_FILE} -p ${PORT} --dalf bond-trading.dalf > "sandbox_output.txt" &
PID=$!
wait_for_bind ${PORT}
END=$(getTime)
kill ${PID}
wait_for_unbind ${PORT}
let "DIFF = ${END} - ${START}"
echo ${DIFF}
}
#Run this from the ledger dir
find sandbox -name "sandbox*.tgz" -exec tar -zxf {} +;
TAR_DIR=$(find . -type d -name "sandbox-*-*")
DAMLI_JAR_FILE=$(find ${TAR_DIR} -name "damli-*-*.jar" -maxdepth 2)
java -jar ${DAMLI_JAR_FILE} export-lf-v1 "../reference-apps/bond-trading/daml/LibraryModules.daml" -o "${TAR_DIR}/bond-trading.dalf"
pushd ${TAR_DIR}
JAR_FILE=$(find . -name "sandbox-*-*.jar" -maxdepth 1)
RESULT_FILE_NAME="StartupBenchmark.xml"
RESULT_FILE="${WORKING_DIR}/${RESULT_FILE_NAME}"
echo "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" > ${RESULT_FILE}
echo "<testResults>" >> ${RESULT_FILE}
for i in {1..5}
do
RESULT_MS=$(run_startup_benchmark "${JAR_FILE}" "${PORT}")
TIME_MS=$(getTime)
echo "<sample lb=\"Sandbox.Startup\" lt=\"0\" rc=\"200\" rm=\"OK\" s=\"true\" t=\"${RESULT_MS}\" tn=\"-\" ts=\"${TIME_MS}\"/>" >> ${RESULT_FILE}
done
popd
echo "</testResults>" >> ${RESULT_FILE}
rm -rf ${TAR_DIR}
TARGET_DIR="sandbox-perf/target/benchmarks/jmeter"
mkdir -p ${TARGET_DIR}
mv ${RESULT_FILE} ${TARGET_DIR}
cat "${TARGET_DIR}/${RESULT_FILE_NAME}"

View File

@ -1,57 +0,0 @@
#!/usr/bin/env bash
# Copyright (c) 2019 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
set -u
exp_num_of_params=2
if [ "$#" -ne $exp_num_of_params ]; then
echo "[ERROR] Illegal number of arguments. (Expected $exp_num_of_params, got $#)"
echo "[HELP] $0 browserstack_user browserstack_password"
exit 1
fi
# browserstack user
readonly BROWSERSTACK_CREDENTIALS_USR=$1
# browserstack password
readonly BROWSERSTACK_CREDENTIALS_PSW=$2
lsof -n -i :4000 | grep LISTEN | awk '{print $2}' | xargs kill -9
lsof -n -i :7500 | grep LISTEN | awk '{print $2}' | xargs kill -9
lsof -n -i :8081 | grep LISTEN | awk '{print $2}' | xargs kill -9
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
pushd $DIR
BSUSER="--browserstack-user ${BROWSERSTACK_CREDENTIALS_USR}"
BSKEY="--browserstack-key ${BROWSERSTACK_CREDENTIALS_PSW}"
DAML_PATH="--daml-path $DIR/src/main/resources/Main.daml"
NAV_CONF_PATH="--nav-conf-path $DIR/src/main/resources/ui-backend.conf"
PARENTDIR="$(dirname "$DIR")"
NAVIGATOR_DIR="--navigator-dir $PARENTDIR"
PARAMS="$DAML_PATH $NAV_CONF_PATH $NAVIGATOR_DIR $BSUSER $BSKEY"
TEST_COMMAND='sbt "run '${PARAMS}'"'
echo ${TEST_COMMAND}
echo "Running the integration tests"
eval "${TEST_COMMAND}"
SUCCESS=$(echo $?)
echo "Test run finished"
echo "Cleaning up the applications"
lsof -n -i :4000 | grep LISTEN | awk '{print $2}' | xargs kill -9
lsof -n -i :7500 | grep LISTEN | awk '{print $2}' | xargs kill -9
lsof -n -i :8081 | grep LISTEN | awk '{print $2}' | xargs kill -9
echo "Cleanup done"
popd
exit ${SUCCESS}

View File

@ -254,8 +254,6 @@ in rec {
undmg = pkgs.undmg;
jfrog = pkgs.callPackage ./tools/jfrog-cli {};
nix-prefetch-git = pkgs.nix-prefetch-git;
# Cloud tools
gcloud = pkgs.google-cloud-sdk;
bq = gcloud;