Skip to content

Commit 15391b2

Browse files
committed
code health: unify create spaces in config.lua
Part of #196
1 parent 679e9c9 commit 15391b2

File tree

2 files changed

+46
-34
lines changed

2 files changed

+46
-34
lines changed

config.lua

Lines changed: 41 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,6 @@ box.cfg{
66
}
77

88
box.once("init", function()
9-
local s = box.schema.space.create('test', {
10-
id = 517,
11-
if_not_exists = true,
12-
})
13-
s:create_index('primary', {type = 'tree', parts = {1, 'uint'}, if_not_exists = true})
14-
15-
local sp = box.schema.space.create('SQL_TEST', {
16-
id = 519,
17-
if_not_exists = true,
18-
format = {
19-
{name = "NAME0", type = "unsigned"},
20-
{name = "NAME1", type = "string"},
21-
{name = "NAME2", type = "string"},
22-
}
23-
})
24-
sp:create_index('primary', {type = 'tree', parts = {1, 'uint'}, if_not_exists = true})
25-
sp:insert{1, "test", "test"}
26-
279
local st = box.schema.space.create('schematest', {
2810
id = 516,
2911
temporary = true,
@@ -53,8 +35,34 @@ box.once("init", function()
5335
})
5436
st:truncate()
5537

56-
local s2 = box.schema.space.create('test_perf', {
57-
id = 520,
38+
local s = box.schema.space.create('test', {
39+
id = 517,
40+
if_not_exists = true,
41+
})
42+
s:create_index('primary', {
43+
type = 'tree',
44+
parts = {1, 'uint'},
45+
if_not_exists = true
46+
})
47+
48+
local s = box.schema.space.create('SQL_TEST', {
49+
id = 518,
50+
if_not_exists = true,
51+
format = {
52+
{name = "NAME0", type = "unsigned"},
53+
{name = "NAME1", type = "string"},
54+
{name = "NAME2", type = "string"},
55+
}
56+
})
57+
s:create_index('primary', {
58+
type = 'tree',
59+
parts = {1, 'uint'},
60+
if_not_exists = true
61+
})
62+
s:insert{1, "test", "test"}
63+
64+
local s = box.schema.space.create('test_perf', {
65+
id = 519,
5866
temporary = true,
5967
if_not_exists = true,
6068
field_count = 3,
@@ -64,14 +72,24 @@ box.once("init", function()
6472
{name = "arr1", type = "array"},
6573
},
6674
})
67-
s2:create_index('primary', {type = 'tree', unique = true, parts = {1, 'unsigned'}, if_not_exists = true})
68-
s2:create_index('secondary', {id = 5, type = 'tree', unique = false, parts = {2, 'string'}, if_not_exists = true})
75+
s:create_index('primary', {
76+
type = 'tree',
77+
unique = true,
78+
parts = {1, 'unsigned'},
79+
if_not_exists = true
80+
})
81+
s:create_index('secondary', {
82+
id = 5, type = 'tree',
83+
unique = false,
84+
parts = {2, 'string'},
85+
if_not_exists = true
86+
})
6987
local arr_data = {}
7088
for i = 1,100 do
7189
arr_data[i] = i
7290
end
7391
for i = 1,1000 do
74-
s2:insert{
92+
s:insert{
7593
i,
7694
'test_name',
7795
arr_data,

tarantool_test.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,7 @@ func BenchmarkClientSerialSQL(b *testing.B) {
205205
conn := test_helpers.ConnectWithValidation(b, server, opts)
206206
defer conn.Close()
207207

208-
spaceNo := 519
209-
_, err := conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
208+
_, err := conn.Replace("SQL_TEST", []interface{}{uint(1111), "hello", "world"})
210209
if err != nil {
211210
b.Errorf("Failed to replace: %s", err)
212211
}
@@ -227,8 +226,7 @@ func BenchmarkClientSerialSQLPrepared(b *testing.B) {
227226
conn := test_helpers.ConnectWithValidation(b, server, opts)
228227
defer conn.Close()
229228

230-
spaceNo := 519
231-
_, err := conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
229+
_, err := conn.Replace("SQL_TEST", []interface{}{uint(1111), "hello", "world"})
232230
if err != nil {
233231
b.Errorf("Failed to replace: %s", err)
234232
}
@@ -601,7 +599,6 @@ func BenchmarkClientParallelMassiveUntyped(b *testing.B) {
601599
func BenchmarkClientReplaceParallel(b *testing.B) {
602600
conn := test_helpers.ConnectWithValidation(b, server, opts)
603601
defer conn.Close()
604-
spaceNo = 520
605602

606603
rSpaceNo, _, err := conn.Schema.ResolveSpaceIndex("test_perf", "secondary")
607604
if err != nil {
@@ -647,8 +644,7 @@ func BenchmarkClientParallelSQL(b *testing.B) {
647644
conn := test_helpers.ConnectWithValidation(b, server, opts)
648645
defer conn.Close()
649646

650-
spaceNo := 519
651-
_, err := conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
647+
_, err := conn.Replace("SQL_TEST", []interface{}{uint(1111), "hello", "world"})
652648
if err != nil {
653649
b.Errorf("No connection available")
654650
}
@@ -671,8 +667,7 @@ func BenchmarkClientParallelSQLPrepared(b *testing.B) {
671667
conn := test_helpers.ConnectWithValidation(b, server, opts)
672668
defer conn.Close()
673669

674-
spaceNo := 519
675-
_, err := conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
670+
_, err := conn.Replace("SQL_TEST", []interface{}{uint(1111), "hello", "world"})
676671
if err != nil {
677672
b.Errorf("No connection available")
678673
}
@@ -706,8 +701,7 @@ func BenchmarkSQLSerial(b *testing.B) {
706701
conn := test_helpers.ConnectWithValidation(b, server, opts)
707702
defer conn.Close()
708703

709-
spaceNo := 519
710-
_, err := conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"})
704+
_, err := conn.Replace("SQL_TEST", []interface{}{uint(1111), "hello", "world"})
711705
if err != nil {
712706
b.Errorf("Failed to replace: %s", err)
713707
}

0 commit comments

Comments
 (0)