Skip to content

Revert "sqlparser: introduce custom formatting options" #97

Revert "sqlparser: introduce custom formatting options"

Revert "sqlparser: introduce custom formatting options" #97

name: Upgrade Downgrade Testing - Backups - Manual
on:
push:
pull_request:
concurrency:
group: format('{0}-{1}', ${{ github.ref }}, 'Upgrade Downgrade Testing - Backups - Manual')
cancel-in-progress: true
jobs:
get_upgrade_downgrade_label:
timeout-minutes: 5
if: github.repository == 'vitessio/vitess'
name: Get the Upgrade Downgrade pull request label
runs-on: ubuntu-latest
outputs:
hasLabel: ${{ steps.check_label.outputs.hasLabel }}
steps:
- name: Check Label for PR
if: github.event_name == 'pull_request'
uses: Dreamcodeio/pr-has-label-action@master
id: check_label
with:
label: Skip Upgrade Downgrade
get_latest_release:
if: always() && (github.event_name != 'pull_request' || needs.get_upgrade_downgrade_label.outputs.hasLabel != 'true')
name: Get latest release
runs-on: ubuntu-latest
needs:
- get_upgrade_downgrade_label
outputs:
latest_release: ${{ steps.output-latest-release-branch.outputs.latest_release_branch }}
steps:
- name: Check out to HEAD
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Set output with latest release branch
id: output-latest-release-branch
run: |
latest_release_branch=$(./tools/get_latest_release.sh ${{github.base_ref}})
echo $latest_release_branch
echo "::set-output name=latest_release_branch::${latest_release_branch}"
# This job usually execute in ± 20 minutes
upgrade_downgrade_test_manual:
timeout-minutes: 40
if: always() && (needs.get_latest_release.result == 'success')
name: Run Upgrade Downgrade Test Backup Manual
runs-on: ubuntu-latest
needs:
- get_upgrade_downgrade_label
- get_latest_release
steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Set up python
uses: actions/setup-python@v2
- name: Tune the OS
run: |
echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range
# TEMPORARY WHILE GITHUB FIXES THIS https://github.com/actions/virtual-environments/issues/3185
- name: Add the current IP address, long hostname and short hostname record to /etc/hosts file
run: |
echo -e "$(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)\t$(hostname -f) $(hostname -s)" | sudo tee -a /etc/hosts
# DON'T FORGET TO REMOVE CODE ABOVE WHEN ISSUE IS ADRESSED!
- name: Get base dependencies
run: |
sudo DEBIAN_FRONTEND="noninteractive" apt-get update
# Uninstall any previously installed MySQL first
sudo systemctl stop apparmor
sudo DEBIAN_FRONTEND="noninteractive" apt-get remove -y --purge mysql-server mysql-client mysql-common
sudo apt-get -y autoremove
sudo apt-get -y autoclean
sudo deluser mysql
sudo rm -rf /var/lib/mysql
sudo rm -rf /etc/mysql
# Install mysql80
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 467B942D3A79BD29
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.20-1_all.deb
echo mysql-apt-config mysql-apt-config/select-server select mysql-8.0 | sudo debconf-set-selections
sudo DEBIAN_FRONTEND="noninteractive" dpkg -i mysql-apt-config*
sudo apt-get update
sudo DEBIAN_FRONTEND="noninteractive" apt-get install -y mysql-server mysql-client
# Install everything else we need, and configure
sudo apt-get install -y make unzip g++ etcd curl git wget eatmydata grep
sudo service mysql stop
sudo service etcd stop
sudo bash -c "echo '/usr/sbin/mysqld { }' > /etc/apparmor.d/usr.sbin.mysqld" # https://bugs.launchpad.net/ubuntu/+source/mariadb-10.1/+bug/1806263
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld || echo "could not remove mysqld profile"
# install JUnit report formatter
go install github.com/jstemmer/go-junit-report@latest
wget https://repo.percona.com/apt/percona-release_latest.$(lsb_release -sc)_all.deb
sudo apt-get install -y gnupg2
sudo dpkg -i percona-release_latest.$(lsb_release -sc)_all.deb
sudo apt-get update
sudo apt-get install percona-xtrabackup-24
# Checkout to the last release of Vitess
- name: Checkout to the other version's code (${{ needs.get_latest_release.outputs.latest_release }})
uses: actions/checkout@v2
with:
ref: ${{ needs.get_latest_release.outputs.latest_release }}
- name: Get dependencies for the last release
run: |
go mod download
- name: Building last release's binaries
timeout-minutes: 5
run: |
source build.env
make build
mkdir -p /tmp/vitess-build-other/
cp -R bin /tmp/vitess-build-other/
rm -Rf bin/*
# Checkout to this build's commit
- name: Checkout to commit's code
uses: actions/checkout@v2
- name: Get dependencies for this commit
run: |
go mod download
- name: Run make minimaltools
run: |
make minimaltools
- name: Building the binaries for this commit
timeout-minutes: 5
run: |
source build.env
make build
mkdir -p /tmp/vitess-build-current/
cp -R bin /tmp/vitess-build-current/
# We create a sharded Vitess cluster following the local example.
# We also insert a few rows in our three tables.
- name: Create the example Vitess cluster with all components using version N
timeout-minutes: 5
run: |
source build.env ; cd examples/local
./backups/start_cluster.sh
# Taking a backup
- name: Take a backup of all the shards
timeout-minutes: 2
run: |
source build.env ; cd examples/local
./backups/take_backups.sh
# We insert more data in every table after the backup.
# When we restore the backup made in the previous step, we do not want to see the rows we are about to insert now.
# The initial number of rows for each table is:
# - customer: 5
# - product: 2
# - corder: 5
# We shall see the same number of rows after restoring the backup.
- name: Insert more data after the backup
run: |
source build.env ; cd examples/local ; source ./env.sh
echo "insert into customer(email) values('[email protected]');" | mysql
echo "insert into product(sku, description, price) values('SKU-1009', 'description', 89);" | mysql
echo "insert into corder(customer_id, sku, price) values(1, 'SKU-1009', 100);" | mysql
# Stop all the tablets and remove their data
- name: Stop tablets
timeout-minutes: 5
run: |
source build.env ; cd examples/local
./backups/stop_tablets.sh
# We downgrade: we use the version N-1 of vttablet
- name: Downgrade - Swap binaries, use VTTablet N-1
run: |
source build.env
rm -f $PWD/bin/vttablet
cp /tmp/vitess-build-other/bin/vttablet $PWD/bin/vttablet
vttablet --version
# Starting the tablets again, they will automatically start restoring the last backup.
- name: Start new tablets and restore
timeout-minutes: 5
run: |
source build.env ; cd examples/local
./backups/restart_tablets.sh
# give enough time to the tablets to restore the backup
sleep 60
# Count the number of rows in each table to make sure the restoration is successful.
- name: Assert the number of rows in every table
run: |
source build.env ; cd examples/local ; source ./env.sh
echo "select count(sku) from product;" | mysql 2>&1| grep 2
echo "select count(email) from customer;" | mysql 2>&1| grep 5
echo "select count(sku) from corder;" | mysql 2>&1| grep 5
# We insert one more row in every table.
- name: Insert more rows in the tables
run: |
source build.env ; cd examples/local ; source ./env.sh
echo "insert into customer(email) values('[email protected]');" | mysql
echo "insert into product(sku, description, price) values('SKU-1011', 'description', 111);" | mysql
echo "insert into corder(customer_id, sku, price) values(1, 'SKU-1011', 111);" | mysql
# Taking a second backup of the cluster.
- name: Take a second backup of all the shards
timeout-minutes: 2
run: |
source build.env ; cd examples/local
./backups/take_backups.sh
# Stopping the tablets so we can perform the upgrade.
- name: Stop tablets
timeout-minutes: 5
run: |
source build.env ; cd examples/local
./backups/stop_tablets.sh
# We upgrade: we swap binaries and use the version N of the tablet.
- name: Upgrade - Swap binaries, use VTTablet N
run: |
source build.env
rm -f $PWD/bin/vttablet
cp /tmp/vitess-build-current/bin/vttablet $PWD/bin/vttablet
vttablet --version
# Starting the tablets again and restoring the previous backup.
- name: Start new tablets and restore
timeout-minutes: 5
run: |
source build.env ; cd examples/local
./backups/restart_tablets.sh
# give enough time to the tablets to restore the backup
sleep 60
# We count the number of rows in every table to check that the restore step was successful.
- name: Assert the number of rows in every table
run: |
source build.env ; cd examples/local ; source ./env.sh
echo "select count(sku) from product;" | mysql 2>&1| grep 3
echo "select count(email) from customer;" | mysql 2>&1| grep 6
echo "select count(sku) from corder;" | mysql 2>&1| grep 6
- name: Stop the Vitess cluster
if: always()
run: |
source build.env ; cd examples/local
./401_teardown.sh || true