<commit_before>#!/bin/bash

function get_aws_key_id_from_server_config() {
   grep aws_access_key_id secretshare-server.json | cut -d\" -f4
   if [ "${?}" -ne 0 ]; then
           echo >&2 "Failed to pull aws_access_key_id out of secretshare-server.json"
           exit 1
   fi
}

function get_aws_secret_from_server_config() {
   grep aws_secret_access_key secretshare-server.json | cut -d\" -f4
   if [ "${?}" -ne 0 ]; then
           echo >&2 "Failed to pull aws_secret_key_id out of secretshare-server.json"
           exit 1
   fi
}

if [ "x$TEST_BUCKET_REGION" == "x" ]; then
    echo 'Set $TEST_BUCKET_REGION to the region of the S3 bucket you will use for this test and re-run.'
    exit 1
fi

if [ "x$TEST_BUCKET" == "x" ]; then
    echo 'Set $TEST_BUCKET to the S3 bucket you will use for this test and re-run.'
    exit 1
fi

if [ "x$CURRENT_OS" == "x" ]; then
    echo 'Set $CURRENT_OS to the OS you are testing on (linux, osx, win) and re-run.'
    exit 1
fi

if [ "x$CURRENT_ARCH" == "x" ]; then
    echo 'Set $CURRENT_ARCH to the OS you are testing on (amd64, etc.) and re-run.'
    exit 1
fi

if [ -z "$PORT" ]; then
    PORT=8080
fi
export SECRETSHARE_KEY="TESTTESTTESTTESTTESTTESTTESTTESTTESTTEST"

if [ -z "$AWS_ACCESS_KEY_ID" ]; then
    AWS_ACCESS_KEY_ID=$(get_aws_key_id_from_server_config)
    AWS_SECRET_ACCESS_KEY=$(get_aws_secret_from_server_config)
fi

cat > secretshare-server-test.json <<EOF
{
    "addr": "0.0.0.0",
    "port": $PORT,
    "bucket": "$TEST_BUCKET",
    "bucket_region": "$TEST_BUCKET_REGION",
    "secret_key": "$SECRETSHARE_KEY",
    "aws_access_key_id": "$AWS_ACCESS_KEY_ID",
    "aws_secret_access_key": "$AWS_SECRET_ACCESS_KEY"
}
EOF

killall secretshare-server
./build/$CURRENT_OS-$CURRENT_ARCH/secretshare-server -config secretshare-server-test.json &> test-server.log &
server_pid=$!

if [ "x$server_pid" == "x" ]; then
    echo 'Failed to start server!'
    exit 1
fi

sleep 2

if ! kill -0 $server_pid; then
    echo 'Server died unexpectedly!'
    exit 1
fi

CLIENT="./build/$CURRENT_OS-$CURRENT_ARCH/secretshare --endpoint http://localhost:$PORT --bucket-region $TEST_BUCKET_REGION --bucket $TEST_BUCKET"

version_out=$($CLIENT version)
client_version=$(echo "$version_out" | grep '^Client version' | cut -d ':' -f 2 | cut -c 2-)<commit_msg>Use native build for testing<commit_after>#!/bin/bash

function get_aws_key_id_from_server_config() {
   grep aws_access_key_id secretshare-server.json | cut -d\" -f4
   if [ "${?}" -ne 0 ]; then
           echo >&2 "Failed to pull aws_access_key_id out of secretshare-server.json"
           exit 1
   fi
}

function get_aws_secret_from_server_config() {
   grep aws_secret_access_key secretshare-server.json | cut -d\" -f4
   if [ "${?}" -ne 0 ]; then
           echo >&2 "Failed to pull aws_secret_key_id out of secretshare-server.json"
           exit 1
   fi
}

if [ "x$TEST_BUCKET_REGION" == "x" ]; then
    echo 'Set $TEST_BUCKET_REGION to the region of the S3 bucket you will use for this test and re-run.'
    exit 1
fi

if [ "x$TEST_BUCKET" == "x" ]; then
    echo 'Set $TEST_BUCKET to the S3 bucket you will use for this test and re-run.'
    exit 1
fi

if [ -z "$PORT" ]; then
    PORT=8080
fi
export SECRETSHARE_KEY="TESTTESTTESTTESTTESTTESTTESTTESTTESTTEST"

if [ -z "$AWS_ACCESS_KEY_ID" ]; then
    AWS_ACCESS_KEY_ID=$(get_aws_key_id_from_server_config)
    AWS_SECRET_ACCESS_KEY=$(get_aws_secret_from_server_config)
fi

cat > secretshare-server-test.json <<EOF
{
    "addr": "0.0.0.0",
    "port": $PORT,
    "bucket": "$TEST_BUCKET",
    "bucket_region": "$TEST_BUCKET_REGION",
    "secret_key": "$SECRETSHARE_KEY",
    "aws_access_key_id": "$AWS_ACCESS_KEY_ID",
    "aws_secret_access_key": "$AWS_SECRET_ACCESS_KEY"
}
EOF

killall secretshare-server
./build/native/secretshare-server -config secretshare-server-test.json &> test-server.log &
server_pid=$!

if [ "x$server_pid" == "x" ]; then
    echo 'Failed to start server!'
    exit 1
fi

sleep 2

if ! kill -0 $server_pid; then
    echo 'Server died unexpectedly!'
    exit 1
fi

CLIENT="./build/native/secretshare --endpoint http://localhost:$PORT --bucket-region $TEST_BUCKET_REGION --bucket $TEST_BUCKET"

version_out=$($CLIENT version)
client_version=$(echo "$version_out" | grep '^Client version' | cut -d ':' -f 2 | cut -c 2-)
{'fraction_non_alphanumeric': 0.12967696955612362, 'fraction_numerical': 0.013014176156170114, 'mean_word_length': 3.642934196332255, 'pattern_counts': {'":': 14, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '991472', 'n_tokens_mistral': 1596, 'n_tokens_neox': 1594, 'n_words': 412}