Skip to content

Commit

Permalink
support shadow type match value (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
PangXing authored Sep 29, 2022
1 parent 3339536 commit 9e78982
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 1,195 deletions.
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

0 comments on commit 9e78982

Please sign in to comment.