-
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.
Use altered table schema for tableCols map
Fix: #173 --- Pull Request resolved: #178 Co-authored-by: tserakhau <[email protected]> commit_hash:4a9b80641f7596bba9ca3c144756d62d8775d287
- Loading branch information
1 parent
1c8954e
commit 93c257d
Showing
5 changed files
with
64 additions
and
1 deletion.
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
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 @@ | ||
CREATE DATABASE source; |
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,43 @@ | ||
package snapshotnofk | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/doublecloud/transfer/pkg/abstract" | ||
chrecipe "github.com/doublecloud/transfer/pkg/providers/clickhouse/recipe" | ||
"github.com/doublecloud/transfer/tests/e2e/mysql2ch" | ||
"github.com/doublecloud/transfer/tests/e2e/pg2ch" | ||
"github.com/doublecloud/transfer/tests/helpers" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestSnapshot(t *testing.T) { | ||
source := helpers.RecipeMysqlSource() | ||
target := chrecipe.MustTarget(chrecipe.WithInitFile("ch.sql"), chrecipe.WithDatabase("source")) | ||
|
||
defer func() { | ||
require.NoError(t, helpers.CheckConnections( | ||
helpers.LabeledPort{Label: "MySQL source", Port: source.Port}, | ||
helpers.LabeledPort{Label: "CH target", Port: target.NativePort}, | ||
)) | ||
}() | ||
|
||
t.Run("fake_keys", func(t *testing.T) { | ||
source.UseFakePrimaryKey = true | ||
transfer := helpers.MakeTransfer(helpers.TransferID, source, target, abstract.TransferTypeSnapshotAndIncrement) | ||
_, err := helpers.ActivateErr(transfer) | ||
require.NoError(t, err) | ||
require.NoError(t, helpers.CompareStorages( | ||
t, | ||
source, | ||
target, | ||
helpers.NewCompareStorageParams().WithEqualDataTypes(pg2ch.PG2CHDataTypesComparator).WithPriorityComparators(mysql2ch.MySQLBytesToStringOptionalComparator), | ||
)) | ||
}) | ||
t.Run("no_fake_keys", func(t *testing.T) { | ||
source.UseFakePrimaryKey = false | ||
transfer := helpers.MakeTransfer(helpers.TransferID, source, target, abstract.TransferTypeSnapshotAndIncrement) | ||
_, err := helpers.ActivateErr(transfer) | ||
require.Error(t, err) | ||
}) | ||
} |
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,16 @@ | ||
-- Create table without a primary key | ||
CREATE TABLE no_pk ( | ||
id INT NOT NULL, | ||
name VARCHAR(100) NOT NULL, | ||
age INT NOT NULL, | ||
city VARCHAR(100) NOT NULL, | ||
email VARCHAR(100) NOT NULL | ||
); | ||
|
||
-- Insert 5 unique rows | ||
INSERT INTO no_pk (id, name, age, city, email) VALUES | ||
(1, 'Alice', 30, 'New York', '[email protected]'), | ||
(2, 'Bob', 25, 'Los Angeles', '[email protected]'), | ||
(3, 'Charlie', 35, 'Chicago', '[email protected]'), | ||
(4, 'Diana', 28, 'San Francisco', '[email protected]'), | ||
(5, 'Eve', 40, 'Miami', '[email protected]'); |