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

test: add cockroachDB 23.2 #4719

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
4 changes: 4 additions & 0 deletions .github/workflows/test-query-engine.yml
Expand Up @@ -47,6 +47,10 @@ jobs:
single_threaded: true
connector: "mongodb"
version: "4.2"
- name: "cockroach_23_2"
single_threaded: false
connector: "cockroachdb"
version: "23.2"
- name: "cockroach_23_1"
single_threaded: false
connector: "cockroachdb"
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/test-schema-engine.yml
Expand Up @@ -90,6 +90,8 @@ jobs:
url: "postgresql://postgres:prisma@localhost:5438"
- name: postgres16
url: "postgresql://postgres:prisma@localhost:5439"
- name: cockroach_23_2
url: "postgresql://prisma@localhost:26261"
- name: cockroach_23_1
url: "postgresql://prisma@localhost:26260"
- name: cockroach_22_2
Expand Down
2 changes: 2 additions & 0 deletions .test_database_urls/cockroachdb_23_2
@@ -0,0 +1,2 @@
export TEST_DATABASE_URL="postgresql://prisma@localhost:26261"
unset TEST_SHADOW_DATABASE_URL
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -196,6 +196,12 @@ start-postgres16:
dev-postgres16: start-postgres16
cp $(CONFIG_PATH)/postgres16 $(CONFIG_FILE)

start-cockroach_23_2:
docker compose -f docker-compose.yml up --wait -d --remove-orphans cockroach_23_2

dev-cockroach_23_2: start-cockroach_23_2
cp $(CONFIG_PATH)/cockroach_23_2 $(CONFIG_FILE)

start-cockroach_23_1:
docker compose -f docker-compose.yml up --wait -d --remove-orphans cockroach_23_1

Expand Down
10 changes: 10 additions & 0 deletions docker-compose.yml
@@ -1,5 +1,15 @@
version: '3'
services:
cockroach_23_2:
image: prismagraphql/cockroachdb-custom:23.2.0
restart: unless-stopped
command: |
start-single-node --insecure
ports:
- '26261:26257'
networks:
- databases

cockroach_23_1:
image: prismagraphql/cockroachdb-custom:23.1@sha256:c5a97355d56a7692ed34d835dfd8e3663d642219ea90736658a24840ea26862d
restart: unless-stopped
Expand Down
4 changes: 3 additions & 1 deletion libs/test-setup/src/postgres.rs
Expand Up @@ -35,7 +35,9 @@ pub(crate) fn get_postgres_tags(database_url: &str) -> Result<BitFlags<Tags>, St
}

