Skip to content

Commit

Permalink
[release-18] Vitess tester workflow (#16127) (#16419)
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
Signed-off-by: Florent Poinsard <35779988+frouioui@users.noreply.github.com>
Co-authored-by: Florent Poinsard <35779988+frouioui@users.noreply.github.com>
  • Loading branch information
GuptaManan100 and frouioui authored Jul 18, 2024
1 parent adf7970 commit e680536
Show file tree
Hide file tree
Showing 5 changed files with 1,360 additions and 0 deletions.
171 changes: 171 additions & 0 deletions .github/workflows/vitess_tester_vtgate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# DO NOT MODIFY: THIS FILE IS GENERATED USING "make generate_ci_workflows"

name: Vitess Tester (vtgate)
on: [push, pull_request]
concurrency:
group: format('{0}-{1}', ${{ github.ref }}, 'Vitess Tester (vtgate)')
cancel-in-progress: true

permissions: read-all

env:
LAUNCHABLE_ORGANIZATION: "vitess"
LAUNCHABLE_WORKSPACE: "vitess-app"
GITHUB_PR_HEAD_SHA: "${{ github.event.pull_request.head.sha }}"

jobs:
build:
name: Run endtoend tests on Vitess Tester (vtgate)
runs-on: gh-hosted-runners-4cores-1

steps:
- name: Skip CI
run: |
if [[ "${{contains( github.event.pull_request.labels.*.name, 'Skip CI')}}" == "true" ]]; then
echo "skipping CI due to the 'Skip CI' label"
exit 1
fi
- name: Check if workflow needs to be skipped
id: skip-workflow
run: |
skip='false'
if [[ "${{github.event.pull_request}}" == "" ]] && [[ "${{github.ref}}" != "refs/heads/main" ]] && [[ ! "${{github.ref}}" =~ ^refs/heads/release-[0-9]+\.[0-9]$ ]] && [[ ! "${{github.ref}}" =~ "refs/tags/.*" ]]; then
skip='true'
fi
echo Skip ${skip}
echo "skip-workflow=${skip}" >> $GITHUB_OUTPUT
PR_DATA=$(curl -s\
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}")
draft=$(echo "$PR_DATA" | jq .draft -r)
echo "is_draft=${draft}" >> $GITHUB_OUTPUT
- name: Check out code
if: steps.skip-workflow.outputs.skip-workflow == 'false'
uses: actions/checkout@v4

- name: Check for changes in relevant files
if: steps.skip-workflow.outputs.skip-workflow == 'false'
uses: dorny/paths-filter@v3.0.1
id: changes
with:
token: ''
filters: |
end_to_end:
- 'go/**/*.go'
- 'go/vt/sidecardb/**/*.sql'
- 'go/test/endtoend/onlineddl/vrepl_suite/**'
- 'test.go'
- 'Makefile'
- 'build.env'
- 'go.sum'
- 'go.mod'
- 'proto/*.proto'
- 'tools/**'
- 'config/**'
- 'bootstrap.sh'
- '.github/workflows/vitess_tester_vtgate.yml'
- name: Set up Go
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
uses: actions/setup-go@v5
with:
go-version: 1.22.5

- name: Set up python
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
uses: actions/setup-python@v5

- name: Tune the OS
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
run: |
# Limit local port range to not use ports that overlap with server side
# ports that we listen on.
sudo sysctl -w net.ipv4.ip_local_port_range="22768 65535"
# Increase the asynchronous non-blocking I/O. More information at https://dev.mysql.com/doc/refman/5.7/en/innodb-parameters.html#sysvar_innodb_use_native_aio
echo "fs.aio-max-nr = 1048576" | sudo tee -a /etc/sysctl.conf
sudo sysctl -p /etc/sysctl.conf
- name: Get dependencies
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
run: |
# Get key to latest MySQL repo
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A8D3785C
# Setup MySQL 8.0
wget -c https://dev.mysql.com/get/mysql-apt-config_0.8.29-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 -qq update
# Install everything else we need, and configure
sudo apt-get -qq install -y mysql-server mysql-client make unzip g++ etcd curl git wget eatmydata xz-utils libncurses5
sudo service mysql stop
sudo service etcd stop
sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
go mod download
# install JUnit report formatter
go install github.com/vitessio/go-junit-report@HEAD
# install vitess tester
go install github.com/vitessio/vitess-tester@eb953122baba163ed8ccaa6642458ee984f5d7e4
- name: Setup launchable dependencies
if: steps.skip-workflow.outputs.is_draft == 'false' && steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' && github.base_ref == 'main'
run: |
# Get Launchable CLI installed. If you can, make it a part of the builder image to speed things up
pip3 install --user launchable~=1.0 > /dev/null
# verify that launchable setup is all correct.
launchable verify || true
# Tell Launchable about the build you are producing and testing
launchable record build --name "$GITHUB_RUN_ID" --no-commit-collection --source .
- name: Run cluster endtoend test
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true'
timeout-minutes: 45
run: |
# We set the VTDATAROOT to the /tmp folder to reduce the file path of mysql.sock file
# which musn't be more than 107 characters long.
export VTDATAROOT="/tmp/"
source build.env
make build
set -exo pipefail
i=1
for dir in ./go/test/endtoend/vtgate/vitess_tester/*/; do
# We go over all the directories in the given path.
# If there is a vschema file there, we use it, otherwise we let vitess-tester autogenerate it.
if [ -f $dir/vschema.json ]; then
vitess-tester --sharded --xunit --test-dir $dir --vschema "$dir"vschema.json
else
vitess-tester --sharded --xunit --test-dir $dir
fi
# Number the reports by changing their file names.
mv report.xml report"$i".xml
i=$((i+1))
done
- name: Print test output and Record test result in launchable if PR is not a draft
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' && always()
run: |
if [[ "${{steps.skip-workflow.outputs.is_draft}}" == "false" ]]; then
# send recorded tests to launchable
launchable record tests --build "$GITHUB_RUN_ID" go-test . || true
fi
# print test output
cat report*.xml
- name: Test Summary
if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' && always()
uses: test-summary/action@v2
with:
paths: "report*.xml"
show: "fail, skip"
210 changes: 210 additions & 0 deletions go/test/endtoend/vtgate/vitess_tester/tpcc/tpcc.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
# The TPC-C Benchmark queries with some sample data so we can test the queries

CREATE TABLE IF NOT EXISTS warehouse (
w_id INT NOT NULL,
w_name VARCHAR(10),
w_street_1 VARCHAR(20),
w_street_2 VARCHAR(20),
w_city VARCHAR(20),
w_state CHAR(2),
w_zip CHAR(9),
w_tax DECIMAL(4, 4),
w_ytd DECIMAL(12, 2),
PRIMARY KEY (w_id)
);

CREATE TABLE IF NOT EXISTS customer (
c_id INT NOT NULL,
c_d_id INT NOT NULL,
c_w_id INT NOT NULL,
c_first VARCHAR(16),
c_middle CHAR(2),
c_last VARCHAR(16),
c_street_1 VARCHAR(20),
c_street_2 VARCHAR(20),
c_city VARCHAR(20),
c_state CHAR(2),
c_zip CHAR(9),
c_phone CHAR(16),
c_since DATETIME,
c_credit CHAR(2),
c_credit_lim DECIMAL(12, 2),
c_discount DECIMAL(4,4),
c_balance DECIMAL(12,2),
c_ytd_payment DECIMAL(12,2),
c_payment_cnt INT,
c_delivery_cnt INT,
c_data VARCHAR(500),
PRIMARY KEY(c_w_id, c_d_id, c_id),
INDEX idx_customer (c_w_id, c_d_id, c_last, c_first)
);

CREATE TABLE IF NOT EXISTS district (
d_id INT NOT NULL,
d_w_id INT NOT NULL,
d_name VARCHAR(10),
d_street_1 VARCHAR(20),
d_street_2 VARCHAR(20),
d_city VARCHAR(20),
d_state CHAR(2),
d_zip CHAR(9),
d_tax DECIMAL(4, 4),
d_ytd DECIMAL(12, 2),
d_next_o_id INT,
PRIMARY KEY (d_w_id, d_id)
);

CREATE TABLE IF NOT EXISTS history (
h_c_id INT NOT NULL,
h_c_d_id INT NOT NULL,
h_c_w_id INT NOT NULL,
h_d_id INT NOT NULL,
h_w_id INT NOT NULL,
h_date DATETIME,
h_amount DECIMAL(6, 2),
h_data VARCHAR(24),
INDEX idx_h_w_id (h_w_id),
INDEX idx_h_c_w_id (h_c_w_id)
);

CREATE TABLE IF NOT EXISTS new_orders (
no_o_id INT NOT NULL,
no_d_id INT NOT NULL,
no_w_id INT NOT NULL,
PRIMARY KEY(no_w_id, no_d_id, no_o_id)
);

CREATE TABLE IF NOT EXISTS orders (
o_id INT NOT NULL,
o_d_id INT NOT NULL,
o_w_id INT NOT NULL,
o_c_id INT,
o_entry_d DATETIME,
o_carrier_id INT,
o_ol_cnt INT,
o_all_local INT,
PRIMARY KEY(o_w_id, o_d_id, o_id),
INDEX idx_order (o_w_id, o_d_id, o_c_id, o_id)
);

CREATE TABLE IF NOT EXISTS order_line (
ol_o_id INT NOT NULL,
ol_d_id INT NOT NULL,
ol_w_id INT NOT NULL,
ol_number INT NOT NULL,
ol_i_id INT NOT NULL,
ol_supply_w_id INT,
ol_delivery_d DATETIME,
ol_quantity INT,
ol_amount DECIMAL(6, 2),
ol_dist_info CHAR(24),
PRIMARY KEY(ol_w_id, ol_d_id, ol_o_id, ol_number)
);

CREATE TABLE IF NOT EXISTS stock (
s_i_id INT NOT NULL,
s_w_id INT NOT NULL,
s_quantity INT,
s_dist_01 CHAR(24),
s_dist_02 CHAR(24),
s_dist_03 CHAR(24),
s_dist_04 CHAR(24),
s_dist_05 CHAR(24),
s_dist_06 CHAR(24),
s_dist_07 CHAR(24),
s_dist_08 CHAR(24),
s_dist_09 CHAR(24),
s_dist_10 CHAR(24),
s_ytd INT,
s_order_cnt INT,
s_remote_cnt INT,
s_data VARCHAR(50),
PRIMARY KEY(s_w_id, s_i_id)
);

CREATE TABLE IF NOT EXISTS item (
i_id INT NOT NULL,
i_im_id INT,
i_name VARCHAR(24),
i_price DECIMAL(5, 2),
i_data VARCHAR(50),
PRIMARY KEY(i_id)
);

INSERT INTO warehouse (w_id, w_name, w_street_1, w_street_2, w_city, w_state, w_zip, w_tax, w_ytd) VALUES
(1, 'Main', '123 Elm St', 'Suite 100', 'Anytown', 'CA', '12345', 0.0750, 100000.00),
(2, 'Side', '123 Storgatan', 'Suite 666', 'Uptown', 'SE', '87654', 0.0150, 200000.00);

INSERT INTO customer (c_id, c_d_id, c_w_id, c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_since, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_payment_cnt, c_delivery_cnt, c_data) VALUES
(10, 15, 1, 'John', 'Q', 'Public', '456 Oak St', 'Apt 5', 'Othertown', 'NY', '54321', '555-1234-5678', '2023-01-01 12:00:00', 'Y', 50000.00, 0.0500, -100.00, 1500.00, 15, 2, 'Frequent shopper'),
(1, 1, 5, 'Jane', 'R', 'last', '789 Pine St', 'Unit 7', 'Smalltown', 'TX', '98765', '555-8765-4321', '2023-02-02 14:30:00', 'N', 75000.00, 0.0250, 500.00, 250.00, 5, 1, 'Occasional shopper'),
(2, 1, 5, 'Jake', 'S', 'last', '101 Birch St', 'Suite 21', 'Middletown', 'FL', '32145', '555-5678-1234', '2023-03-03 16:45:00', 'Y', 100000.00, 0.1000, 200.00, 300.00, 10, 3, 'Regular shopper'),
(3, 5, 8, 'Alice', 'T', 'item_last', '102 Acacia Ave', 'Top Floor', 'Bigtown', 'CO', '12345', '555-9876-5432', '2023-04-04 18:00:00', 'N', 30000.00, 0.0750, 150.00, 100.00, 3, 1, 'Sporadic shopper'),
(4, 5, 8, 'Bob', 'U', 'item_last', '103 Maple Dr', 'Room 6', 'Laketown', 'WA', '98765', '555-6543-2109', '2023-05-05 19:15:00', 'Y', 20000.00, 0.0500, 0.00, 50.00, 2, 0, 'New shopper'),
(9, 1, 8965, 'Charlie', 'V', 'Quiet', '104 Cedar Ln', 'Basement', 'Cloudtown', 'VT', '54321', '555-3210-9876', '2023-06-06 20:30:00', 'N', 15000.00, 0.0200, 75.00, 25.00, 1, 0, 'Rare shopper'),
(5, 68, 32, 'Dan', 'W', 'Anyone', '105 Spruce Rd', 'Floor 2', 'Hilltown', 'ME', '32145', '555-4321-0987', '2023-07-07 21:45:00', 'Y', 10000.00, 0.0150, 500.00, 75.00, 5, 2, 'Ad hoc shopper');

INSERT INTO district (d_id, d_w_id, d_name, d_street_1, d_street_2, d_city, d_state, d_zip, d_tax, d_ytd, d_next_o_id) VALUES
(95, 15, 'Central', '123 Central St', 'Unit 5', 'Centerville', 'CA', '95021', 0.0850, 20000.00, 10),
(9, 896, 'Eastside', '789 East St', 'Bldg 2', 'Eastville', 'NY', '10021', 0.0750, 15000.00, 20),
(6, 21, 'Westend', '456 West Rd', 'Suite 8', 'Westtown', 'TX', '77019', 0.0650, 50000.00, 30);

INSERT INTO orders (o_id, o_d_id, o_w_id, o_c_id, o_entry_d, o_carrier_id, o_ol_cnt, o_all_local) VALUES
(10, 3, 9894, 159, '2024-04-30 12:00:00', 12, 5, 1),
(9, 3, 9894, 159, '2024-04-29 12:00:00', 15, 3, 1),
(8, 3, 9894, 159, '2024-04-28 12:00:00', null, 4, 1),
(6, 1983, 894605, 204, '2024-04-27 12:00:00', 10, 2, 0),
(2110, 1, 1, 105, '2024-04-15 10:00:00', 5, 3, 1),
(3000, 1, 1, 105, '2024-04-16 10:05:00', 6, 2, 1),
(4200, 1, 1, 105, '2024-04-17 10:10:00', 7, 1, 1);

INSERT INTO order_line (ol_o_id, ol_d_id, ol_w_id, ol_number, ol_i_id, ol_supply_w_id, ol_delivery_d, ol_quantity, ol_amount, ol_dist_info) VALUES
(1, 5, 92, 1, 101, 92, '2024-05-01 12:00:00', 5, 150.00, 'xyzabcdefghijklmnopr'),
(680, 201, 87, 1, 102, 87, '2024-05-02 13:00:00', 10, 100.00, 'yzabcdefghijklmnopqr'),
(680, 201, 87, 2, 103, 87, '2024-05-02 13:05:00', 2, 50.00, 'zabcdefghijklmnopqrs'),
(45, 156, 1, 1, 104, 1, '2024-05-03 14:00:00', 20, 200.00, 'abcdejklmnopqrsvwxyx'),
(56, 156, 1, 2, 105, 1, '2024-05-04 15:00:00', 30, 250.00, 'bcdefghiqrstuvwxyza'),
(15, 1908, 12, 1, 106, 12, '2024-05-05 16:00:00', 3, 75.00, 'cdefghijklmnopqwxyzab');

INSERT INTO stock (s_i_id, s_w_id, s_quantity, s_dist_01, s_dist_02, s_dist_03, s_dist_04, s_dist_05, s_dist_06, s_dist_07, s_dist_08, s_dist_09, s_dist_10, s_ytd, s_order_cnt, s_remote_cnt, s_data) VALUES
(101, 92, 50, 'distdata1', 'distdata2', 'distdata3', 'distdata4', 'distdata5', 'distdata6', 'distdata7', 'distdata8', 'distdata9', 'distdata10', 1000, 100, 10, 'Example data string'),
(102, 87, 30, 'distdata1', 'distdata2', 'distdata3', 'distdata4', 'distdata5', 'distdata6', 'distdata7', 'distdata8', 'distdata9', 'distdata10', 500, 50, 5, 'Another example string'),
(106, 12, 5, 'distdata1', 'distdata2', 'distdata3', 'distdata4', 'distdata5', 'distdata6', 'distdata7', 'distdata8', 'distdata9', 'distdata10', 300, 30, 3, 'Yet another string'),
(8, 1, 900, 'distdata1', 'distdata2', 'distdata3', 'distdata4', 'distdata5', 'distdata6', 'distdata7', 'distdata8', 'distdata9', 'distdata10', 800, 80, 8, 'Low stock string'),
(2198, 89, 100, 'distdata1', '', '', '', '', '', '', '', '', '', 150, 15, 1, 'Critical stock data');

INSERT INTO new_orders (no_o_id, no_d_id, no_w_id) VALUES
(10, 689, 15),
(11, 689, 15),
(12, 689, 15);

INSERT INTO item (i_id, i_im_id, i_name, i_price, i_data) VALUES
(9654, 123, 'Gadget', 199.99, 'High-quality electronic gadget'),
(9655, 124, 'Widget', 29.99, 'Durable plastic widget');

# Here follows the SELECT queries we are testing.
# The TPCC benchmark also uses INSERT, UPDATE and DELETE queries, but we are not testing those here.
-- wait_authoritative customer
-- wait_authoritative warehouse
SELECT c_discount, c_last, c_credit, w_tax FROM customer AS c JOIN warehouse AS w ON c_w_id=w_id WHERE w_id = 1 AND c_d_id = 15 AND c_id = 10;
SELECT count(c_id) namecnt FROM customer WHERE c_w_id = 5 AND c_d_id= 1 AND c_last='last';
SELECT c_id FROM customer WHERE c_w_id = 8 AND c_d_id = 5 AND c_last='item_last' ORDER BY c_first;
SELECT c_first, c_middle, c_last, c_street_1, c_street_2, c_city, c_state, c_zip, c_phone, c_credit, c_credit_lim, c_discount, c_balance, c_ytd_payment, c_since FROM customer WHERE c_w_id = 8965 AND c_d_id = 1 AND c_id = 9;
SELECT c_data FROM customer WHERE c_w_id = 32 AND c_d_id=68 AND c_id = 5;
SELECT count(c_id) namecnt FROM customer WHERE c_w_id = 870 AND c_d_id= 780 AND c_last='last';
SELECT c_balance, c_first, c_middle, c_id FROM customer WHERE c_w_id = 840 AND c_d_id= 1 AND c_last='test' ORDER BY c_first;
SELECT c_balance, c_first, c_middle, c_last FROM customer WHERE c_w_id = 15 AND c_d_id=5169 AND c_id=1;
SELECT d_next_o_id, d_tax FROM district WHERE d_w_id = 15 AND d_id = 95;
SELECT d_street_1, d_street_2, d_city, d_state, d_zip, d_name FROM district WHERE d_w_id = 896 AND d_id = 9;
SELECT d_next_o_id FROM district WHERE d_id = 6 AND d_w_id= 21;
SELECT o_id, o_carrier_id, o_entry_d FROM orders WHERE o_w_id = 9894 AND o_d_id = 3 AND o_c_id = 159 ORDER BY o_id DESC;
SELECT o_c_id FROM orders WHERE o_id = 6 AND o_d_id = 1983 AND o_w_id = 894605;
SELECT ol_i_id, ol_supply_w_id, ol_quantity, ol_amount, ol_delivery_d FROM order_line WHERE ol_w_id = 92 AND ol_d_id = 5 AND ol_o_id = 1;
SELECT SUM(ol_amount) sm FROM order_line WHERE ol_o_id = 680 AND ol_d_id = 201 AND ol_w_id = 87;
SELECT DISTINCT ol_i_id FROM order_line WHERE ol_w_id = 1 AND ol_d_id = 156 AND ol_o_id < 500 AND ol_o_id >= 56;
SELECT COUNT(DISTINCT(s.s_i_id)) FROM stock AS s JOIN order_line AS ol ON ol.ol_w_id=s.s_w_id AND ol.ol_i_id=s.s_i_id WHERE ol.ol_w_id = 12 AND ol.ol_d_id = 1908 AND ol.ol_o_id < 30 AND ol.ol_o_id >= 15 AND s.s_w_id= 12 AND s.s_quantity < 10;
SELECT count(*) FROM stock WHERE s_w_id = 1 AND s_i_id = 8 AND s_quantity < 1000;
SELECT s_quantity, s_data, s_dist_01 s_dist FROM stock WHERE s_i_id = 2198 AND s_w_id = 89;
SELECT no_o_id FROM new_orders WHERE no_d_id = 689 AND no_w_id = 15 ORDER BY no_o_id ASC LIMIT 1;
SELECT i_price, i_name, i_data FROM item WHERE i_id = 9654;
SELECT w_street_1, w_street_2, w_city, w_state, w_zip, w_name FROM warehouse WHERE w_id = 998;
Loading

0 comments on commit e680536

Please sign in to comment.