Skip to content

Commit bc011fe

Browse files
Merge 65bec8e into 05aab2d
2 parents 05aab2d + 65bec8e commit bc011fe

File tree

4 files changed

+140
-49
lines changed

4 files changed

+140
-49
lines changed

test/clt-tests/base/replication/join-cluster-on-all-nodes.recb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
––– input –––
2-
for n in `seq 2 $INSTANCE`; do mysql -h0 -P${n}306 -e "join cluster ${CLUSTER_NAME} at '127.0.0.1:1312'"; done;
2+
for n in `seq 2 $INSTANCE`; do mysql -h0 -P${n}306 -e "join cluster ${CLUSTER_NAME} at '127.0.0.1:$((n*1000+312))'"; done
33
––– output –––
44
––– input –––
55
mysql -h0 -P${INSTANCE}306 -e "show status like 'cluster_${CLUSTER_NAME}_status'\G"

test/clt-tests/base/replication/start-searchd-precach.recb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ mkdir -p /var/{run,lib,log}/manticore-${INSTANCE}
55
stdbuf -oL searchd -c test/clt-tests/base/searchd-with-flexible-ports.conf > /dev/null
66
––– output –––
77
––– input –––
8-
if timeout 10 grep -qm1 'accepting connections' <(tail -n 1000 -f /var/log/manticore-${INSTANCE}/searchd.log); then echo 'Accepting connections!'; else echo 'Timeout or failed!'; fi
8+
if timeout 10 grep -qm1 'accepting connections' <(tail -n 1000 -f /tmp/manticore-${INSTANCE}/searchd.log); then echo 'Accepting connections!'; else echo 'Timeout or failed!'; fi
99
––– output –––
1010
Accepting connections!

test/clt-tests/core/test-freeze-unfreeze-update.rec

