Skip to content

Commit 3a70dc3

Browse files
MDEV-30265 Spider: Add CODING_STANDARDS
1 parent c083f19 commit 3a70dc3

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
#+title Spider Development Documentation
2+
3+
** Testing
4+
:PROPERTIES:
5+
:UPDATED: [2025-10-15 Wed 15:33]
6+
:END:
7+
8+
*** Run spider test suites
9+
:PROPERTIES:
10+
:UPDATED: [2025-10-15 Wed 15:39]
11+
:END:
12+
13+
Spider has sub-suites. Assuming temporary WIP spider tests are placed
14+
under the spider/temp suite, to run a test on all spider tests, do
15+
16+
#+begin_src sh
17+
./mysql-test/mtr --suite spider,spider/*,spider/*/* \
18+
--skip-test="spider/temp.*|.*/t\..*" --parallel=auto --big-test \
19+
--force --max-test-fail=0
20+
#+end_src
21+
22+
Tests should be run normally, but also with --ps-protocol,
23+
--view-protocol and ASAN.
24+
25+
For 10.11+ tests should also be run with
26+
--mysqld=--loose-disable-spider-group-by-handler. This will be done
27+
automatically after MDEV-37810.
28+
29+
*** Where to place new tests
30+
:PROPERTIES:
31+
:UPDATED: [2025-10-15 Wed 15:35]
32+
:END:
33+
34+
- spider/bugfix suite for bugfixes
35+
- spider/feature suite for new features
36+
- spider suite for all else, such as generic tests to improve coverage
37+
38+
*** Use engine defined attributes in tests whenever possible
39+
:PROPERTIES:
40+
:UPDATED: [2025-10-15 Wed 15:52]
41+
:END:
42+
43+
In versions of at least 10.11, when writing new tests or updating
44+
existing tests, use engine defined attributes for spider table
45+
connection info instead of table comments
46+
47+
#+begin_src sql
48+
# Do this for 10.11+
49+
CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1;
50+
# Do this for 10.6
51+
CREATE TABLE t (c int) ENGINE=SPIDER COMMENT='srv "s1", table "t1"';
52+
#+end_src
53+
54+
However, if the spider table has connection info that is not
55+
REMOTE_SERVER, REMOTE_TABLE, or REMOTE_DATABASE, comments are still
56+
needed for 10.11:
57+
58+
#+begin_src sql
59+
# Do this for 10.6 and 10.11
60+
CREATE TABLE t (c int) ENGINE=SPIDER COMMENT='srv "s1", table "t1", read_only_mode "1"';
61+
# Do this for 11.4+
62+
CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1 READ_ONLY=1;
63+
#+end_src
64+
65+
Don't mix engine defined attributes with COMMENT, unless the mixing is
66+
part of the test.
67+
68+
#+begin_src sql
69+
# Don't do this
70+
CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1 COMMENT='read_only_mode "1"';
71+
#+end_src
72+
73+
WRAPPER by default is mysql, so it is ok to do the following
74+
conversion in 10.11+:
75+
76+
#+begin_src sql
77+
# From
78+
CREATE TABLE t (c int) ENGINE=SPIDER COMMENT='wrapper "mysql", srv "s1", table "t1"';
79+
# to
80+
CREATE TABLE t (c int) ENGINE=SPIDER REMOTE_SERVER=s1 REMOTE_TABLE=t1;
81+
#+end_src

0 commit comments

Comments
 (0)