Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kamil-gwozdz/b0495a2d313a32c5895dfb70943ac828 to your computer and use it in GitHub Desktop.
Save kamil-gwozdz/b0495a2d313a32c5895dfb70943ac828 to your computer and use it in GitHub Desktop.
Script to reproduce `MAX_EXECUTION_TIME` in vitess 22.0.2
#! /bin/bash
DOCKER_CONTAINER_NAME="test-external-mysql"
MYSQL_IMAGE="mysql:8.0.35"
# cleanup any previous containers/processes
docker stop $DOCKER_CONTAINER_NAME || true
docker rm $DOCKER_CONTAINER_NAME || true
pkill -f etcd
pkill -f vttablet
rm -rf .vtdataroot
docker run --name $DOCKER_CONTAINER_NAME \
-e MYSQL_ROOT_PASSWORD=strong_password \
-p 3307:3306 \
-d $MYSQL_IMAGE
# Wait for MySQL to start
echo -n "Waiting for MySQL to start"
while ! docker exec -it $DOCKER_CONTAINER_NAME mysqladmin --protocol=TCP -uroot -pstrong_password ping --silent > /dev/null 2>&1; do
echo -n "."
sleep 1
done
echo ""
echo "MySQL is ready"
docker exec -it $DOCKER_CONTAINER_NAME mysql -u root -pstrong_password -e "CREATE DATABASE test;"
docker exec -it $DOCKER_CONTAINER_NAME mysql -u root -pstrong_password -e "CREATE TABLE test.test_table (id INT PRIMARY KEY, name VARCHAR(255));"
cat <<EOF > credentials.json
{
"root": ["strong_password"]
}
EOF
# start etcd
etcd_dir=".vtdataroot/etcd"
mkdir -p $etcd_dir
./bin/etcd \
--data-dir "${etcd_dir}" \
--listen-client-urls "http://127.0.0.1:2379" \
--advertise-client-urls "http://127.0.0.1:2379" \
> "${etcd_dir}"/etcd.out 2>&1 &
echo -n "Waiting for etcd to be ready"
while ! curl "http://127.0.0.1:2379/health" > /dev/null 2>&1; do
echo -n "."
sleep 1
done
echo ""
echo "etcd is ready"
# Add cell info
./bin/vtctldclient --server=internal AddCellInfo \
--root=/vitess/cell1 \
--server-address=127.0.0.1:2379 \
cell1
# start vttablet in unmanaged mode
./bin/vttablet \
--logtostderr=true \
--db-credentials-file=credentials.json \
--db_allprivs_user=root \
--db_app_user=root \
--db_appdebug_user=root \
--db_dba_user=root \
--db_filtered_user=root \
--db_host=127.0.0.1 \
--db_port=3307 \
--db_repl_user=root \
--db_flags=2048 \
--alsologtostderr \
--grpc_port=15999 \
--init_db_name_override=test \
--init_keyspace=test-keyspace \
--init_shard=- \
--init_tablet_type=spare \
--mysql_server_version=8.0.40-Vitess \
--port=15000 \
--restore_from_backup=false \
--service_map=grpc-queryservice,grpc-tabletmanager,grpc-updatestream \
--tablet-path=cell1-1 \
--tablet_hostname=127.0.0.1 \
--topo_global_root=/vitess/global \
--topo_global_server_address=127.0.0.1:2379 \
--topo_implementation=etcd2 \
--unmanaged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment