diff --git a/Makefile b/Makefile index 68e1afd239..2d6b7da8ff 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,19 @@ export GOPATH := $(shell go env GOPATH) GOPATH1 := $(firstword $(subst :, ,$(GOPATH))) export GO111MODULE := on -export GOPROXY := https://gocenter.io +export GOPROXY := direct UNAME := $(shell uname) SRCPATH := $(shell pwd) ARCH := $(shell ./scripts/archtype.sh) OS_TYPE := $(shell ./scripts/ostype.sh) +S3_RELEASE_BUCKET = $$S3_RELEASE_BUCKET # If build number already set, use it - to ensure same build number across multiple platforms being built BUILDNUMBER ?= $(shell ./scripts/compute_build_number.sh) COMMITHASH := $(shell ./scripts/compute_build_commit.sh) -BUILDBRANCH ?= $(shell ./scripts/compute_branch.sh) -BUILDCHANNEL ?= $(shell ./scripts/compute_branch_channel.sh $(BUILDBRANCH)) +BUILDBRANCH := $(shell ./scripts/compute_branch.sh) +BUILDCHANNEL := $(shell ./scripts/compute_branch_channel.sh $(BUILDBRANCH)) DEFAULTNETWORK ?= $(shell ./scripts/compute_branch_network.sh $(BUILDBRANCH)) DEFAULT_DEADLOCK ?= $(shell ./scripts/compute_branch_deadlock_default.sh $(BUILDBRANCH)) @@ -155,8 +156,14 @@ $(KMD_API_SWAGGER_INJECT): $(KMD_API_SWAGGER_SPEC) $(KMD_API_SWAGGER_SPEC).valid build: buildsrc gen +# We're making an empty file in the go-cache dir to +# get around a bug in go build where it will fail +# to cache binaries from time to time on empty NFS +# dirs buildsrc: crypto/libs/$(OS_TYPE)/$(ARCH)/lib/libsodium.a node_exporter NONGO_BIN deps $(ALGOD_API_SWAGGER_INJECT) $(KMD_API_SWAGGER_INJECT) - go install $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./... + mkdir -p tmp/go-cache && \ + touch tmp/go-cache/file.txt && \ + GOCACHE=$(SRCPATH)/tmp/go-cache go install $(GOTRIMPATH) $(GOTAGS) $(GOBUILDMODE) -ldflags="$(GOLDFLAGS)" ./... SOURCES_RACE := github.com/algorand/go-algorand/cmd/kmd @@ -233,7 +240,10 @@ node_exporter: $(GOPATH1)/bin/node_exporter # The file is was taken from the S3 cloud and it traditionally stored at # /travis-build-artifacts-us-ea-1.algorand.network/algorand/node_exporter/latest/node_exporter-stable-linux-x86_64.tar.gz $(GOPATH1)/bin/node_exporter: - tar -xzvf installer/external/node_exporter-stable-$(shell ./scripts/ostype.sh)-$(shell uname -m | tr '[:upper:]' '[:lower:]').tar.gz -C $(GOPATH1)/bin + mkdir -p $(GOPATH1)/bin && \ + cd $(GOPATH1)/bin && \ + tar -xzvf $(SRCPATH)/installer/external/node_exporter-stable-$(shell ./scripts/ostype.sh)-$(shell uname -m | tr '[:upper:]' '[:lower:]').tar.gz && \ + cd - # deploy @@ -279,3 +289,9 @@ install: build ###### TARGETS FOR CICD PROCESS ###### include ./scripts/release/mule/Makefile.mule +SUPPORTED_ARCHIVE_OS_ARCH = linux/amd64 linux/arm64 linux/arm darwin/amd64 + +archive: + CHANNEL=$(BUILDCHANNEL) \ + PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/bin:$${PATH} \ + scripts/upload_version.sh $(BUILDCHANNEL) $(SRCPATH)/tmp/node_pkgs $(S3_RELEASE_BUCKET) diff --git a/docker/build/Dockerfile b/docker/build/Dockerfile index 5b04ab3e5d..ac62e8dd55 100644 --- a/docker/build/Dockerfile +++ b/docker/build/Dockerfile @@ -6,7 +6,7 @@ WORKDIR /root RUN wget --quiet https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz && tar -xvf go${GOLANG_VERSION}.linux-amd64.tar.gz && mv go /usr/local ENV GOROOT=/usr/local/go \ GOPATH=$HOME/go \ - GOPROXY=https://gocenter.io + GOPROXY=https://gocenter.io,https://goproxy.io,direct RUN mkdir -p $GOPATH/src/github.com/algorand WORKDIR $GOPATH/src/github.com/algorand COPY ./go-algorand ./go-algorand/ diff --git a/docker/build/Dockerfile-deploy b/docker/build/Dockerfile-deploy index 65c16b7f2f..cc534ceb63 100644 --- a/docker/build/Dockerfile-deploy +++ b/docker/build/Dockerfile-deploy @@ -6,7 +6,7 @@ WORKDIR /root RUN wget --quiet https://dl.google.com/go/go${GOLANG_VERSION}.linux-amd64.tar.gz && tar -xvf go${GOLANG_VERSION}.linux-amd64.tar.gz && mv go /usr/local ENV GOROOT=/usr/local/go \ GOPATH=$HOME/go \ - GOPROXY=https://gocenter.io + GOPROXY=https://gocenter.io,https://goproxy.io,direct RUN mkdir -p $GOPATH/src/github.com/algorand WORKDIR $GOPATH/src/github.com/algorand COPY . ./go-algorand/ diff --git a/docker/build/arm.Dockerfile b/docker/build/cicd.alpine.Dockerfile similarity index 94% rename from docker/build/arm.Dockerfile rename to docker/build/cicd.alpine.Dockerfile index 8c801cdeed..9824eef64e 100644 --- a/docker/build/arm.Dockerfile +++ b/docker/build/cicd.alpine.Dockerfile @@ -24,7 +24,7 @@ RUN apk add dpkg && \ COPY . $GOPATH/src/github.com/algorand/go-algorand WORKDIR $GOPATH/src/github.com/algorand/go-algorand ENV GCC_CONFIG="--with-arch=armv6" \ - GOPROXY=https://gocenter.io + GOPROXY=https://gocenter.io,https://goproxy.io,direct RUN make ci-deps && make clean RUN rm -rf $GOPATH/src/github.com/algorand/go-algorand && \ mkdir -p $GOPATH/src/github.com/algorand/go-algorand diff --git a/docker/build/cicd.centos.Dockerfile b/docker/build/cicd.centos.Dockerfile index a9a038a42f..3021859e5a 100644 --- a/docker/build/cicd.centos.Dockerfile +++ b/docker/build/cicd.centos.Dockerfile @@ -1,12 +1,15 @@ ARG ARCH="amd64" FROM ${ARCH}/centos:7 -ENV GOLANG_VERSION 1.12 -ARG ARCH="amd64" + RUN yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \ yum update -y && \ - yum install -y autoconf wget awscli git gnupg2 nfs-utils python36 sqlite3 boost-devel expect jq libtool gcc-c++ libstdc++-devel libstdc++-static rpmdevtools createrepo rpm-sign bzip2 which ShellCheck + yum install -y autoconf wget awscli git gnupg2 nfs-utils python3-devel sqlite3 boost-devel expect jq \ + libtool gcc-c++ libstdc++-devel libstdc++-static rpmdevtools createrepo rpm-sign bzip2 which ShellCheck \ + libffi-devel openssl-devel WORKDIR /root +ARG ARCH +ENV GOLANG_VERSION 1.12.17 RUN wget https://dl.google.com/go/go${GOLANG_VERSION}.linux-${ARCH%v*}.tar.gz \ && tar -xvf go${GOLANG_VERSION}.linux-${ARCH%v*}.tar.gz && \ mv go /usr/local @@ -28,4 +31,3 @@ RUN rm -rf $GOPATH/src/github.com/algorand/go-algorand && \ mkdir -p $GOPATH/src/github.com/algorand/go-algorand RUN echo "vm.max_map_count = 262144" >> /etc/sysctl.conf CMD ["/bin/bash"] - diff --git a/mule.yaml b/mule.yaml index 16ba509b41..c30fd5ca51 100644 --- a/mule.yaml +++ b/mule.yaml @@ -1,102 +1,199 @@ -stages: - build-linux-amd64: +tasks: - task: docker.Version - name: linux-amd64 - arch: amd64 configFilePath: scripts/configure_dev-deps.sh - task: shell.docker.Ensure - image: algorand/go-algorand-linux - arch: amd64 - version: '{{ docker.Version.linux-amd64.version }}' + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' dockerFilePath: docker/build/cicd.Dockerfile + dependencies: docker.Version - task: docker.Make - image: algorand/go-algorand-linux - version: '{{ docker.Version.linux-amd64.version }}' - workDir: /go/src/github.com/algorand/go-algorand - target: fulltest ci-build - test-linux-amd64: - - task: docker.Version - name: linux-amd64 - arch: amd64 - configFilePath: scripts/configure_dev-deps.sh - - task: shell.docker.Ensure - image: algorand/go-algorand-linux - arch: amd64 - version: '{{ docker.Version.linux-amd64.version }}' - dockerFilePath: docker/build/cicd.Dockerfile - - task: docker.Make - image: algorand/go-algorand-linux - version: '{{ docker.Version.linux-amd64.version }}' - workDir: /go/src/github.com/algorand/go-algorand - target: ci-integration - build-linux-arm64: - - task: docker.Version - name: linux-arm64 - arch: arm64v8 - configFilePath: scripts/configure_dev-deps.sh - - task: shell.docker.Ensure - image: algorand/go-algorand-linux - arch: arm64v8 - version: '{{ docker.Version.linux-arm64.version }}' - dockerFilePath: docker/build/cicd.Dockerfile + name: build + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: ci-build - task: docker.Make - image: algorand/go-algorand-linux - version: '{{ docker.Version.linux-arm64.version }}' - workDir: /go/src/github.com/algorand/go-algorand - target: fulltest ci-build - test-linux-arm64: - - task: docker.Version - name: linux-arm64 - arch: arm64v8 - configFilePath: scripts/configure_dev-deps.sh - - task: shell.docker.Ensure - image: algorand/go-algorand-linux - arch: arm64v8 - version: '{{ docker.Version.linux-arm64.version }}' - dockerFilePath: docker/build/cicd.Dockerfile + name: fulltest + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: fulltest -j4 - task: docker.Make - image: algorand/go-algorand-linux - version: '{{ docker.Version.linux-arm64.version }}' - workDir: /go/src/github.com/algorand/go-algorand - target: ci-integration - build-linux-arm: - - task: docker.Version - name: linux-arm - arch: arm32v6 - configFilePath: scripts/configure_dev-deps.sh - - task: shell.docker.Ensure - image: algorand/go-algorand-linux - arch: arm32v6 - version: '{{ docker.Version.linux-arm.version }}' - dockerFilePath: docker/build/arm.Dockerfile + name: shorttest + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: shorttest -j4 - task: docker.Make - image: algorand/go-algorand-linux - version: '{{ docker.Version.linux-arm.version }}' - workDir: /go/src/github.com/algorand/go-algorand + name: integration-test + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: ci-integration -j4 + - task: shell.Make + name: deps + target: ci-deps + - task: shell.Make + name: build target: ci-build - test-linux-arm: - - task: docker.Version - name: linux-arm - arch: arm32v6 - configFilePath: scripts/configure_dev-deps.sh - - task: shell.docker.Ensure - image: algorand/go-algorand-linux - arch: arm32v6 - version: '{{ docker.Version.linux-arm.version }}' - dockerFilePath: docker/build/arm.Dockerfile - - task: docker.Make - image: algorand/go-algorand-linux - version: '{{ docker.Version.linux-arm.version }}' - workDir: /go/src/github.com/algorand/go-algorand - target: ci-integration - build-local: - task: shell.Make - target: ci-deps fulltest ci-build - test-local: - - task: shell.Make - target: ci-integration - release: - - task: release.notes.GenerateReleaseNotes - releaseVersion: ${GO_ALGORAND_RELEASE_VERSION} - githubPatToken: ${GITHUB_PAT_TOKEN} - githubRepoFullName: algorand/go-algorand + name: fulltest + target: fulltest -j4 + - task: shell.Make + name: shorttest + target: shorttest -j3 + - task: shell.Make + name: integration-test + target: ci-integration -j4 + - task: shell.Make + name: archive + target: archive + +jobs: + # Linux arm64 jobs + build-linux-arm64: + configs: + arch: arm64v8 + docker: + env: + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.build + test-linux-arm64-fulltest: + configs: + arch: arm64v8 + docker: + env: + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.fulltest + test-linux-arm64-shorttest: + configs: + arch: arm64v8 + docker: + env: + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.shorttest + test-linux-arm64-integration: + configs: + arch: arm64v8 + docker: + env: + - SHORTTEST=${SHORTTEST} + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.integration-test + + + + # Linux amd64 jobs + build-linux-amd64: + configs: + arch: amd64 + docker: + env: + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.build + test-linux-amd64-fulltest: + configs: + arch: amd64 + docker: + env: + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.fulltest + test-linux-amd64-shorttest: + configs: + arch: amd64 + docker: + env: + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.shorttest + test-linux-amd64-integration: + configs: + arch: amd64 + docker: + env: + - SHORTTEST=${SHORTTEST} + - TRAVIS_OS_NAME=${TRAVIS_OS_NAME} + - TRAVIS_BRANCH=${TRAVIS_BRANCH} + - TRAVIS_PULL_REQUEST=${TRAVIS_PULL_REQUEST} + - S3_RELEASE_BUCKET=${S3_RELEASE_BUCKET} + tasks: + - shell.docker.Ensure + - docker.Make.integration-test + + + + # Local jobs + build-local: + tasks: + - shell.Make.deps + - shell.Make.build + test-local-fulltest: + tasks: + - shell.Make.deps + - shell.Make.fulltest + test-local-shorttest: + tasks: + - shell.Make.deps + - shell.Make.shorttest + test-local-integration: + tasks: + - shell.Make.deps + - shell.Make.integration-test + archive-local: + tasks: + - shell.Make.deps + - shell.Make.archive + + + + # Linux arm jobs + build-linux-arm: + configs: + arch: arm32v6 + target: ci-build + tasks: + - docker.Make + test-linux-arm-shorttest: + configs: + arch: arm32v6 + target: shorttest + tasks: + - docker.Make diff --git a/network/ping_test.go b/network/ping_test.go index f719798dfe..4914917c83 100644 --- a/network/ping_test.go +++ b/network/ping_test.go @@ -60,7 +60,7 @@ func TestPing(t *testing.T) { if lastPingRoundTripTime > 0 { postPing := time.Now() testTime := postPing.Sub(prePing) - if (lastPingRoundTripTime < testTime) && (lastPingRoundTripTime > (testTime - (2 * waitStep))) { + if (lastPingRoundTripTime < testTime) { // success return } diff --git a/scripts/build_package.sh b/scripts/build_package.sh index 7e99452ee9..47772e1c8b 100755 --- a/scripts/build_package.sh +++ b/scripts/build_package.sh @@ -111,7 +111,7 @@ TOOLS_ROOT=${PKG_ROOT}/tools echo "Staging tools package files" -bin_files=("algons" "auctionconsole" "auctionmaster" "auctionminion" "coroner" "dispenser" "netgoal" "nodecfg" "pingpong" "cc_service" "cc_agent" "cc_client" "COPYING") +bin_files=("algons" "auctionconsole" "auctionmaster" "auctionminion" "coroner" "dispenser" "netgoal" "nodecfg" "pingpong" "cc_service" "cc_agent" "cc_client" "COPYING" "dsign") mkdir -p ${TOOLS_ROOT} for bin in "${bin_files[@]}"; do cp ${GOPATHBIN}/${bin} ${TOOLS_ROOT} diff --git a/scripts/build_packages.sh b/scripts/build_packages.sh index 5a196c4135..bd2592f63e 100755 --- a/scripts/build_packages.sh +++ b/scripts/build_packages.sh @@ -55,8 +55,6 @@ if [ "${PKG_ROOT}" = "" ]; then PKG_ROOT=${HOME}/node_pkg fi -rm -rf ${PKG_ROOT} - BASECHANNEL=${CHANNEL} echo Building ${#VARIATION_ARRAY[@]} variations @@ -85,6 +83,7 @@ for var in "${VARIATION_ARRAY[@]}"; do PKG_NAME=${OS}-${ARCH} PLATFORM_ROOT=${PKG_ROOT}/${CHANNEL}/${PKG_NAME} + rm -rf ${PLATFORM_ROOT} mkdir -p ${PLATFORM_ROOT} scripts/build_package.sh ${OS} ${ARCH} ${PLATFORM_ROOT} diff --git a/scripts/configure_dev.sh b/scripts/configure_dev.sh index 11ce3ac421..4c9df6ea05 100755 --- a/scripts/configure_dev.sh +++ b/scripts/configure_dev.sh @@ -1,15 +1,43 @@ #!/usr/bin/env bash set -e +HELP="Usage: $0 [-s] +Installs host level dependencies necessary to build go-algorand. + +Options: + -s Skips installing go dependencies + -f Force dependencies to be installed (May overwrite existing files) +" + +SKIP_GO_DEPS=false +FORCE=false +while getopts ":sfh" opt; do + case ${opt} in + s ) SKIP_GO_DEPS=true + ;; + f ) FORCE=true + ;; + h ) echo "${HELP}" + exit 0 + ;; + \? ) echo "${HELP}" + exit 2 + ;; + esac +done + SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" OS=$("$SCRIPTPATH"/ostype.sh) function install_or_upgrade { + if ${FORCE} ; then + BREW_FORCE="-f" + fi if brew ls --versions "$1" >/dev/null; then - HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade "$1" || true + HOMEBREW_NO_AUTO_UPDATE=1 brew upgrade ${BREW_FORCE} "$1" || true else - HOMEBREW_NO_AUTO_UPDATE=1 brew install "$1" + HOMEBREW_NO_AUTO_UPDATE=1 brew install ${BREW_FORCE} "$1" fi } @@ -21,7 +49,7 @@ if [ "${OS}" = "linux" ]; then fi sudo apt-get update - sudo apt-get install -y libboost-all-dev expect jq autoconf shellcheck sqlite3 + sudo apt-get install -y libboost-all-dev expect jq autoconf shellcheck sqlite3 python3.7-venv elif [ "${OS}" = "darwin" ]; then brew update brew tap homebrew/cask @@ -32,6 +60,11 @@ elif [ "${OS}" = "darwin" ]; then install_or_upgrade autoconf install_or_upgrade automake install_or_upgrade shellcheck + install_or_upgrade python3 +fi + +if ${SKIP_GO_DEPS} ; then + exit 0 fi "$SCRIPTPATH"/configure_dev-deps.sh diff --git a/scripts/release/mule/Makefile.mule b/scripts/release/mule/Makefile.mule index 6fef5e7ecc..3f8ba746cc 100644 --- a/scripts/release/mule/Makefile.mule +++ b/scripts/release/mule/Makefile.mule @@ -15,7 +15,7 @@ ci-deps: ci-setup: mkdir -p $(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH) -ci-test: ci-build +ci-test: ifeq ($(ARCH), amd64) RACE=-race else @@ -26,25 +26,18 @@ endif done ci-integration: - -ifeq ($(ARCH), amd64) - export NODEBINDIR=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/dev/$(OS_TYPE)-$(ARCH)/bin && \ - export PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/dev/$(OS_TYPE)-$(ARCH)/bin:$$PATH && \ - export PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/dev/$(OS_TYPE)-$(ARCH)/test-utils:$$PATH && \ - export SRCROOT=$(SRCPATH) && \ - ./test/scripts/e2e_go_tests.sh -else - export NODEBINDIR=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/dev/$(OS_TYPE)-$(ARCH)/bin && \ - export PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/dev/$(OS_TYPE)-$(ARCH)/bin:$$PATH && \ - export PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/dev/$(OS_TYPE)-$(ARCH)/test-utils:$$PATH && \ - export SRCROOT=$(SRCPATH) && \ - ./test/scripts/e2e_go_tests.sh -norace -endif - -ci-build: ci-setup buildsrc gen - PKG_ROOT=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH) \ - NO_BUILD=True VARIATIONS=$(OS_TYPE)/$(ARCH) \ - scripts/build_packages.sh $(OS_TYPE)/$(ARCH) + NODEBINDIR=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/bin \ + PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/bin:$$PATH \ + PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/tools:$$PATH \ + PATH=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/test-utils:$$PATH \ + SRCROOT=$(SRCPATH) \ + test/scripts/e2e.sh -c $(BUILDCHANNEL) -n + +ci-build: buildsrc gen ci-setup + CHANNEL=$(BUILDCHANNEL) PKG_ROOT=$(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH) NO_BUILD=True VARIATIONS=$(OS_TYPE)-$(ARCH) \ + scripts/build_packages.sh $(OS_TYPE)/$(ARCH) && \ + mkdir -p $(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/data && \ + cp gen/devnet/genesis.json $(SRCPATH)/tmp/node_pkgs/$(OS_TYPE)/$(ARCH)/$(BUILDCHANNEL)/$(OS_TYPE)-$(ARCH)/data # Builds targets from the sub-directories of ./scripts/release/mule/, such as `mule-package`, `mule-sign`, `mule-test`. # https://scene-si.org/2019/12/04/make-dynamic-makefile-targets/ diff --git a/scripts/upload_version.sh b/scripts/upload_version.sh index 14c17c2fcd..8d01c4f248 100755 --- a/scripts/upload_version.sh +++ b/scripts/upload_version.sh @@ -23,5 +23,6 @@ CHANNEL=$1 DIRECTORY=$2 BUCKET=$3 -export GOPATH=$(go env GOPATH) -${GOPATH}/bin/updater send -s "${DIRECTORY}" -c "${CHANNEL}" -b "${BUCKET}" +export GOPATH1=$(go env GOPATH | cut -d':' -f1 ) +export PATH=${PATH}:${GOPATH1}/bin +updater send -s "${DIRECTORY}" -c "${CHANNEL}" -b "${BUCKET}" diff --git a/test/e2e-go/cli/goal/expect/goalExpectCommon.exp b/test/e2e-go/cli/goal/expect/goalExpectCommon.exp index ec19b0a033..46b0322a5f 100755 --- a/test/e2e-go/cli/goal/expect/goalExpectCommon.exp +++ b/test/e2e-go/cli/goal/expect/goalExpectCommon.exp @@ -141,15 +141,15 @@ proc ::AlgorandGoal::StartNetwork { NETWORK_NAME NETWORK_TEMPLATE TEST_ALGO_DIR set ::GLOBAL_NETWORK_NAME $NETWORK_NAME # Running on ARM64, it seems that network creation is pretty slow. - # 30 second won't be enough here, so I'm changing this to 90 seconds. - set timeout 90 + # 30 second won't be enough here, so I'm changing this to 120 seconds. + set timeout 120 if { [catch { # Create network puts "network create $NETWORK_NAME" spawn goal network create --network $NETWORK_NAME --template $NETWORK_TEMPLATE --datadir $TEST_ALGO_DIR --rootdir $TEST_ROOT_DIR expect { - timeout { close; ::AlgorandGoal::Abort "Timed out creating network" } + timeout { close; ::AlgorandGoal::Abort "Timed out creating network with timeout: $timeout" } "^Network $NETWORK_NAME created under.*" { puts "Network $NETWORK_NAME created" ; close } close } @@ -205,6 +205,7 @@ proc ::AlgorandGoal::StopNetwork { NETWORK_NAME TEST_ALGO_DIR TEST_ROOT_DIR } { # Create a new wallet proc ::AlgorandGoal::CreateWallet { WALLET_NAME WALLET_PASSWORD TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { set WALLET_PASS_PHRASE "NOT SET" spawn goal wallet new $WALLET_NAME -d $TEST_PRIMARY_NODE_DIR @@ -237,6 +238,7 @@ proc ::AlgorandGoal::CreateWallet { WALLET_NAME WALLET_PASSWORD TEST_PRIMARY_NOD # Verify that the wallet exists proc ::AlgorandGoal::VerifyWallet { WALLET_NAME TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { spawn goal wallet list -d $TEST_PRIMARY_NODE_DIR expect { @@ -249,6 +251,7 @@ proc ::AlgorandGoal::VerifyWallet { WALLET_NAME TEST_PRIMARY_NODE_DIR } { } proc ::AlgorandGoal::RecoverWallet { NEW_WALLET_NAME WALLET_PASSPHRASE NEW_WALLET_PASSWORD TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { spawn goal wallet new -r $NEW_WALLET_NAME -d $TEST_PRIMARY_NODE_DIR expect { @@ -273,6 +276,7 @@ proc ::AlgorandGoal::RecoverWallet { NEW_WALLET_NAME WALLET_PASSPHRASE NEW_WALLE # Associate a new account with a specific wallet proc ::AlgorandGoal::CreateAccountForWallet { WALLET_NAME WALLET_PASSWORD TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { spawn goal account new -w $WALLET_NAME -d $TEST_PRIMARY_NODE_DIR while 1 { @@ -291,6 +295,7 @@ proc ::AlgorandGoal::CreateAccountForWallet { WALLET_NAME WALLET_PASSWORD TEST_P # Verify that account exists proc ::AlgorandGoal::VerifyAccount { WALLET_NAME WALLET_PASSWORD ACCOUNT_ADDRESS TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { spawn goal account list -w $WALLET_NAME -d $TEST_PRIMARY_NODE_DIR while 1 { @@ -308,12 +313,14 @@ proc ::AlgorandGoal::VerifyAccount { WALLET_NAME WALLET_PASSWORD ACCOUNT_ADDRESS # Delete an account proc ::AlgorandGoal::DeleteAccount { WALLET_NAME ACCOUNT_ADDRESS } { + set timeout 60 spawn goal account delete --wallet $WALLET_NAME --address $ACCOUNT_ADDRESS expect {*} } #Select an account from the Wallet proc ::AlgorandGoal::GetAccountAddress { WALLET_NAME TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { spawn goal account list -w $WALLET_NAME -d $TEST_PRIMARY_NODE_DIR expect { @@ -329,6 +336,7 @@ proc ::AlgorandGoal::GetAccountAddress { WALLET_NAME TEST_PRIMARY_NODE_DIR } { # Return the Account Balance proc ::AlgorandGoal::GetAccountBalance { WALLET_NAME ACCOUNT_ADDRESS TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [ catch { spawn goal account balance -w $WALLET_NAME -a $ACCOUNT_ADDRESS -d $TEST_PRIMARY_NODE_DIR expect { @@ -344,6 +352,7 @@ proc ::AlgorandGoal::GetAccountBalance { WALLET_NAME ACCOUNT_ADDRESS TEST_PRIMAR # Return the Account Rewards proc ::AlgorandGoal::GetAccountRewards { WALLET_NAME ACCOUNT_ADDRESS TEST_PRIMARY_NODE_DIR } { + set timeout 60 spawn goal account rewards -w $WALLET_NAME -a $ACCOUNT_ADDRESS -d $TEST_PRIMARY_NODE_DIR expect { timeout { ::AlgorandGoal::Abort "Timed out retrieving account rewards for wallet $WALLET_NAME and account $ACCOUNT_ADDRESS" } @@ -355,6 +364,7 @@ proc ::AlgorandGoal::GetAccountRewards { WALLET_NAME ACCOUNT_ADDRESS TEST_PRIMAR # Account Transfer proc ::AlgorandGoal::AccountTransfer { FROM_WALLET_NAME FROM_WALLET_PASSWORD FROM_ACCOUNT_ADDRESS TRANSFER_AMOUNT TO_ACCOUNT_ADDRESS FEE_AMOUNT TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [ catch { set TRANSACTION_ID "NOT SET" spawn goal clerk send --fee $FEE_AMOUNT --wallet $FROM_WALLET_NAME --amount $TRANSFER_AMOUNT --from $FROM_ACCOUNT_ADDRESS --to $TO_ACCOUNT_ADDRESS -d $TEST_PRIMARY_NODE_DIR -N @@ -371,6 +381,7 @@ proc ::AlgorandGoal::AccountTransfer { FROM_WALLET_NAME FROM_WALLET_PASSWORD FRO # Wait for Account to achieve given balance proc ::AlgorandGoal::WaitForAccountBalance { WALLET_NAME ACCOUNT_ADDRESS EXPECTED_BALANCE TEST_PRIMARY_NODE_DIR } { + set timeout 60 if { [catch { set i 0 while 1 { diff --git a/test/e2e-go/cli/goal/expect/goalTxValidityTest.exp b/test/e2e-go/cli/goal/expect/goalTxValidityTest.exp index f72f1c816f..6fa4d333d2 100644 --- a/test/e2e-go/cli/goal/expect/goalTxValidityTest.exp +++ b/test/e2e-go/cli/goal/expect/goalTxValidityTest.exp @@ -22,7 +22,7 @@ set FILE_COUNTER 1 proc TestLastValidInTx { CMD TX_FILE EXPECTED_LAST_VALID } { set PASSED 0 set LAST_VALID 0 - set timeout 5 + set timeout 60 eval spawn $CMD expect diff --git a/test/e2e-go/upgrades/send_receive_upgrade_test.go b/test/e2e-go/upgrades/send_receive_upgrade_test.go index 4d859b2718..ac65faf88a 100644 --- a/test/e2e-go/upgrades/send_receive_upgrade_test.go +++ b/test/e2e-go/upgrades/send_receive_upgrade_test.go @@ -181,7 +181,7 @@ func testAccountsCanSendMoneyAcrossUpgrade(t *testing.T, templatePath string) { time.Sleep(time.Second) - if time.Now().After(startTime.Add(2 * time.Minute)) { + if time.Now().After(startTime.Add(3 * time.Minute)) { a.Fail("upgrade taking too long") } } diff --git a/test/muleCI/Jenkinsfile b/test/muleCI/Jenkinsfile new file mode 100644 index 0000000000..361781be91 --- /dev/null +++ b/test/muleCI/Jenkinsfile @@ -0,0 +1,3 @@ +@Library('go-algorand-ci') _ + +muleCI('test/muleCI/mule.yaml', '0.0.9') \ No newline at end of file diff --git a/test/muleCI/mule.yaml b/test/muleCI/mule.yaml new file mode 100644 index 0000000000..4c419f1f33 --- /dev/null +++ b/test/muleCI/mule.yaml @@ -0,0 +1,199 @@ +tasks: + # Stash tasks + - task: stash.Stash + name: linux-amd64 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/linux-amd64 + globSpecs: + - tmp/node_pkgs/** + - crypto/libs/** + - gen/devnet/genesis.json + - gen/testnet/genesis.json + - gen/mainnet/genesis.json + - task: stash.Stash + name: darwin-amd64 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/darwin-amd64 + globSpecs: + - tmp/node_pkgs/** + - crypto/libs/** + - gen/devnet/genesis.json + - gen/testnet/genesis.json + - gen/mainnet/genesis.json + - task: stash.Stash + name: linux-arm64 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/linux-arm64 + globSpecs: + - tmp/node_pkgs/** + - crypto/libs/** + - gen/devnet/genesis.json + - gen/testnet/genesis.json + - gen/mainnet/genesis.json + - task: stash.Stash + name: linux-arm32 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/linux-arm32 + globSpecs: + - tmp/node_pkgs/** + - crypto/libs/** + - gen/devnet/genesis.json + - gen/testnet/genesis.json + - gen/mainnet/genesis.json + + # Unstash tasks + - task: stash.Unstash + name: linux-arm64 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/linux-arm64 + - task: stash.Unstash + name: linux-amd64 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/linux-amd64 + - task: stash.Unstash + name: darwin-amd64 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/darwin-amd64 + - task: stash.Unstash + name: linux-arm32 + bucketName: go-algorand-ci-cache + stashId: ${JENKINS_JOB_CACHE_ID}/linux-arm32 + + # Docker tasks + - task: docker.Version + configFilePath: scripts/configure_dev-deps.sh + - task: shell.docker.Ensure + name: centos + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + dockerFilePath: docker/build/cicd.centos.Dockerfile + dependencies: docker.Version + - task: shell.docker.Ensure + name: alpine + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + dockerFilePath: docker/build/cicd.alpine.Dockerfile + dependencies: docker.Version + - task: docker.Make + name: build + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: ci-build + - task: docker.Make + name: fulltest + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: fulltest -j4 + - task: docker.Make + name: integration-test + docker: + env: + - SHORTTEST=-short + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: ci-integration -j4 + - task: docker.Make + name: archive + docker: + image: algorand/go-algorand-ci-linux + version: '{{ docker.Version.outputs.version }}' + workDir: /go/src/github.com/algorand/go-algorand + target: ci-archive + + # Local Tasks + - task: shell.Make + name: ci-deps build + target: ci-build + - task: shell.Make + name: fulltest + target: fulltest -j4 + - task: shell.Make + name: integration-test + target: ci-integration -j4 + - task: shell.Make + name: archive + target: archive + +jobs: + # Linux amd64 jobs + build-linux-amd64: + configs: + arch: amd64 + tasks: + - shell.docker.Ensure.centos + - docker.Make.build + - stash.Stash.linux-amd64 + test-linux-amd64-integration: + configs: + arch: amd64 + tasks: + - shell.docker.Ensure.centos + - stash.Unstash.linux-amd64 + - docker.Make.integration-test + test-linux-amd64-fulltest: + configs: + arch: amd64 + tasks: + - shell.docker.Ensure.centos + - docker.Make.fulltest + + # Darwin amd64 jobs +# build-darwin-amd64: +# configs: +# arch: amd64 +# tasks: +# - shell.Make.build +# - stash.Stash.darwin-amd64 +# test-darwin-amd64-integration: +# configs: +# arch: amd64 +# tasks: +# - stash.Unstash.darwin-amd64 +# - shell.Make.integration-test +# test-darwin-amd64-fulltest: +# configs: +# arch: amd64 +# tasks: +# - shell.Make.fulltest + + # Linux arm64 jobs + build-linux-arm64: + configs: + arch: arm64v8 + tasks: + - shell.docker.Ensure.centos + - docker.Make.build + - stash.Stash.linux-arm64 + test-linux-arm64-integration: + configs: + arch: arm64v8 + tasks: + - shell.docker.Ensure.centos + - stash.Unstash.linux-arm64 + - docker.Make.integration-test + + # Linux arm32 jobs + build-linux-arm32: + configs: + arch: arm32v6 + tasks: + - shell.docker.Ensure.alpine + - docker.Make.build + - stash.Stash.linux-arm32 + + # Archive jobs + archive-linux-amd64: + configs: + arch: amd64 + tasks: + - shell.docker.Ensure.centos + - stash.Unstash.linux-amd64 + # - stash.Unstash.darwin-amd64 + - stash.Unstash.linux-arm64 + - stash.Unstash.linux-arm32 + - docker.Make.archive diff --git a/test/scripts/e2e.sh b/test/scripts/e2e.sh index 393e8ae873..50662a93d7 100755 --- a/test/scripts/e2e.sh +++ b/test/scripts/e2e.sh @@ -11,24 +11,33 @@ SCRIPT_PATH="$( cd "$(dirname "$0")" ; pwd -P )" SRCROOT="$(pwd -P)" -# Use same PKG_ROOT location as local_install.sh uses. -PKG_ROOT=$(pwd)/tmp/dev_pkg -rm -rf ${PKG_ROOT} # Purge existing dir if present - export CHANNEL=master -while [ "$1" != "" ]; do - case "$1" in - -c) - shift - export CHANNEL="$1" - ;; - *) - echo "Unknown option" "$1" - exit 1 - ;; - esac - shift +HELP="Usage: $0 [-v] [-u] +Script for running go-algorand e2e tests +Requires: + * pip + * python 3 + * go +Options: + -c Channel of build you are building binaries with this script + -n Run tests without building binaries (Binaries are expected in PATH) +" +NO_BUILD=false +while getopts ":c:nh" opt; do + case ${opt} in + c ) CHANNEL=$OPTARG + ;; + n ) NO_BUILD=true + GO_TEST_ARGS="-norace" + ;; + h ) echo "${HELP}" + exit 0 + ;; + \? ) echo "${HELP}" + exit 2 + ;; + esac done # export TEMPDIR=$(mktemp -d 2>/dev/null || mktemp -d -t "tmp") @@ -53,15 +62,19 @@ reset_dirs echo Killing all instances and installing current build pkill -u $(whoami) -x algod || true -./scripts/local_install.sh -c ${CHANNEL} -p ${BINDIR} -d ${DATADIR} +if ! ${NO_BUILD} ; then + ./scripts/local_install.sh -c ${CHANNEL} -p ${BINDIR} -d ${DATADIR} + export PATH=${BINDIR}:${PATH} +fi + +cp gen/devnet/genesis.json ${DATADIR} # check our install -${BINDIR}/algod -v -${BINDIR}/goal -v +algod -v +goal -v -./test/scripts/goal_subcommand_sanity.sh "${BINDIR}" "${TEMPDIR}" +./test/scripts/goal_subcommand_sanity.sh "${TEMPDIR}" -export PATH=${BINDIR}:${PATH} export GOPATH=$(go env GOPATH) # Change current directory to test/scripts so we can just use ./test.sh to exec. @@ -72,7 +85,7 @@ cd "${SCRIPT_PATH}" python3 -m venv ${TEMPDIR}/ve . ${TEMPDIR}/ve/bin/activate ${TEMPDIR}/ve/bin/pip3 install --upgrade pip -${TEMPDIR}/ve/bin/pip3 install py-algorand-sdk cryptography +${TEMPDIR}/ve/bin/pip3 install --upgrade py-algorand-sdk cryptography ${TEMPDIR}/ve/bin/python3 e2e_client_runner.py e2e_subs/*.sh deactivate @@ -82,10 +95,13 @@ export TESTDIR=${TEMPDIR} export TESTDATADIR=${SRCROOT}/test/testdata export SRCROOT=${SRCROOT} -./e2e_go_tests.sh +./e2e_go_tests.sh ${GO_TEST_ARGS} rm -rf ${TEMPDIR} -rm -rf ${PKG_ROOT} + +if ! ${NO_BUILD} ; then + rm -rf ${PKG_ROOT} +fi echo "----------------------------------------------------------------------" echo " DONE: E2E" diff --git a/test/scripts/e2e_basic_start_stop.sh b/test/scripts/e2e_basic_start_stop.sh index 3f519e0378..8d9da35c9a 100755 --- a/test/scripts/e2e_basic_start_stop.sh +++ b/test/scripts/e2e_basic_start_stop.sh @@ -15,12 +15,16 @@ function update_running_count() { } function verify_at_least_one_running() { - update_running_count - if [ ${RUNNING_COUNT} -eq 0 ]; then - echo "algod expected to be running but it isn't" - exit 1 - fi - return 0 + # Starting up can take some time, so wait at least 2 seconds + for TRIES in 1 2 3 4 5; do + update_running_count + if [ ${RUNNING_COUNT} -ge 1 ]; then + return 0 + fi + sleep .4 + done + echo "at least one algod expected to be running but ${RUNNING_COUNT} are running" + exit 1 } function verify_none_running() { @@ -37,7 +41,7 @@ function verify_none_running() { } function verify_one_running() { - # Shutting down can take some time, so retry up to 2 seconds + # Starting up can take some time, so retry up to 2 seconds for TRIES in 1 2 3 4 5; do update_running_count if [ ${RUNNING_COUNT} -eq 1 ]; then @@ -55,17 +59,17 @@ verify_none_running #---------------------- # Test that we can start & stop a generic node with no overrides echo Verifying a generic node will start using goal -${BINDIR}/goal node start -d ${DATADIR} +goal node start -d ${DATADIR} verify_at_least_one_running echo Verifying we can stop it using goal -${BINDIR}/goal node stop -d ${DATADIR} +goal node stop -d ${DATADIR} verify_none_running #---------------------- # Test that we can start a generic node straight with no overrides echo Verifying a generic node will start directly -${BINDIR}/algod -d ${DATADIR} & +algod -d ${DATADIR} & verify_at_least_one_running pkill -u $(whoami) -x algod || true verify_none_running @@ -74,9 +78,9 @@ verify_none_running # Test that we can start a generic node against the datadir # but that we cannot start a second one against same datadir echo Verifying that the datadir algod lock works correctly -${BINDIR}/algod -d ${DATADIR} & +algod -d ${DATADIR} & verify_at_least_one_running -${BINDIR}/algod -d ${DATADIR} & +algod -d ${DATADIR} & verify_at_least_one_running # one should still be running verify_one_running # in fact, exactly one should still be running # clean up diff --git a/test/scripts/e2e_client_runner.py b/test/scripts/e2e_client_runner.py index 5149dffe1c..9660835e39 100755 --- a/test/scripts/e2e_client_runner.py +++ b/test/scripts/e2e_client_runner.py @@ -379,8 +379,8 @@ def main(): sys.exit(1) retcode = 0 - xrun(['goal', 'network', 'create', '-r', netdir, '-n', 'tbd', '-t', os.path.join(gopath, 'src/github.com/algorand/go-algorand/test/testdata/nettemplates/TwoNodes50EachFuture.json')], timeout=30) - xrun(['goal', 'network', 'start', '-r', netdir], timeout=30) + xrun(['goal', 'network', 'create', '-r', netdir, '-n', 'tbd', '-t', os.path.join(gopath, 'src/github.com/algorand/go-algorand/test/testdata/nettemplates/TwoNodes50EachFuture.json')], timeout=90) + xrun(['goal', 'network', 'start', '-r', netdir], timeout=90) atexit.register(goal_network_stop, netdir) env['ALGORAND_DATA'] = os.path.join(netdir, 'Node') diff --git a/test/scripts/e2e_subs/limit-swap-test.sh b/test/scripts/e2e_subs/limit-swap-test.sh index 72084b1eeb..7127a32543 100755 --- a/test/scripts/e2e_subs/limit-swap-test.sh +++ b/test/scripts/e2e_subs/limit-swap-test.sh @@ -33,7 +33,7 @@ ACCOUNT_ALGO_TRADER=$(${gcmd} clerk compile ${TEMPDIR}/limit-order-a.teal -o ${T # setup trader with Algos ${gcmd} clerk send --amount 100000000 --from ${ACCOUNT} --to ${ACCOUNT_ALGO_TRADER} -goal node wait +goal node wait --waittime 30 ${gcmd} clerk send -a 0 -t ${ZERO_ADDRESS} -c ${ACCOUNT} --from-program ${TEMPDIR}/limit-order-a.teal @@ -42,8 +42,9 @@ echo "closeout part b, asset trader" # quick expiration, test closeout ROUND=$(goal node status | grep 'Last committed block:'|awk '{ print $4 }') -TIMEOUT_ROUND=$((${ROUND} + 6)) -SETUP_ROUND=$((${ROUND} + 5)) + +SETUP_ROUND=$((${ROUND} + 10)) +TIMEOUT_ROUND=$((${SETUP_ROUND} + 1)) sed s/TMPL_ASSET/${ASSET_ID}/g < ${GOPATH}/src/github.com/algorand/go-algorand/tools/teal/templates/limit-order-b.teal.tmpl | sed s/TMPL_SWAPN/137/g | sed s/TMPL_SWAPD/31337/g | sed s/TMPL_TIMEOUT/${TIMEOUT_ROUND}/g | sed s/TMPL_OWN/${ACCOUNT}/g | sed s/TMPL_FEE/100000/g | sed s/TMPL_MINTRD/10000/g > ${TEMPDIR}/limit-order-b.teal @@ -90,8 +91,9 @@ ${gcmd} clerk rawsend -f ${TEMPDIR}/bcloseA.stx echo "test actual swap" ROUND=$(goal node status | grep 'Last committed block:'|awk '{ print $4 }') -TIMEOUT_ROUND=$((${ROUND} + 200)) + SETUP_ROUND=$((${ROUND} + 199)) +TIMEOUT_ROUND=$((${SETUP_ROUND} + 1)) sed s/TMPL_ASSET/${ASSET_ID}/g < ${GOPATH}/src/github.com/algorand/go-algorand/tools/teal/templates/limit-order-b.teal.tmpl | sed s/TMPL_SWAPN/137/g | sed s/TMPL_SWAPD/31337/g | sed s/TMPL_TIMEOUT/${TIMEOUT_ROUND}/g | sed s/TMPL_OWN/${ACCOUNT}/g | sed s/TMPL_FEE/100000/g | sed s/TMPL_MINTRD/10000/g > ${TEMPDIR}/limit-order-b.teal diff --git a/test/scripts/goal_subcommand_sanity.sh b/test/scripts/goal_subcommand_sanity.sh index 3981e6880e..82fac62e21 100755 --- a/test/scripts/goal_subcommand_sanity.sh +++ b/test/scripts/goal_subcommand_sanity.sh @@ -3,12 +3,11 @@ echo "goal subcommand sanity check" set -e set -x -BINDIR=$1 -TEMPDIR=$2 +TEMPDIR=$1 # Run all `goal ... -h` commands. # This will make sure they work and that there are no conflicting subcommand options. -${BINDIR}/goal helptest > ${TEMPDIR}/helptest +goal helptest > ${TEMPDIR}/helptest if bash -x -e ${TEMPDIR}/helptest > ${TEMPDIR}/helptest.out 2>&1; then # ok echo "goal subcommands ok" diff --git a/test/scripts/testrunid.py b/test/scripts/testrunid.py index d9069a0a16..a1f698f5e9 100755 --- a/test/scripts/testrunid.py +++ b/test/scripts/testrunid.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Computes a name to use to identify a current test run, based on timestamp: # D[DD]HHMMSS @@ -7,8 +7,10 @@ # This mimics the BuildNumber so it can be correlated (ie this is [BuildNumber]MMSS) from datetime import datetime +import time epoch = datetime(2018, 5, 25, 0, 0, 0) d1 = datetime.utcnow() delta = d1 - epoch -print("%d%02d%02d%02d" % (delta.days, d1.hour, d1.minute, d1.second)) + +print(f"{delta.days}{d1.hour}-{int(round(time.time() * 1000))}")