if version.contains("CockroachDB") {
if version.contains("v23.1") {
if version.contains("v23.2") {
tags |= Tags::CockroachDb232;
} else if version.contains("v23.1") {
tags |= Tags::CockroachDb231;
} else if version.contains("v22.2") {
tags |= Tags::CockroachDb222;
Expand Down
1 change: 1 addition & 0 deletions libs/test-setup/src/tags.rs
Expand Up @@ -42,6 +42,7 @@ tags![
CockroachDb222 = 1 << 20,
CockroachDb231 = 1 << 21,
Postgres16 = 1 << 22,
CockroachDb232 = 1 << 23,
];

pub fn tags_from_comma_separated_list(input: &str) -> BitFlags<Tags> {
Expand Down
Expand Up @@ -8,6 +8,7 @@ pub(crate) struct CockroachDbConnectorTag;

#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CockroachDbVersion {
V232,
V231,
V222,
V221,
Expand All @@ -21,6 +22,7 @@ impl TryFrom<&str> for CockroachDbVersion {
"22.1" => Self::V221,
"22.2" => Self::V222,
"23.1" => Self::V231,
"23.2" => Self::V232,
_ => return Err(TestError::parse_error(format!("Unknown CockroachDB version `{s}`"))),
};

Expand All @@ -31,6 +33,7 @@ impl TryFrom<&str> for CockroachDbVersion {
impl fmt::Display for CockroachDbVersion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
CockroachDbVersion::V232 => f.write_str("23.2"),
CockroachDbVersion::V231 => f.write_str("23.1"),
CockroachDbVersion::V222 => f.write_str("22.2"),
CockroachDbVersion::V221 => f.write_str("22.1"),
Expand Down
Expand Up @@ -194,6 +194,9 @@ pub(crate) fn connection_string(
Some(CockroachDbVersion::V231) if is_ci => {
format!("postgresql://prisma@test-db-cockroachdb-23-1:26260/{database}?schema={database}")
}
Some(CockroachDbVersion::V232) if is_ci => {
format!("postgresql://prisma@test-db-cockroachdb-23-2:26261/{database}?schema={database}")
}
Some(CockroachDbVersion::V221) => {
format!("postgresql://prisma@127.0.0.1:26257/{database}?schema={database}")
}
Expand All @@ -203,6 +206,9 @@ pub(crate) fn connection_string(
Some(CockroachDbVersion::V231) => {
format!("postgresql://prisma@127.0.0.1:26260/{database}?schema={database}")
}
Some(CockroachDbVersion::V232) => {
format!("postgresql://prisma@127.0.0.1:26261/{database}?schema={database}")
}

None => unreachable!("A versioned connector must have a concrete version to run."),
}
Expand Down
@@ -0,0 +1,4 @@
{
"connector": "cockroachdb",
"version": "23.2"
}
Expand Up @@ -1300,7 +1300,7 @@ fn bigint_defaults_work(api: TestApi) {
}

// regression test for https://github.com/prisma/prisma/issues/20557
#[test_connector(tags(CockroachDb), exclude(CockroachDb231))]
#[test_connector(tags(CockroachDb), exclude(CockroachDb231, CockroachDb232))]
fn alter_type_works(api: TestApi) {
let schema = r#"
datasource db {
Expand Down
@@ -1,6 +1,6 @@
use sql_migration_tests::test_api::*;

#[test_connector(tags(CockroachDb), exclude(CockroachDb231))]
#[test_connector(tags(CockroachDb), exclude(CockroachDb231, CockroachDb232))]
fn failing_migration_after_migration_dropping_data(api: TestApi) {
let migrations = &[
r#"
Expand Down Expand Up @@ -49,7 +49,7 @@ fn failing_migration_after_migration_dropping_data(api: TestApi) {
expectation.assert_eq(&err);
}

#[test_connector(tags(CockroachDb), exclude(CockroachDb231))]
#[test_connector(tags(CockroachDb), exclude(CockroachDb231, CockroachDb232))]
fn failing_step_in_migration_dropping_data(api: TestApi) {
let migrations = &[
r#"
Expand Down Expand Up @@ -97,7 +97,7 @@ fn failing_step_in_migration_dropping_data(api: TestApi) {
}

// Skipped on CRDB 23.1 because of https://github.com/prisma/prisma/issues/20851
#[test_connector(tags(CockroachDb), exclude(CockroachDb231))]
#[test_connector(tags(CockroachDb), exclude(CockroachDb231, CockroachDb232))]
fn multiple_alter_tables_in_one_migration_works(api: TestApi) {
let migrations = &[
r#"
Expand Down Expand Up @@ -171,7 +171,7 @@ fn multiple_alter_tables_in_multiple_migration_works(api: TestApi) {
api.apply_migrations(&dir).send_sync();
}

#[test_connector(tags(CockroachDb), exclude(CockroachDb231))]
#[test_connector(tags(CockroachDb), exclude(CockroachDb231, CockroachDb232))]
fn syntax_errors_return_error_position(api: TestApi) {
let migrations = &[r#"
CREATE TABLE "Dog" (
Expand Down
Expand Up @@ -1374,7 +1374,9 @@ fn multi_schema_tests(_api: TestApi) {
async fn migration_with_shadow_database() {
let conn_str = std::env::var("TEST_DATABASE_URL").unwrap();

let is_cockroach = conn_str.contains("localhost:2625") || conn_str.contains("localhost:26260");
let is_cockroach = conn_str.contains("localhost:2625")
|| conn_str.contains("localhost:26260")
|| conn_str.contains("localhost:26261");
if !conn_str.starts_with("postgres") || is_cockroach {
return;
}
Expand Down