From b9715270ef95159328eae2652cd6ac4561844b37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 23 Nov 2023 16:22:26 +0100 Subject: [PATCH 1/3] Run TestCompareReservedWordsWithMySQL in CI --- .github/workflows/mysql.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/mysql.yml diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml new file mode 100644 index 0000000000000..63795695fca11 --- /dev/null +++ b/.github/workflows/mysql.yml @@ -0,0 +1,24 @@ +name: MySQL Tests + +on: [push, pull_request, workflow_dispatch] +jobs: + keywords: + runs-on: ubuntu-latest + services: + mysql: + image: mysql:8.0 + env: + MYSQL_ALLOW_EMPTY_PASSWORD: yes + MYSQL_DATABASE: test + ports: + - 3306:3306 + options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 + with: + go-version-file: 'go.mod' + - name: Run TestCompareReservedWordsWithMySQL + run: | + cd pkg/parser + go test -tags reserved_words_test -run '^TestCompareReservedWordsWithMySQL$' From 6ae16a2092f2d0cef29a377c92f36ac9584a8ded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 23 Jan 2024 16:43:14 +0100 Subject: [PATCH 2/3] Move from GitHub action to Prow --- .github/workflows/mysql.yml | 24 ------------------------ build/image/parser_test | 16 ++++++++++++++++ 2 files changed, 16 insertions(+), 24 deletions(-) delete mode 100644 .github/workflows/mysql.yml create mode 100644 build/image/parser_test diff --git a/.github/workflows/mysql.yml b/.github/workflows/mysql.yml deleted file mode 100644 index 63795695fca11..0000000000000 --- a/.github/workflows/mysql.yml +++ /dev/null @@ -1,24 +0,0 @@ -name: MySQL Tests - -on: [push, pull_request, workflow_dispatch] -jobs: - keywords: - runs-on: ubuntu-latest - services: - mysql: - image: mysql:8.0 - env: - MYSQL_ALLOW_EMPTY_PASSWORD: yes - MYSQL_DATABASE: test - ports: - - 3306:3306 - options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 - steps: - - uses: actions/checkout@v4 - - uses: actions/setup-go@v4 - with: - go-version-file: 'go.mod' - - name: Run TestCompareReservedWordsWithMySQL - run: | - cd pkg/parser - go test -tags reserved_words_test -run '^TestCompareReservedWordsWithMySQL$' diff --git a/build/image/parser_test b/build/image/parser_test new file mode 100644 index 0000000000000..80b777e63ce09 --- /dev/null +++ b/build/image/parser_test @@ -0,0 +1,16 @@ +FROM rockylinux:9 + +ENV GOLANG_VERSION 1.21.6 +ENV ARCH amd64 +ENV GOLANG_DOWNLOAD_URL https://dl.google.com/go/go$GOLANG_VERSION.linux-$ARCH.tar.gz +ENV GOPATH /home/prow/go +ENV GOROOT /usr/local/go +ENV PATH $GOPATH/bin:$GOROOT/bin:$PATH + +ADD run.sh /bin +RUN chmod 700 /bin/run.sh +RUN dnf update -y +RUN dnf install -y git mysql-server +RUN curl -fsSL "$GOLANG_DOWNLOAD_URL" -o golang.tar.gz \ + && tar -C /usr/local -xzf golang.tar.gz \ + && rm golang.tar.gz From 87900e165dc1e65328bd413102ef57e7da8355ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 23 Jan 2024 17:17:21 +0100 Subject: [PATCH 3/3] Update parser_test image and readme --- build/image/README.md | 5 ++++- build/image/parser_test | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/build/image/README.md b/build/image/README.md index b109968354940..60eb82cbbdb80 100644 --- a/build/image/README.md +++ b/build/image/README.md @@ -1,7 +1,10 @@ ## CI Image -Here is the Dockerfile for the CI image. +Here are the Dockerfiles for the CI images. - ```base``` is the base image with golang, development tools and so on. - ```centos7_jenkins``` is the production image with CI environment tool in tidb repo. it is based on ```base```. - ```.ci_bazel``` is the global default bazel config. it tell bazel where to get cache. +- ```parser_test``` is the image for running parser tests that require MySQL 8.x. + +Note that `parser_test` requires `CAP_SYS_NICE` to run. Either use `docker --cap-add=sys_nice` or add `SYS_NICE` to the capabilities under the `securityContext` when using Kubernetes. diff --git a/build/image/parser_test b/build/image/parser_test index 80b777e63ce09..4fcb559ab865f 100644 --- a/build/image/parser_test +++ b/build/image/parser_test @@ -1,3 +1,17 @@ +# Copyright 2024 PingCAP, Inc. +# +# 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. + FROM rockylinux:9 ENV GOLANG_VERSION 1.21.6