Lines changed: 91 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
––– input –––
2-
echo -e "searchd {\n listen = 9315:mysql\n listen = 9316\n log = /tmp/searchd.log\n pid_file = /tmp/searchd.pid\n data_dir = /tmp/data\n watchdog = 0\n}" > /tmp/116.conf
2+
export INSTANCE=1
3+
––– output –––
4+
––– block: ../base/replication/start-searchd-precach –––
5+
––– input –––
6+
export INSTANCE=2
7+
––– output –––
8+
––– block: ../base/replication/start-searchd-precach –––
9+
––– input –––
10+
export INSTANCE=3
11+
––– output –––
12+
––– block: ../base/replication/start-searchd-precach –––
13+
––– input –––
14+
export CLUSTER_NAME=replication
315
––– output –––
416
––– input –––
517
mkdir -p /tmp/data; rm -f /tmp/searchd.log; stdbuf -oL searchd --stopwait > /dev/null; stdbuf -oL searchd -c /tmp/116.conf > /dev/null
@@ -9,30 +21,90 @@ if timeout 10 grep -qm1 '\[BUDDY\] started' <(tail -n 1000 -f /tmp/searchd.log);
921
––– output –––
1022
Buddy started!
1123
––– input –––
12-
mysql -P9315 -h0 -e "drop table if exists t; create table t(s string); insert into t values(1, 'a'); flush ramchunk t"; echo $?
24+
for n in `seq 2 $INSTANCE`; do mysql -h0 -P${n}306 -e "join cluster ${CLUSTER_NAME} at '127.0.0.1:1312'"; done;
1325
––– output –––
14-
0
1526
––– input –––
16-
mysql -P9315 -h0 -e "select * from t;"
27+
mysql -h0 -P1306 -e "SHOW STATUS LIKE 'cluster_replication_status'\G"
1728
––– output –––
18-
+------+------+
19-
| id | s |
20-
+------+------+
21-
| 1 | a |
22-
+------+------+
2329
––– input –––
2430
(rm -f /tmp/update.sql; for n in `seq 1 10000`; do echo "update t set s='b' where id=1;" >> /tmp/update.sql; done; nohup sh -c "while true; do mysql -P9315 -h0 < /tmp/update.sql | break; done" &>/dev/null &) 2>/dev/null
2531
––– output –––
2632
––– input –––
27-
sleep 30; mysql -P9315 -h0 -e "select * from t;"
33+
mysql -h0 -P2306 -e "SHOW STATUS LIKE 'cluster_replication_status'\G"
34+
––– output –––
35+
––– input –––
36+
mysql -h0 -P2306 -e "SHOW STATUS LIKE 'cluster_replication_nodes_set'\G;"
37+
––– output –––
38+
––– input –––
39+
mysql -h0 -P3306 -e "SHOW STATUS LIKE 'cluster_replication_status'\G"
40+
––– output –––
41+
––– input –––
42+
mysql -h0 -P3306 -e "SHOW STATUS LIKE 'cluster_replication_nodes_set'\G;"
43+
––– output –––
44+
––– input –––
45+
php -d memory_limit=2G ./test/clt-tests/scripts/load_names_attr.php --batch-size=5000 --concurrency=1 --docs=1000000 --start-id=01 --rt-mem-limit=256M --min-infix-len=2 --drop-table --port=2306
46+
––– output –––
47+
––– input –––
48+
mysql -h0 -P2306 -e "ALTER CLUSTER replication ADD name;"
49+
––– output –––
50+
––– input –––
51+
mysql -P1306 -h0 -e "SELECT COUNT(*) FROM name;"
52+
––– output –––
53+
+----------+
54+
| count(*) |
55+
+----------+
56+
| 1100000 |
57+
+----------+
58+
––– input –––
59+
mysql -P1306 -h0 -e "DESCRIBE name;"
60+
––– output –––
61+
––– input –––
62+
mysql -P1306 -h0 -e "SELECT * FROM name limit 10;"
63+
––– output –––
64+
––– input –––
65+
mysql -P1306 -h0 -e "SELECT id, s FROM name LIMIT 10;"
66+
––– output –––
67+
––– input –––
68+
mysql -P1306 -h0 -e "SHOW CREATE TABLE name\G;"
69+
––– output –––
70+
––– input –––
71+
mysql -P2306 -h0 -e "SHOW CREATE TABLE name\G;"
72+
––– output –––
73+
––– input –––
74+
mysql -P3306 -h0 -e "SHOW CREATE TABLE name\G;"
75+
––– output –––
76+
––– input –––
77+
mysql -P1306 -h0 -e "SELECT COUNT(*) FROM name;"
78+
––– output –––
79+
+----------+
80+
| count(*) |
81+
+----------+
82+
| 1000000 |
83+
+----------+
84+
––– input –––
85+
rm -f /tmp/update.sql; for n in `seq 01 100`; do echo "UPDATE replication:name SET s='b' WHERE id=$n;" >> /tmp/update.sql; done; while true; do mysql -P1306 -h0 < /tmp/update.sql; done & UPDATE_PID=$!
86+
––– output –––
87+
[%{NUMBER}] %{NUMBER}
88+
––– input –––
89+
mysql -P1306 -h0 -e "DESCRIBE name;"
90+
––– output –––
91+
––– input –––
92+
mysql -P1306 -h0 -e "SELECT id FROM replication:name WHERE MATCH('@s value1');"
93+
––– output –––
94+
––– input –––
95+
mysql -P1306 -h0 -e "SHOW CREATE TABLE replication:name\G;"
96+
––– output –––
97+
––– input –––
98+
sleep 10; mysql -P1306 -h0 -e "SELECT * FROM replication:name limit 10;"
99+
––– output –––
100+
––– input –––
101+
mysql -P2306 -h0 -e "SELECT * FROM replication:name limit 10;"
28102
––– output –––
29-
+------+------+
30-
| id | s |
31-
+------+------+
32-
| 1 | b |
33-
+------+------+
34103
––– input –––
35-
stdbuf -oL mysql -P9315 -h0 -e "freeze t"
104+
mysql -P3306 -h0 -e "SELECT * FROM replication:name limit 10;"
105+
––– output –––
106+
––– input –––
107+
sleep 1; mysql -P9306 -h0 -e "freeze replication:name"
36108
––– output –––
37109
+------------------------+------------------------+
38110
| file | normalized |
@@ -53,19 +125,12 @@ stdbuf -oL mysql -P9315 -h0 -e "freeze t"
53125
| /tmp/data/t/t.settings | /tmp/data/t/t.settings |
54126
+------------------------+------------------------+
55127
––– input –––
56-
mysql -P9315 -h0 -e "unfreeze t"; echo $?
128+
sleep 1; kill $UPDATE_PID; wait $UPDATE_PID 2>/dev/null;
57129
––– output –––
58130
0
59131
––– input –––
60-
mysql -P9315 -h0 -e "DESCRIBE t"
132+
(sleep 1; mysql -P1306 -h0 -e "drop table if exists replication:name;" && mysql -P1306 -h0 -e "CREATE TABLE name(a string); insert into name values(1, 'a'); flush ramchunk ; freeze t"; mysql -P1306 -h0 -e "update name set a='b' where id = 1" 2>&1 &)
61133
––– output –––
62-
+-------+--------+------------+
63-
| Field | Type | Properties |
64-
+-------+--------+------------+
65-
| id | bigint | |
66-
| s | string | |
67-
+-------+--------+------------+
68134
––– input –––
69-
mysql -P9315 -h0 -e "UPDATE t SET s='с' WHERE id=1; FLUSH RAMCHUNK t"; echo $?
135+
if timeout 5 mysql -P1306 -h0 -e 'SELECT * FROM t'; then echo 'Query executed'; else echo 'Query not executed'; fi
70136
––– output –––
71-
0

