From 13b765f50cfcaa3655a8076dea312c4a021292f5 Mon Sep 17 00:00:00 2001 From: GuptaManan100 Date: Mon, 22 Feb 2021 22:29:22 +0530 Subject: [PATCH 1/3] added script to tools for checking that make sizegen has been run Signed-off-by: GuptaManan100 --- go/vt/sqlparser/cached_size.go | 4 +-- go/vt/vtgate/engine/cached_size.go | 2 +- tools/check_make_sizegen.sh | 47 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+), 3 deletions(-) create mode 100755 tools/check_make_sizegen.sh diff --git a/go/vt/sqlparser/cached_size.go b/go/vt/sqlparser/cached_size.go index ad4cbe32662..30b1b680026 100644 --- a/go/vt/sqlparser/cached_size.go +++ b/go/vt/sqlparser/cached_size.go @@ -553,7 +553,7 @@ func (cached *CreateTable) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(57) + size += int64(65) } // field Table vitess.io/vitess/go/vt/sqlparser.TableName size += cached.Table.CachedSize(false) @@ -666,7 +666,7 @@ func (cached *DropTable) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(25) + size += int64(33) } // field FromTables vitess.io/vitess/go/vt/sqlparser.TableNames { diff --git a/go/vt/vtgate/engine/cached_size.go b/go/vt/vtgate/engine/cached_size.go index 136ce2b84f1..2278127a81c 100644 --- a/go/vt/vtgate/engine/cached_size.go +++ b/go/vt/vtgate/engine/cached_size.go @@ -78,7 +78,7 @@ func (cached *DDL) CachedSize(alloc bool) int64 { } size := int64(0) if alloc { - size += int64(56) + size += int64(57) } // field Keyspace *vitess.io/vitess/go/vt/vtgate/vindexes.Keyspace size += cached.Keyspace.CachedSize(true) diff --git a/tools/check_make_sizegen.sh b/tools/check_make_sizegen.sh new file mode 100755 index 00000000000..edcff23a5e3 --- /dev/null +++ b/tools/check_make_sizegen.sh @@ -0,0 +1,47 @@ +#!/bin/bash +# +# Validate that the current version of the generated cache_size files match the output +# generated by sizegen. +# +# This is used in Travis to verify that the currently committed version was +# generated with the proper cache_size files. + +source build.env + +TMP="/tmp/cached_size.$$.go" +ALL_FILES=$(find . -name "cached_size.go") + +set +e + +for SRC in $ALL_FILES +do + TMP="/tmp/"$(echo "$SRC" | sed 's/\//_/g' | sed "s/cached_size.go/cached_size_$$.go/g") + mv "$SRC" "$TMP" +done + +make sizegen + +STATUS=0 + +for SRC in $ALL_FILES +do + TMP="/tmp/"$(echo "$SRC" | sed 's/\//_/g' | sed "s/cached_size.go/cached_size_$$.go/g") + + if [ ! -f "$SRC" ]; then + mv "$TMP" "$SRC" + continue + fi + + if ! diff -q "$SRC" "$TMP" > /dev/null ; then + echo "ERROR: Regenerated file for $SRC does not match the current version:" + diff -u "$SRC" "$TMP" + + echo + echo "Please re-run 'make sizegen' to generate." + STATUS=1 + fi + mv "$TMP" "$SRC" +done + +exit $STATUS + From 0ecaed17d27bbfcd5297191b01e91a70fe46d66d Mon Sep 17 00:00:00 2001 From: GuptaManan100 Date: Mon, 22 Feb 2021 22:31:26 +0530 Subject: [PATCH 2/3] added github workflow for checking that make sizegen has been run Signed-off-by: GuptaManan100 --- .github/workflows/check_make_sizegen.yml | 35 ++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/check_make_sizegen.yml diff --git a/.github/workflows/check_make_sizegen.yml b/.github/workflows/check_make_sizegen.yml new file mode 100644 index 00000000000..f7524ec4d3f --- /dev/null +++ b/.github/workflows/check_make_sizegen.yml @@ -0,0 +1,35 @@ +name: check_make_parser +on: [push, pull_request] +jobs: + + build: + name: Check Make Sizegen + runs-on: ubuntu-latest + steps: + + - name: Set up Go + uses: actions/setup-go@v1 + with: + go-version: 1.15 + + - name: Check out code + uses: actions/checkout@v2 + + - name: Get dependencies + run: | + sudo apt-get update + sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget + 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 + + - name: Run make minimaltools + run: | + make minimaltools + + - name: check_make_sizegen + run: | + tools/check_make_sizegen.sh + From 1db70ca90c15541305321e86474decc0af3b16dc Mon Sep 17 00:00:00 2001 From: GuptaManan100 Date: Mon, 22 Feb 2021 22:35:36 +0530 Subject: [PATCH 3/3] fixed name Signed-off-by: GuptaManan100 --- .github/workflows/check_make_sizegen.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_make_sizegen.yml b/.github/workflows/check_make_sizegen.yml index f7524ec4d3f..b8eef13acf4 100644 --- a/.github/workflows/check_make_sizegen.yml +++ b/.github/workflows/check_make_sizegen.yml @@ -1,4 +1,4 @@ -name: check_make_parser +name: check_make_sizegen on: [push, pull_request] jobs: