<commit_before>#!/usr/bin/env bash
set -e

##################################################
# create compute instances

gcloud compute instances create \
  bench-agent-1 \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure

gcloud compute instances create \
  bench-agent-2 \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure

gcloud compute instances create \
  bench-agent-3 \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure

export GCP_KEY_PATH=/etc/gcp-key-etcd-development.json
gcloud compute instances create \
  bench-tester \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure \
  --metadata-from-file gcp-key-etcd=${GCP_KEY_PATH}
##################################################


##################################################
gcloud compute ssh --zone=us-west1-a bench-agent-1
gcloud compute ssh --zone=us-west1-a bench-agent-2
gcloud compute ssh --zone=us-west1-a bench-agent-3
gcloud compute ssh --zone=us-west1-a bench-tester

gcloud compute instances list

<<COMMENT
10.138.0.2
10.138.0.3
10.138.0.4
10.138.0.5
COMMENT

<<COMMENT

sudo apt update -y

sudo apt install -y \
  build-essential \
  apt-utils \
  gcc \
  bash \
  bash-completion \
  tar \
  unzip \
  curl \
  wget \
  git \
  apt-transport-https \
  software-properties-common \
  libssl-dev

sudo apt upgrade -y

sudo apt autoremove
sudo apt autoclean

COMMENT

curl -L http://metadata.google.internal/computeMetadata/v1/instance/attributes/gcp-key-etcd -H 'Metadata-Flavor:Google' > /tmp/gcp-key-etcd-development.json
sudo mv /tmp/gcp-key-etcd-development.json /etc/gcp-key-etcd-development.json
head -10 /etc/gcp-key-etcd-development.json
##################################################


##################################################
ulimit -n
# ulimit -v unlimited

sudo vi /etc/security/limits.conf;

# add the following lines
* soft nofile 120000
* hard nofile 120000

sudo reboot
##################################################


