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: support shadow type match value #433

Merged
merged 1 commit into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions integration_test/config/db_tbl/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,6 @@ data:
password: "123456"
database: employees_0003
weight: r10w10
- name: employees_shadow
nodes:
- name: node_shadow
host: arana-mysql
port: 3306
username: root
password: "123456"
database: employees_shadow
weight: r10w10

sharding_rule:
tables:
- name: employees.student
Expand All @@ -114,13 +104,3 @@ data:
tbl_pattern: student_${0000..0031}
attributes:
sqlMaxLimit: -1
shadow_rule:
tables:
- name: employees.student
enable: true
group_node: employees_shadow
match_rules:
- operation: [select,insert,update,delete]
match_type: hint
attributes:
- value: "shadow"
12 changes: 11 additions & 1 deletion integration_test/config/shadow/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,17 @@ data:
- name: employees.student
enable: true
match_rules:
- operation: [select, insert, update, delete]
- operation: [insert, select]
match_type: hint
attributes:
- value: "shadow"
- operation: [update]
match_type: value
attributes:
- column: uid
value: 10000
- operation: [delete]
match_type: regex
attributes:
- column: name
value: "^hanmeimei$"
29 changes: 19 additions & 10 deletions integration_test/scene/shadow/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,25 @@ func (s *IntegrationSuite) TestShadowScene() {
}
}

/*
for _, sqlCase := range cases.ExShRegexCases {
for _, sense := range sqlCase.Sense {
if strings.Compare(strings.TrimSpace(sense), "shadow") == 0 {
result, err := tx.Exec(sqlCase.SQL)
assert.NoError(t, err, err)
err = sqlCase.ExpectedResult.CompareRow(result)
assert.NoError(t, err, err)
}
for _, sqlCase := range cases.ExShValueCases {
for _, sense := range sqlCase.Sense {
if strings.Compare(strings.TrimSpace(sense), "shadow") == 0 {
result, err := tx.Exec(sqlCase.SQL)
assert.NoError(t, err, err)
err = sqlCase.ExpectedResult.CompareRow(result)
assert.NoError(t, err, err)
}
}
*/
}

for _, sqlCase := range cases.ExShRegexCases {
for _, sense := range sqlCase.Sense {
if strings.Compare(strings.TrimSpace(sense), "shadow") == 0 {
result, err := tx.Exec(sqlCase.SQL)
assert.NoError(t, err, err)
err = sqlCase.ExpectedResult.CompareRow(result)
assert.NoError(t, err, err)
}
}
}
}
1 change: 0 additions & 1 deletion integration_test/scripts/shadow/init.sql
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
--

CREATE DATABASE IF NOT EXISTS employees_0000 CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE DATABASE IF NOT EXISTS employees_shadow CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

USE employees_0000;

Expand Down
Loading