#! /bin/bash -e

### If set the possible values are either 'kvm' or 'azure'
export VM_PROVISIONER='kvm'
### Root password to connect to the kvm host
export ROOT_PASSWORD=${ROOT_PASSWORD:-M6pssoqJk}
### Root password to connect to the vm host
export VM_PASSWORD=${VM_PASSWORD:-M6pssoqJk}
export VM_USERNAME=root
###### export some variables for create azure vm ############
export ADMIN_PASSWORD='M6pssoqJk'
export ADMIN_USERNAME=tidb
export CLOUD_MACHINE_TYPE=Standard_DS3
#export RESOURCE_GROUP=incubator_test_`uuidgen|cut -d'-' -f1|tr '[A-Z]' '[a-z]'`
export RESOURCE_GROUP=tep-ci
export LOCATION=chinanorth
export INSTANCE_NAMES="tep-ci-k8s-master-node00,tep-ci-k8s-node01,tep-ci-k8s-node02"
export HOST_IP="172.16.10.17"
export DOCKER_VERSION="docker-ce-18.09.3"
####### export variables for deploy k8s cluster #############
export TEST_MODE=true
export OFFLINE_INSTALL_ENABLED=true
export DOCKER_INSECURE_REGISTRIES="172.16.10.0/24"
export HARBOR_ADMIN_PASSWORD="justForTest"
export HARBOR_ENABLED=true
export CUSTOM_COREDNS_ENABLED=true
export COREDNS_VERSION=1.4.0
export KUBE_NETWORK_PLUGIN=calico
export DOWNLOAD_RUN_ONCE=false
export LOG_ENABLED=true
export MONITOR_ENABLED=true
export DOCKER_DAEMON_GRAPH=/tep/docker
export KUBE_ROOT_DIR=/tep/kubelet
export ETCD_CLIENT_PORT=2201
export ETCD_PEER_PORT=2202

export MIN_WRITE_SPEED=5
export MIN_RANDREAD_IOPS=100
export MIN_MIX_RANDREAD_IOPS=100
export MIN_MIX_WRITE_IOPS=100

### bypassing the problem of insufficient resources
export NGINX_CPU_REQUESTS=25m
export NGINX_MEMORY_REQUESTS=32m
export KUBE_PROXY_CPU_REQUESTS=150m
export KUBE_PROXY_MEMORY_REQUESTS=64m
export KUBE_APISERVER_CPU_REQUESTS=100m
export KUBE_APISERVER_MEMORY_REQUESTS=256M
export KUBE_SCHEDULER_CPU_REQUESTS=80m
export KUBE_SCHEDULER_MEMORY_REQUESTS=170M
export KUBE_CONTROLLER_CPU_REQUESTS=100m
export KUBE_CONTROLLER_MEMORY_REQUESTS=100M
#############################################################
export TRANSPORT=paramiko
export WORK_DIR=$(cd $(dirname $0)/../;pwd)

## change workspace
cd ${WORK_DIR}

echo "Start to run tests with tox"
### workaround for tox to handle interpreter directives with long lengths
export TOX_LIMITED_SHEBANG=2048
tox
echo "...PASSED"

echo "Start running integration test"
./tests/shebang-unit tests
echo "...PASSED"
