-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sample Issue Tests against YB Versions #2033
Merged
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5b89491
sample test
makalaaneesh 565792f
GHA workflow
makalaaneesh d87ab7e
check in test
makalaaneesh bdf528a
issue tests
makalaaneesh 44889ca
reorg tests
makalaaneesh 5b61d22
Merge branch 'main' into aneesh/issue-tests
makalaaneesh 934a654
review comment
makalaaneesh 79910c1
use yugabyted from releases.yugabyte.com to allow testsing pre-releas…
makalaaneesh 9d5d0cf
proper connection string
makalaaneesh 130c5ae
fix typo
makalaaneesh 414c02d
comment
makalaaneesh 209fe86
review comment
makalaaneesh File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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:[email protected]: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 "postgresql://yugabyte:@127.0.0.1:5433/yugabyte" -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) | ||
|
||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
psql $YB_CONN_STR -c "SELECT version();"