From b604a500d127273657f31638de2cb77f609ffb07 Mon Sep 17 00:00:00 2001 From: Joel Baranick Date: Fri, 2 Mar 2018 02:33:23 -0800 Subject: [PATCH] Enabled file_glob in travis. Create archives. --- .travis.yml | 3 ++- README.md | 18 ++++++++++++++++++ build.sh | 47 +++++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 63 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0f97314..4e9ec53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,8 @@ deploy: provider: releases api_key: secure: QjoIGS+UoJaLGK3MM7ohdl5djyKX0RVt7/bJphhtD6sGS6MyHWQbEgXpKToWC6dRL/pfvfkZYAAnTjsZLWGye7V8QXfQDharFJX0IeKTWfUjB67DnHXxdukfcB8mtX1bPGXpk5MGvIaVKKJulxC7h4BT1j0YDFE/G/p13dtfll4rYgmQ+QDOOhhYdEGqX0b5sAJqYOdEQR5FEyXm8uF0G7yA9tncz24Gv1Gk0jP6ASB52kpoZ4mO1fnUdJuMNOlk+xuasvyyvyw1SIz/KM0UaCJ2gHcBkterlbTftGWwMRt6xSw5DWGfGZt07ywStQqFhnGB3CJG05Sw6YakgRxi+wd2c6KwQCxCPUByzFoyf7T14ut2vSJFu/dJMA98KtxFQkNX4ln9sMtXOFSRpUQOG/kqx4jEftCgX7fczkJUZ6LgIvwIJQ7CWU4uIRNrbJko3RtZvpcNtR3hIvjA1tRlYUHHs3Nyqu7KnAJ9386TCELa6hH63T3ttOOftMruUJz0JC0Q3wXOFC61wEXIyW0u7akFiDf6HFlOmCRpgm8nPlNFpJiZJarZd7/l8YnoRuQfGU6tbHQPG0B5St6qf75UUfwtAKG2R5rxTfRyxp8woyQeq+MKom5KQpRp2YdRmRz/HkVQGVCIedlEj1KmLbz3UoBL1UZmoVnWti7BM7i7fPY= - file: dist/* + file_glob: true + file: dist/*.tar.gz skip_cleanup: true on: repo: kadaan/consulate diff --git a/README.md b/README.md index 22aeaba..bb281f1 100644 --- a/README.md +++ b/README.md @@ -592,6 +592,24 @@ Content-Type: application/json; charset=utf-8 * `503`: One or more Consul checks have failed * `504`: Consul unavailable +## Overhead + +In it's standard configuration Consulate adds very little overhead to the system and to Consul. Caching is used to reduce the calls to Consul to one per second. The processing done in Consulate is CPU bound, but is not very intensive. + +Performance testing was done with [vegeta](https://github.com/tsenart/vegeta). +```console +$ echo "GET http://localhost:8080/verify/checks" | vegeta attack -duration=5m | tee results.bin | vegeta report + +Requests [total, rate] 15000, 50.00 +Duration [total, attack, wait] 4m59.98055175s, 4m59.979999s, 552.75µs +Latencies [mean, 50, 95, 99, max] 1.101265ms, 910.812µs, 1.761948ms, 1.958328ms, 249.418571ms +Bytes In [total, mean] 225000, 15.00 +Bytes Out [total, mean] 0, 0.00 +Success [ratio] 100.00% +Status Codes [code:count] 200:15000 +Error Set: +``` + ## License Apache License 2.0, see [LICENSE](https://github.com/kadaan/consulate/blob/master/LICENSE). diff --git a/build.sh b/build.sh index ce7cba2..e5fa169 100755 --- a/build.sh +++ b/build.sh @@ -56,6 +56,7 @@ function get_platform() { PLATFORM=$(get_platform) GLIDE=$BINARY_DIR/glide GLIDE_URL="https://github.com/Masterminds/glide/releases/download/v0.13.1/glide-v0.13.1-$PLATFORM-amd64.tar.gz" +GOX="gox" GOMETALINTER=$BINARY_DIR/gometalinter GOMETALINTER_URL="https://github.com/alecthomas/gometalinter/releases/download/v2.0.4/gometalinter-2.0.4-$PLATFORM-amd64.tar.gz" CONSUL=$BINARY_DIR/consul @@ -112,8 +113,16 @@ function download_gometalinter() { fi } +function download_gox() { + if [ ! -x "$(command -v $GOX)" ]; then + echo " --> $GOX" + go get github.com/mitchellh/gox || fatal "go get 'github.com/mitchellh/gox' failed: $?" + fi +} + function download_binaries() { download_glide || fatal "failed to download 'glide': $?" + download_gox || fatal "failed to download 'gox': $?" download_gometalinter || fatal "failed to download 'gometalinter': $?" download_consul || fatal "failed to download 'consul': $?" export PATH=$PATH:$BINARY_DIR @@ -126,6 +135,11 @@ function run() { local buildDate=`date -u +"%Y-%m-%dT%H:%M:%SZ"` go version | grep -q 'go version go1.9.3 ' || fatal "go version is not 1.9.3" + if [ -z "$TRAVIS" ]; then + verbose "Cleanup dist..." + rm -rf dist/* + fi + verbose "Fetching binaries..." download_binaries @@ -172,12 +186,37 @@ function run() { go test -v ./... || fatal "$gopackage tests failed: $?" fi + XC_ARCH=${XC_ARCH:-"386 amd64 arm arm64"} + XC_OS=${XC_OS:-"solaris darwin freebsd linux windows"} + if [ -z "$TRAVIS" ]; then + XC_OS=$(go env GOOS) + XC_ARCH=$(go env GOARCH) + fi + verbose "Building binaries..." - if [ ! -x "$(command -v gox)" ]; then - echo "Getting gox..." - go get github.com/mitchellh/gox || fatal "go get 'github.com/mitchellh/gox' failed: $?" + $GOX -os="${XC_OS}" -arch="${XC_ARCH}" -osarch="!darwin/arm !darwin/arm64" -ldflags "-X github.com/kadaan/consulate/version.Version=$VERSION -X github.com/kadaan/consulate/version.Revision=$revision -X github.com/kadaan/consulate/version.Branch=$branch -X github.com/kadaan/consulate/version.BuildUser=$USER@$host -X github.com/kadaan/consulate/version.BuildDate=$buildDate" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" || fatal "gox failed: $?" + + if [ -n "$TRAVIS" ]; then + verbose "Creating archives..." + cd dist + set -x + for f in *; do + filename=$(basename "$f") + extension="${filename##*.}" + filename="${filename%.*}" + if [[ "$filename" != "$extension" ]] && [[ -n "$extension" ]]; then + extension=".$extension" + else + extension="" + fi + archivename="$filename.tar.gz" + verbose " --> $archivename" + genericname="consulate$extension" + mv -f "$f" "$genericname" + tar -czf $archivename "$genericname" + rm -rf "$genericname" + done fi - gox -ldflags "-X github.com/kadaan/consulate/version.Version=$VERSION -X github.com/kadaan/consulate/version.Revision=$revision -X github.com/kadaan/consulate/version.Branch=$branch -X github.com/kadaan/consulate/version.BuildUser=$USER@$host -X github.com/kadaan/consulate/version.BuildDate=$buildDate" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}" || fatal "gox failed: $?" } run "$@"