diff --git a/.github/workflows/cluster_endtoend_vtgate_buffer.yml b/.github/workflows/cluster_endtoend_vtgate_buffer.yml deleted file mode 100644 index 09387571174..00000000000 --- a/.github/workflows/cluster_endtoend_vtgate_buffer.yml +++ /dev/null @@ -1,118 +0,0 @@ -# DO NOT MODIFY: THIS FILE IS GENERATED USING "make generate_ci_workflows" - -name: Cluster (vtgate_buffer) -on: [push, pull_request] -concurrency: - group: format('{0}-{1}', ${{ github.ref }}, 'Cluster (vtgate_buffer)') - cancel-in-progress: true - -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 Cluster (vtgate_buffer) - runs-on: ubuntu-18.04 - - steps: - - 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 "::set-output name=skip-workflow::${skip}" - - - name: Check out code - if: steps.skip-workflow.outputs.skip-workflow == 'false' - uses: actions/checkout@v2 - - - name: Check for changes in relevant files - if: steps.skip-workflow.outputs.skip-workflow == 'false' - uses: frouioui/paths-filter@main - id: changes - with: - token: '' - filters: | - end_to_end: - - 'go/**/*.go' - - 'test.go' - - 'Makefile' - - 'build.env' - - 'go.[sumod]' - - 'proto/*.proto' - - 'tools/**' - - 'config/**' - - 'bootstrap.sh' - - '.github/workflows/cluster_endtoend_vtgate_buffer.yml' - - - name: Set up Go - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' - uses: actions/setup-go@v2 - with: - go-version: 1.18.7 - - - name: Set up python - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' - uses: actions/setup-python@v2 - - - name: Tune the OS - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' - run: | - echo '1024 65535' | sudo tee -a /proc/sys/net/ipv4/ip_local_port_range - # 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: | - sudo apt-get update - sudo apt-get install -y mysql-server mysql-client make unzip g++ etcd curl git wget eatmydata - 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 - - - name: Setup launchable dependencies - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' - 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" --source . - - - name: Run cluster endtoend test - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' - timeout-minutes: 30 - 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 - - set -x - - # run the tests however you normally do, then produce a JUnit XML file - eatmydata -- go run test.go -docker=false -follow -shard vtgate_buffer | tee -a output.txt | go-junit-report -set-exit-code > report.xml - - - name: Print test output and Record test result in launchable - if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.end_to_end == 'true' && always() - run: | - # send recorded tests to launchable - launchable record tests --build "$GITHUB_RUN_ID" go-test . || true - - # print test output - cat output.txt diff --git a/.github/workflows/static_checks_etc.yml b/.github/workflows/static_checks_etc.yml index ebebd5041cd..aee79ea34ea 100644 --- a/.github/workflows/static_checks_etc.yml +++ b/.github/workflows/static_checks_etc.yml @@ -83,8 +83,9 @@ jobs: - 'Makefile' - 'bootstrap.sh' - '.github/workflows/static_checks_etc.yml' + ci_config: + - 'test/config.json' - ## Setup and install - name: Set up Go if: steps.skip-workflow.outputs.skip-workflow == 'false' uses: actions/setup-go@v2 @@ -183,3 +184,8 @@ jobs: if: steps.skip-workflow.outputs.skip-workflow == 'false' && steps.changes.outputs.proto_changes == 'true' run: | tools/check_make_proto.sh || exit 1 + + - name: Check test/config.json + if: steps.skip-workflow.outputs.skip-workflow == 'false' && (steps.changes.outputs.go_files == 'true' || steps.changes.outputs.ci_config == 'true') + run: | + go run ./go/tools/ci-config/main.go || exit 1 diff --git a/go.sum b/go.sum index 905753d91c1..adb9c6ec5cd 100644 --- a/go.sum +++ b/go.sum @@ -136,8 +136,6 @@ github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdn github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/bndr/gotabulate v1.1.2 h1:yC9izuZEphojb9r+KYL4W9IJKO/ceIO8HDwxMA24U4c= github.com/bndr/gotabulate v1.1.2/go.mod h1:0+8yUgaPTtLRTjf49E8oju7ojpU11YmXyvq1LbPAb3U= -github.com/buger/jsonparser v0.0.0-20200322175846-f7e751efca13 h1:+qUNY4VRkEH46bLUwxCyUU+iOGJMQBVibAaYzWiwWcg= -github.com/buger/jsonparser v0.0.0-20200322175846-f7e751efca13/go.mod h1:tgcrVJ81GPSF0mz+0nu1Xaz0fazGPrmmJfJtxjbHhUQ= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= diff --git a/go/test/endtoend/utils/cmp.go b/go/test/endtoend/utils/cmp.go index 21146f1ac21..30937ade8e2 100644 --- a/go/test/endtoend/utils/cmp.go +++ b/go/test/endtoend/utils/cmp.go @@ -71,6 +71,39 @@ func (mcmp *MySQLCompare) AssertMatches(query, expected string) { } } +// AssertMatchesAnyNoCompare ensures the given query produces any one of the expected results. +// This method does not compare the mysql and vitess results together +func (mcmp *MySQLCompare) AssertMatchesAnyNoCompare(query string, expected ...string) { + mcmp.t.Helper() + + mQr, vQr := mcmp.execNoCompare(query) + got := fmt.Sprintf("%v", mQr.Rows) + valid := false + for _, e := range expected { + diff := cmp.Diff(e, got) + if diff == "" { + valid = true + break + } + } + if !valid { + mcmp.t.Errorf("MySQL Query: %s (-want +got):\n%v\nGot:%s", query, expected, got) + } + valid = false + + got = fmt.Sprintf("%v", vQr.Rows) + for _, e := range expected { + diff := cmp.Diff(e, got) + if diff == "" { + valid = true + break + } + } + if !valid { + mcmp.t.Errorf("Vitess Query: %s (-want +got):\n%v\nGot:%s", query, expected, got) + } +} + // AssertContainsError executes the query on both Vitess and MySQL. // Both clients need to return an error. The error of Vitess must be matching the given expectation. func (mcmp *MySQLCompare) AssertContainsError(query, expected string) { @@ -180,8 +213,9 @@ func (mcmp *MySQLCompare) ExecWithColumnCompare(query string) *sqltypes.Result { // ExecAllowAndCompareError executes the query against both Vitess and MySQL. // The test will pass if: -// - MySQL and Vitess both agree that there is an error -// - MySQL and Vitess did not find an error, but their results are matching +// - MySQL and Vitess both agree that there is an error +// - MySQL and Vitess did not find an error, but their results are matching +// // The result set and error produced by Vitess are returned to the caller. func (mcmp *MySQLCompare) ExecAllowAndCompareError(query string) (*sqltypes.Result, error) { mcmp.t.Helper() diff --git a/go/test/endtoend/vtgate/queries/derived/derived_test.go b/go/test/endtoend/vtgate/queries/derived/derived_test.go index 5da8d8bac9b..3ac0716fb1d 100644 --- a/go/test/endtoend/vtgate/queries/derived/derived_test.go +++ b/go/test/endtoend/vtgate/queries/derived/derived_test.go @@ -30,7 +30,7 @@ func start(t *testing.T) (utils.MySQLCompare, func()) { require.NoError(t, err) deleteAll := func() { - tables := []string{"music"} + tables := []string{"music", "user"} for _, table := range tables { _, _ = mcmp.ExecAndIgnore("delete from " + table) } @@ -46,6 +46,7 @@ func start(t *testing.T) (utils.MySQLCompare, func()) { } func TestDerivedTableWithOrderByLimit(t *testing.T) { + t.Skip("skipped for now, issue: https://github.com/vitessio/vitess/issues/11763") mcmp, closer := start(t) defer closer() @@ -56,6 +57,7 @@ func TestDerivedTableWithOrderByLimit(t *testing.T) { } func TestDerivedAggregationOnRHS(t *testing.T) { + t.Skip("skipped for now, issue: https://github.com/vitessio/vitess/issues/11703") mcmp, closer := start(t) defer closer() @@ -84,13 +86,11 @@ func TestDerivedTableWithHaving(t *testing.T) { mcmp.Exec("insert into user(id, name) values(1,'toto'), (2,'tata'), (3,'titi'), (4,'tete'), (5,'foo')") mcmp.Exec("set sql_mode = ''") - - // this is probably flaky? the id returned from the derived table could be any of the ids from user. - // works on my machine (TM) - mcmp.Exec("select /*vt+ PLANNER=Gen4 */ * from (select id from user having count(*) >= 1) s") + mcmp.AssertMatchesAnyNoCompare("select /*vt+ PLANNER=Gen4 */ * from (select id from user having count(*) >= 1) s", "[[INT64(1)]]", "[[INT64(4)]]") } func TestDerivedTableColumns(t *testing.T) { + t.Skip("skipped for now, issue: https://github.com/vitessio/vitess/issues/11763") mcmp, closer := start(t) defer closer() diff --git a/go/tools/ci-config/main.go b/go/tools/ci-config/main.go new file mode 100644 index 00000000000..d767b6f4d32 --- /dev/null +++ b/go/tools/ci-config/main.go @@ -0,0 +1,74 @@ +/* +Copyright 2022 The Vitess Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package main + +import ( + "encoding/json" + "fmt" + "log" + "os" + "strings" +) + +type Test struct { + Args []string +} + +type Config struct { + Tests map[string]*Test +} + +func main() { + content, err := os.ReadFile("./test/config.json") + if err != nil { + log.Fatal(err) + } + + tests := &Config{} + err = json.Unmarshal(content, tests) + if err != nil { + log.Fatal(err) + } + + var failedConfig []string + for name, test := range tests.Tests { + if len(test.Args) == 0 { + continue + } + path := test.Args[0] + if !strings.HasPrefix(path, "vitess.io/vitess/") { + continue + } + path = path[len("vitess.io/vitess/"):] + + stat, err := os.Stat(path) + if err != nil || !stat.IsDir() { + failedConfig = append(failedConfig, fmt.Sprintf("%s: %s", name, path)) + continue + } + } + + if len(failedConfig) > 0 { + fmt.Println("Some packages in test/config.json were not found in the codebase:") + for _, failed := range failedConfig { + fmt.Println("\t" + failed) + } + fmt.Println("\nYou must remove them from test/config.json to avoid unnecessary CI load.") + os.Exit(1) + } + fmt.Println("The file: test/config.json is clean.") +} diff --git a/test/ci_workflow_gen.go b/test/ci_workflow_gen.go index 96cc5b6c17f..c50572a801d 100644 --- a/test/ci_workflow_gen.go +++ b/test/ci_workflow_gen.go @@ -100,7 +100,6 @@ var ( "tabletmanager_throttler_custom_config", "tabletmanager_tablegc", "tabletmanager_consul", - "vtgate_buffer", "vtgate_concurrentdml", "vtgate_godriver", "vtgate_gen4", diff --git a/test/config.json b/test/config.json index 3b6377dcee9..7dfcc44bf98 100644 --- a/test/config.json +++ b/test/config.json @@ -534,15 +534,6 @@ "RetryMax": 1, "Tags": [] }, - "tabletgateway_cellalias": { - "File": "unused.go", - "Args": ["vitess.io/vitess/go/test/endtoend/tabletgateway/cellalias"], - "Command": [], - "Manual": false, - "Shard": "13", - "RetryMax": 1, - "Tags": [] - }, "tabletgateway": { "File": "unused.go", "Args": ["vitess.io/vitess/go/test/endtoend/tabletgateway"], @@ -651,6 +642,15 @@ "RetryMax": 2, "Tags": [] }, + "vtgate_queries_derived": { + "File": "unused.go", + "Args": ["vitess.io/vitess/go/test/endtoend/vtgate/queries/derived"], + "Command": [], + "Manual": false, + "Shard": "vtgate_queries", + "RetryMax": 1, + "Tags": [] + }, "vtgate_queries_aggregation": { "File": "unused.go", "Args": ["vitess.io/vitess/go/test/endtoend/vtgate/queries/aggregation"], @@ -723,15 +723,6 @@ "RetryMax": 2, "Tags": [] }, - "vtgate_buffer": { - "File": "unused.go", - "Args": ["vitess.io/vitess/go/test/endtoend/vtgate/buffer"], - "Command": [], - "Manual": false, - "Shard": "vtgate_buffer", - "RetryMax": 1, - "Tags": [] - }, "vtgate_concurrentdml": { "File": "unused.go", "Args": ["vitess.io/vitess/go/test/endtoend/vtgate/concurrentdml"], @@ -813,15 +804,6 @@ "RetryMax": 1, "Tags": [] }, - "vtgate_mysql80_derived": { - "File": "unused.go", - "Args": ["vitess.io/vitess/go/test/endtoend/vtgate/mysql80/derived"], - "Command": [], - "Manual": false, - "Shard": "mysql80", - "RetryMax": 1, - "Tags": [] - }, "vtgate_sequence": { "File": "unused.go", "Args": ["vitess.io/vitess/go/test/endtoend/vtgate/sequence"],