Skip to content
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

feat(ci): Test Vitess 5.7 and 8.0 #6928

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 20 additions & 12 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,13 @@ jobs:
fail-fast: false
matrix:
database:
- sqlite
- postgres
- mysql
- mariadb
- mssql
# - sqlite
# - postgres
# - mysql
# - mariadb
# - mssql
- vitess57
- vitess80
node: [12]

steps:
Expand Down Expand Up @@ -128,7 +130,7 @@ jobs:
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

- run: pnpm run jest integration/${{ matrix.database }} -- --forceExit --maxConcurrency=8
- run: pnpm run jest integration/${{ matrix.database }} -- --forceExit #--maxConcurrency=8
working-directory: src/packages/tests
env:
CI: true
Expand All @@ -141,6 +143,8 @@ jobs:
TEST_MYSQL_URI: mysql://root:root@localhost:3306/tests
TEST_MARIADB_URI: mysql://root:root@localhost:4306/tests
TEST_MSSQL_URI: mssql://SA:Pr1sm4_Pr1sm4@localhost:1433/master
TEST_VITESS57_URI: mysql://root:prisma@localhost:33577/test
TEST_VITESS80_URI: mysql://root:prisma@localhost:33807/test

- uses: codecov/codecov-action@v1
with:
Expand All @@ -159,11 +163,13 @@ jobs:
fail-fast: false
matrix:
database:
- sqlite
- postgres
- mysql
- mariadb
- mssql
# - sqlite
# - postgres
# - mysql
# - mariadb
# - mssql
- vitess57
- vitess80
node: [12]

steps:
Expand Down Expand Up @@ -196,7 +202,7 @@ jobs:
# - name: Setup tmate session
# uses: mxschmitt/action-tmate@v3

- run: pnpm run jest integration/${{ matrix.database }} -- --forceExit --maxConcurrency=8 --verbose
- run: pnpm run jest integration/${{ matrix.database }} -- --forceExit #--maxConcurrency=8 --verbose
working-directory: src/packages/tests
env:
CI: true
Expand All @@ -209,6 +215,8 @@ jobs:
TEST_MYSQL_URI: mysql://root:root@localhost:3306/tests
TEST_MARIADB_URI: mysql://root:root@localhost:4306/tests
TEST_MSSQL_URI: mssql://SA:Pr1sm4_Pr1sm4@localhost:1433/master
TEST_VITESS57_URI: mysql://root:prisma@localhost:33577/test
TEST_VITESS80_URI: mysql://root:prisma@localhost:33807/test

- uses: codecov/codecov-action@v1
with:
Expand Down
2 changes: 2 additions & 0 deletions TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ In the `prisma/prisma` repository we have a few places where you can write tests
- mysql
- postgresql
- sqlite
- vitess57
- vitess80
- While these tests also test the client itself, they're rather just our base to make sure that basic query engine functionality actually works in the Prisma Client
- When you want to test very specific queries for a new feature, you can write an integration test in the `client` package, as that's usually easier

Expand Down
2 changes: 1 addition & 1 deletion src/docker/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Using docker-compose for databases

This is only intended to be run in a development environment where ports 3306 / default for MySQL - 5432 / default for PostgreSQL and 4306 custom port - MariaDB are free and not used.
This is only intended to be run in a development environment where ports 3306 / default for MySQL - 5432 / default for PostgreSQL and 4306 custom port - MariaDB are free and not used. TODO Vitess

If they are already used make sure to change the ports like this

Expand Down
22 changes: 22 additions & 0 deletions src/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,28 @@ services:
ports:
- '27017:27017'

vitess57:
image: vitess/vttestserver:mysql57
restart: always
ports:
- 33577:33577
environment:
PORT: 33574
KEYSPACES: "test"
NUM_SHARDS: "1"
MYSQL_BIND_HOST: "0.0.0.0"

vitess80:
image: vitess/vttestserver:mysql80
restart: always
ports:
- 33807:33807
environment:
PORT: 33804
KEYSPACES: "test"
NUM_SHARDS: "1"
MYSQL_BIND_HOST: "0.0.0.0"

volumes:
postgres:
postgres_isolated:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import { uriToCredentials } from '@prisma/sdk'
import mariadb from 'mariadb'
import { Context, Input } from '../../__helpers__/integrationTest'

export const database = {
name: 'vitess57',
datasource: {
url: (ctx) => getConnectionInfo(ctx).connectionString,
provider: 'mysql',
},
connect(ctx) {
const credentials = getConnectionInfo(ctx).credentials
return mariadb.createConnection({
host: credentials.host,
port: credentials.port,
user: credentials.user,
password: credentials.password,
ssl: credentials.ssl,
allowPublicKeyRetrieval: true,
multipleStatements: true,
})
},
beforeEach: async (db, sqlScenario, ctx) => {
// const sqlUp = `
// DROP DATABASE IF EXISTS ${ctx.id};
// CREATE DATABASE ${ctx.id};
// USE ${ctx.id};`
// await db.query(sqlUp + sqlScenario)
await db.query('USE test')
const foreign_keys = await db.query({
rowsAsArray: true,
sql:
'SELECT DISTINCT TABLE_NAME, CONSTRAINT_NAME FROM information_schema.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL',
})
for (const row of foreign_keys) {
await db.query(
'ALTER TABLE `' + row[0] + '` DROP FOREIGN KEY `' + row[1] + '`',
)
}
const tables = await db.query({ rowsAsArray: true, sql: 'SHOW TABLES' })
for (const row of tables) {
await db.query('DROP TABLE `' + row[0] + '`')
}
await db.query(sqlScenario)
},
close: (db) => db.end(),
} as Input<mariadb.Connection>['database']

function getConnectionInfo(ctx: Context) {
const connectionString =
process.env.TEST_VITESS57_URI || 'mysql://root:prisma@localhost:33577/test'
const credentials = uriToCredentials(connectionString)

return {
credentials,
connectionString,
}
}