test/clt-tests/scripts/load_names_attr.php

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,26 @@
77
'concurrency' => 4,
88
'docs' => 1000000,
99
'start-id' => 1,
10-
'drop-table' => true // Drop and create table by default
10+
'drop-table' => true, // Drop and create table by default
11+
'shards' => 1, // Default number of shards
12+
'rf' => 1, // Default replication factor
13+
'port' => 9306 // Default port
1114
];
1215

1316
// Parse command-line arguments
1417
$options = [
15-
'batch-size::', // Optional argument, controlled by --batch-size=
16-
'concurrency::', // Optional argument, controlled by --concurrency=
17-
'docs::', // Optional argument, controlled by --docs=
18-
'min-infix-len::', // Optional argument, controlled by --min-infix-len=
19-
'start-id::', // Optional argument, controlled by --start-id=
20-
'rt-mem-limit::', // Optional argument, controlled by --rt-mem-limit=
21-
'drop-table', // Flag argument, controlled by --drop-table (default true)
22-
'no-drop-table', // Flag to disable dropping and creating the table
23-
'help' // Help argument
18+
'batch-size::',
19+
'concurrency::',
20+
'docs::',
21+
'min-infix-len::',
22+
'start-id::',
23+
'rt-mem-limit::',
24+
'drop-table',
25+
'no-drop-table',
26+
'shards::', // Number of shards
27+
'rf::', // Replication factor
28+
'port::', // Port number
29+
'help'
2430
];
2531
$args = getopt("", $options);
2632

@@ -63,15 +69,28 @@
6369
$concurrency = intval($args['concurrency']);
6470
$docs = intval($args['docs']);
6571
$startId = intval($args['start-id']);
72+
$shards = intval($args['shards']);
73+
$rf = intval($args['rf']);
74+
$port = intval($args['port']);
75+
76+
// Validate shards and rf
77+
if ($shards < 1 || $rf < 1) {
78+
die("Error: --shards and --rf must be greater than or equal to 1.\n");
79+
}
80+
81+
// Check required files
82+
$namesFile = './test/clt-tests/scripts/names.txt';
83+
$surnamesFile = './test/clt-tests/scripts/surnames.txt';
84+
if (!file_exists($namesFile) || !file_exists($surnamesFile)) {
85+
die("Error: Required files names.txt or surnames.txt are missing.\n");
86+
}
6687

6788
// Connect to database
68-
function connectDb() {
89+
function connectDb($port) {
6990
$host = '127.0.0.1';
70-
$port = '9306';
71-
7291
$m = @mysqli_connect($host, '', '', '', $port);
7392
if (mysqli_connect_error()) {
74-
die("Cannot connect to Manticore\n");
93+
die("Cannot connect to Manticore on port $port\n");
7594
}
7695
return $m;
7796
}
@@ -89,21 +108,28 @@ function process($link, $query) {
89108
// Create connections
90109
$all_links = [];
91110
for ($i = 0; $i < $concurrency; $i++) {
92-
$all_links[] = connectDb();
111+
$all_links[] = connectDb($port);
93112
}
94113

95114
// Initialize table if drop-table is true
96115
$pdo = $all_links[0];
97116
if ($dropTable) {
98-
mysqli_query($pdo, "DROP TABLE IF EXISTS name");
117+
if (!process($pdo, "DROP TABLE IF EXISTS name")) {
118+
die("Failed to drop existing table.\n");
119+
}
99120
echo "Table 'name' dropped and recreated.\n";
100-
$createTableQuery = "CREATE TABLE name(id INTEGER, username TEXT, s STRING) $minInfixLen expand_keywords='1'";
121+
122+
$createTableQuery = "CREATE TABLE name (id INTEGER, username TEXT, s STRING ATTRIBUTE INDEXED)";
123+
if ($minInfixLen) {
124+
$createTableQuery .= " $minInfixLen";
125+
}
126+
$createTableQuery .= " expand_keywords='1' shards=$shards rf=$rf";
101127
if ($rtMemLimit) {
102128
$createTableQuery .= " $rtMemLimit";
103129
}
104-
mysqli_query($pdo, $createTableQuery);
105130
}
106131

132+
// Prepare data
107133
$batch = [];
108134
$query_start = "INSERT INTO name(id, username, s) VALUES ";
109135
$names = file('./test/clt-tests/scripts/names.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
@@ -134,9 +160,9 @@ function process($link, $query) {
134160

135161
$t = microtime(true);
136162

137-
foreach ($batches as $batch) {
138-
$link = $all_links[array_rand($all_links)];
139-
if (!process($link, $batch)) die("ERROR\n");
163+
foreach ($batches as $index => $batch) {
164+
$link = $all_links[$index % $concurrency];
165+
if (!process($link, $batch)) die("Error during batch insertion.\n");
140166
}
141167

142168
echo "finished inserting\n";

0 commit comments

Comments
 (0)