-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sample Issue Tests against YB Versions (#2033)
Workflow that will help us detect when issues are fixed in YB: - Whenever we introduce a new issue, write a unit test asserting that it fails. - The unit test will be run against all the latest YB versions in every series that we support (2.18,2.20,2.23,2024.1,2024.2 for example) - YB fixes an issue in 2025.1.0.0. - As part of qualifying voyager for 2025.1 release, all unit tests are also run against 2025.1. Since the issue was fixed, "assert that it fails" will fail. - This prompts us to a. Add MinimumVersionsFixedIn[2025.1] = 2025.1.0.0 to the issue. b. Write a unit test that asserts that parserDetector.GetAllIssues(..., 2025.1) does not return an issue of that type. - The failing unit test will now start passing because it takes into account MinimumVersionsFixedIn[2025.1]. (this part is not implemented yet)
- Loading branch information
1 parent
b8f6c84
commit f3b63ce
Showing
5 changed files
with
183 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Go | ||
|
||
on: | ||
push: | ||
branches: ['main', '*.*-dev', '*.*.*-dev'] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
|
||
test-issues-against-all-yb-versions: | ||
strategy: | ||
matrix: | ||
version: [2.23.1.0-b220, 2024.1.3.1-b8, 2.20.8.0-b53, 2.18.9.0-b17] | ||
env: | ||
YB_VERSION: ${{ matrix.version }} | ||
YB_CONN_STR: "postgres://yugabyte:yugabyte@127.0.0.1:5433/yugabyte" | ||
|
||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v3 | ||
with: | ||
go-version: "1.23.1" | ||
|
||
- name: Setup YugabyteDB | ||
run: | | ||
# using s3 release instead of docker image to allow testing against un-released versions | ||
wget https://s3.us-west-2.amazonaws.com/releases.yugabyte.com/${YB_VERSION}/yugabyte-${YB_VERSION}-centos-x86_64.tar.gz | ||
mkdir -p yugabyte-${YB_VERSION} | ||
tar -xvzf yugabyte-${YB_VERSION}-centos-x86_64.tar.gz -C yugabyte-${YB_VERSION} --strip-components=1 | ||
yugabyte-${YB_VERSION}/bin/yugabyted start --advertise_address 127.0.0.1 | ||
sleep 20 | ||
- name: Test YugabyteDB connection | ||
run: | | ||
psql "${YB_CONN_STR}" -c "SELECT version();" | ||
- name: Build | ||
run: | | ||
cd yb-voyager | ||
go build -v ./... | ||
- name: Test Issues Against YB Version | ||
run: | | ||
cd yb-voyager | ||
go test -v -run '^TestDDLIssuesInYBVersion$' ./... | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
Copyright (c) YugabyteDB, 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. | ||
*/ | ||
package queryissue | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/jackc/pgx/v5" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/testcontainers/testcontainers-go/modules/yugabytedb" | ||
) | ||
|
||
var ( | ||
yugabytedbContainer *yugabytedb.Container | ||
yugabytedbConnStr string | ||
versions = []string{} | ||
) | ||
|
||
func getConn() (*pgx.Conn, error) { | ||
ctx := context.Background() | ||
var connStr string | ||
var err error | ||
if yugabytedbConnStr != "" { | ||
connStr = yugabytedbConnStr | ||
} else { | ||
connStr, err = yugabytedbContainer.YSQLConnectionString(ctx, "sslmode=disable") | ||
if err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
conn, err := pgx.Connect(ctx, connStr) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return conn, nil | ||
} | ||
|
||
func testXMLFunctionIssue(t *testing.T) { | ||
ctx := context.Background() | ||
conn, err := getConn() | ||
assert.NoError(t, err) | ||
|
||
defer conn.Close(context.Background()) | ||
_, err = conn.Exec(ctx, "SELECT xmlconcat('<abc/>', '<bar>foo</bar>')") | ||
assert.ErrorContains(t, err, "unsupported XML feature") | ||
} | ||
|
||
func testStoredGeneratedFunctionsIssue(t *testing.T) { | ||
ctx := context.Background() | ||
conn, err := getConn() | ||
assert.NoError(t, err) | ||
|
||
defer conn.Close(context.Background()) | ||
_, err = conn.Exec(ctx, ` | ||
CREATE TABLE rectangles ( | ||
id SERIAL PRIMARY KEY, | ||
length NUMERIC NOT NULL, | ||
width NUMERIC NOT NULL, | ||
area NUMERIC GENERATED ALWAYS AS (length * width) STORED | ||
)`) | ||
assert.ErrorContains(t, err, "syntax error") | ||
} | ||
|
||
func testUnloggedTableIssue(t *testing.T) { | ||
ctx := context.Background() | ||
conn, err := getConn() | ||
assert.NoError(t, err) | ||
|
||
defer conn.Close(context.Background()) | ||
_, err = conn.Exec(ctx, "CREATE UNLOGGED TABLE unlogged_table (a int)") | ||
assert.ErrorContains(t, err, "UNLOGGED database object not supported yet") | ||
} | ||
|
||
func TestDDLIssuesInYBVersion(t *testing.T) { | ||
ybVersion := os.Getenv("YB_VERSION") | ||
if ybVersion == "" { | ||
panic("YB_VERSION env variable is not set. Set YB_VERSIONS=2024.1.3.0-b105 for example") | ||
} | ||
|
||
yugabytedbConnStr = os.Getenv("YB_CONN_STR") | ||
if yugabytedbConnStr == "" { | ||
// spawn yugabytedb container | ||
var err error | ||
ctx := context.Background() | ||
yugabytedbContainer, err = yugabytedb.Run( | ||
ctx, | ||
"yugabytedb/yugabyte:"+ybVersion, | ||
) | ||
assert.NoError(t, err) | ||
defer yugabytedbContainer.Terminate(context.Background()) | ||
} | ||
|
||
// run tests | ||
var success bool | ||
success = t.Run(fmt.Sprintf("%s-%s", "xml functions", ybVersion), testXMLFunctionIssue) | ||
assert.True(t, success) | ||
|
||
success = t.Run(fmt.Sprintf("%s-%s", "stored generated functions", ybVersion), testStoredGeneratedFunctionsIssue) | ||
assert.True(t, success) | ||
|
||
success = t.Run(fmt.Sprintf("%s-%s", "unlogged table", ybVersion), testUnloggedTableIssue) | ||
assert.True(t, success) | ||
|
||
} |