##################################################
sudo rm -rf ${HOME}/*

# etcd v3.2.0
GO_VERSION=1.8.3

# etcd v3.3.0
# GO_VERSION=1.9.2

sudo rm -f /usr/local/go/bin/go && sudo rm -rf /usr/local/go && sudo rm -f /bin/go

GOOGLE_URL=https://storage.googleapis.com/golang
DOWNLOAD_URL=${GOOGLE_URL}

sudo curl -s ${DOWNLOAD_URL}/go$GO_VERSION.linux-amd64.tar.gz | sudo tar -v -C /usr/local/ -xz

if grep -q GOPATH "$(echo $HOME)/.bashrc"; then
  echo "bashrc already has GOPATH";
else
  echo "adding GOPATH to bashrc";
  echo "export GOPATH=$(echo $HOME)/go" >> ${HOME}/.bashrc;
  PATH_VAR=$PATH":/usr/local/go/bin:$(echo $HOME)/go/bin";
  echo "export PATH=$(echo $PATH_VAR)" >> ${HOME}/.bashrc;
  source ${HOME}/.bashrc;
fi

mkdir -p ${GOPATH}/bin/
source ${HOME}/.bashrc
go version
##################################################


##################################################
GIT_PATH=github.com/coreos/etcd

USER_NAME=coreos
BRANCH_NAME=release-3.2
# BRANCH_NAME=release-3.3

rm -rf ${GOPATH}/src/${GIT_PATH}
mkdir -p ${GOPATH}/src/github.com/coreos

git clone https://github.com/${USER_NAME}/etcd \
  --branch ${BRANCH_NAME} \
  ${GOPATH}/src/${GIT_PATH}

cd ${GOPATH}/src/${GIT_PATH}

# v3.2.0
git reset --hard 66722b1ada68fcd5227db853ee92003169a975c8

# v3.3.0 RC+
# git reset --hard 58c402a47bc5ad46fa748ce666257b45b06b1444

GO_BUILD_FLAGS="-v" ./build

${GOPATH}/src/${GIT_PATH}/bin/etcd --version
${GOPATH}/src/${GIT_PATH}/bin/etcdctl --version

cp ${GOPATH}/src/${GIT_PATH}/bin/etcd ${GOPATH}/bin/etcd
sudo cp ${GOPATH}/src/${GIT_PATH}/bin/etcd /etcd

cp ${GOPATH}/src/${GIT_PATH}/bin/etcdctl ${GOPATH}/bin/etcdctl
sudo cp ${GOPATH}/src/${GIT_PATH}/bin/etcdctl /etcdctl

${GOPATH}/bin/etcd --version
ETCDCTL_API=3 ${GOPATH}/bin/etcdctl version
etcd --version
ETCDCTL_API=3 etcdctl version
##################################################


##################################################
USER_NAME=gyuho
BRANCH_NAME=new-test
cd $HOME
rm -rf ${HOME}/go/src/github.com/coreos/dbtester<commit_msg>scripts: use dbtester master branch<commit_after>#!/usr/bin/env bash
set -e

##################################################
# create compute instances

gcloud compute instances create \
  bench-agent-1 \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure

gcloud compute instances create \
  bench-agent-2 \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure

gcloud compute instances create \
  bench-agent-3 \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure

export GCP_KEY_PATH=/etc/gcp-key-etcd-development.json
gcloud compute instances create \
  bench-tester \
  --custom-cpu=16 \
  --custom-memory=60 \
  --image-family=ubuntu-1710 \
  --image-project=ubuntu-os-cloud \
  --boot-disk-size=300 \
  --boot-disk-type="pd-ssd" \
  --network dbtester \
  --zone us-west1-a \
  --maintenance-policy=MIGRATE \
  --restart-on-failure \
  --metadata-from-file gcp-key-etcd=${GCP_KEY_PATH}
##################################################


##################################################
gcloud compute ssh --zone=us-west1-a bench-agent-1
gcloud compute ssh --zone=us-west1-a bench-agent-2
gcloud compute ssh --zone=us-west1-a bench-agent-3
gcloud compute ssh --zone=us-west1-a bench-tester

gcloud compute instances list

<<COMMENT
10.138.0.2
10.138.0.3
10.138.0.4
10.138.0.5
COMMENT

<<COMMENT

sudo apt update -y

sudo apt install -y \
  build-essential \
  apt-utils \
  gcc \
  bash \
  bash-completion \
  tar \
  unzip \
  curl \
  wget \
  git \
  apt-transport-https \
  software-properties-common \
  libssl-dev

sudo apt upgrade -y

sudo apt autoremove
sudo apt autoclean

COMMENT

curl -L http://metadata.google.internal/computeMetadata/v1/instance/attributes/gcp-key-etcd -H 'Metadata-Flavor:Google' > /tmp/gcp-key-etcd-development.json
sudo mv /tmp/gcp-key-etcd-development.json /etc/gcp-key-etcd-development.json
head -10 /etc/gcp-key-etcd-development.json
##################################################


##################################################
ulimit -n
# ulimit -v unlimited

sudo vi /etc/security/limits.conf;

# add the following lines
* soft nofile 120000
* hard nofile 120000

sudo reboot
##################################################


##################################################
sudo rm -rf ${HOME}/*

# etcd v3.2.0
GO_VERSION=1.8.3

# etcd v3.3.0
# GO_VERSION=1.9.2

sudo rm -f /usr/local/go/bin/go && sudo rm -rf /usr/local/go && sudo rm -f /bin/go

GOOGLE_URL=https://storage.googleapis.com/golang
DOWNLOAD_URL=${GOOGLE_URL}

sudo curl -s ${DOWNLOAD_URL}/go$GO_VERSION.linux-amd64.tar.gz | sudo tar -v -C /usr/local/ -xz

if grep -q GOPATH "$(echo $HOME)/.bashrc"; then
  echo "bashrc already has GOPATH";
else
  echo "adding GOPATH to bashrc";
  echo "export GOPATH=$(echo $HOME)/go" >> ${HOME}/.bashrc;
  PATH_VAR=$PATH":/usr/local/go/bin:$(echo $HOME)/go/bin";
  echo "export PATH=$(echo $PATH_VAR)" >> ${HOME}/.bashrc;
  source ${HOME}/.bashrc;
fi

mkdir -p ${GOPATH}/bin/
source ${HOME}/.bashrc
go version
##################################################


##################################################
GIT_PATH=github.com/coreos/etcd

USER_NAME=coreos
BRANCH_NAME=release-3.2
# BRANCH_NAME=release-3.3

rm -rf ${GOPATH}/src/${GIT_PATH}
mkdir -p ${GOPATH}/src/github.com/coreos

git clone https://github.com/${USER_NAME}/etcd \
  --branch ${BRANCH_NAME} \
  ${GOPATH}/src/${GIT_PATH}

cd ${GOPATH}/src/${GIT_PATH}

# v3.2.0
git reset --hard <PASSWORD>

# v3.3.0 RC+
# git reset --hard <PASSWORD>6<PASSWORD>b06b1444

GO_BUILD_FLAGS="-v" ./build

${GOPATH}/src/${GIT_PATH}/bin/etcd --version
${GOPATH}/src/${GIT_PATH}/bin/etcdctl --version

cp ${GOPATH}/src/${GIT_PATH}/bin/etcd ${GOPATH}/bin/etcd
sudo cp ${GOPATH}/src/${GIT_PATH}/bin/etcd /etcd

cp ${GOPATH}/src/${GIT_PATH}/bin/etcdctl ${GOPATH}/bin/etcdctl
sudo cp ${GOPATH}/src/${GIT_PATH}/bin/etcdctl /etcdctl

${GOPATH}/bin/etcd --version
ETCDCTL_API=3 ${GOPATH}/bin/etcdctl version
etcd --version
ETCDCTL_API=3 etcdctl version
##################################################


##################################################
USER_NAME=coreos
BRANCH_NAME=master
cd $HOME
rm -rf ${HOME}/go/src/github.com/coreos/dbtester
{'fraction_non_alphanumeric': 0.2635626688838079, 'fraction_numerical': 0.03273747661608813, 'mean_word_length': 3.5736692015209126, 'pattern_counts': {'":': 2, '<': 14, '<?xml version=': 0, '>': 16, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 8, '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': '2209348', 'n_tokens_mistral': 3839, 'n_tokens_neox': 3569, 'n_words': 633}