From 9648c4f11a1134794681b573d52fa21ff7aa34c5 Mon Sep 17 00:00:00 2001 From: Georgy Moiseev Date: Mon, 12 Dec 2022 17:14:09 +0300 Subject: [PATCH] test: change space id range In Tarantool, user space ids starts from 512. You can set arbitrary id or use autoincrement (sequence also starts from 512). Unfortunately, mixing spaces with autoincremented ids and spaces with explicit ids may cause id conflict [1]. Since there are cases when we cannot explicitly set space id (creating a space with SQL), a short range of free ids (from 512 to 515) causes problems. This patch increases range of free ids (now it's from 512 to 615) so it should be ok until [1] is resolved. 1. https://github.com/tarantool/tarantool/issues/8036 Part of #215 --- config.lua | 14 +++++++------- example_custom_unpacking_test.go | 2 +- example_test.go | 24 ++++++++++++------------ multi/config.lua | 4 ++-- multi/multi_test.go | 2 +- tarantool_test.go | 32 ++++++++++++++++---------------- 6 files changed, 39 insertions(+), 39 deletions(-) diff --git a/config.lua b/config.lua index bb976ef43..c8a853ff4 100644 --- a/config.lua +++ b/config.lua @@ -7,7 +7,7 @@ box.cfg{ box.once("init", function() local st = box.schema.space.create('schematest', { - id = 516, + id = 616, temporary = true, if_not_exists = true, field_count = 7, @@ -36,7 +36,7 @@ box.once("init", function() st:truncate() local s = box.schema.space.create('test', { - id = 517, + id = 617, if_not_exists = true, }) s:create_index('primary', { @@ -46,7 +46,7 @@ box.once("init", function() }) local s = box.schema.space.create('teststring', { - id = 518, + id = 618, if_not_exists = true, }) s:create_index('primary', { @@ -56,7 +56,7 @@ box.once("init", function() }) local s = box.schema.space.create('testintint', { - id = 519, + id = 619, if_not_exists = true, }) s:create_index('primary', { @@ -66,7 +66,7 @@ box.once("init", function() }) local s = box.schema.space.create('SQL_TEST', { - id = 520, + id = 620, if_not_exists = true, format = { {name = "NAME0", type = "unsigned"}, @@ -82,7 +82,7 @@ box.once("init", function() s:insert{1, "test", "test"} local s = box.schema.space.create('test_perf', { - id = 521, + id = 621, temporary = true, if_not_exists = true, field_count = 3, @@ -117,7 +117,7 @@ box.once("init", function() end local s = box.schema.space.create('test_error_type', { - id = 522, + id = 622, temporary = true, if_not_exists = true, field_count = 2, diff --git a/example_custom_unpacking_test.go b/example_custom_unpacking_test.go index 4087c5620..26d19f3af 100644 --- a/example_custom_unpacking_test.go +++ b/example_custom_unpacking_test.go @@ -87,7 +87,7 @@ func Example_customUnpacking() { log.Fatalf("Failed to connect: %s", err.Error()) } - spaceNo := uint32(517) + spaceNo := uint32(617) indexNo := uint32(0) tuple := Tuple2{Cid: 777, Orig: "orig", Members: []Member{{"lol", "", 1}, {"wut", "", 3}}} diff --git a/example_test.go b/example_test.go index 538fa93b1..27a962da0 100644 --- a/example_test.go +++ b/example_test.go @@ -51,7 +51,7 @@ func ExampleConnection_Select() { conn.Replace(spaceNo, []interface{}{uint(1111), "hello", "world"}) conn.Replace(spaceNo, []interface{}{uint(1112), "hallo", "werld"}) - resp, err := conn.Select(517, 0, 0, 100, tarantool.IterEq, []interface{}{uint(1111)}) + resp, err := conn.Select(617, 0, 0, 100, tarantool.IterEq, []interface{}{uint(1111)}) if err != nil { fmt.Printf("error in select is %v", err) @@ -75,7 +75,7 @@ func ExampleConnection_SelectTyped() { defer conn.Close() var res []Tuple - err := conn.SelectTyped(517, 0, 0, 100, tarantool.IterEq, tarantool.IntKey{1111}, &res) + err := conn.SelectTyped(617, 0, 0, 100, tarantool.IterEq, tarantool.IntKey{1111}, &res) if err != nil { fmt.Printf("error in select is %v", err) @@ -96,7 +96,7 @@ func ExampleConnection_SelectTyped() { func ExampleConnection_SelectAsync() { conn := example_connect(opts) defer conn.Close() - spaceNo := uint32(517) + spaceNo := uint32(617) conn.Insert(spaceNo, []interface{}{uint(16), "test", "one"}) conn.Insert(spaceNo, []interface{}{uint(17), "test", "one"}) @@ -223,7 +223,7 @@ func ExampleSelectRequest() { conn := example_connect(opts) defer conn.Close() - req := tarantool.NewSelectRequest(517). + req := tarantool.NewSelectRequest(617). Limit(100). Key(tarantool.IntKey{1111}) resp, err := conn.Do(req).Get() @@ -253,7 +253,7 @@ func ExampleUpdateRequest() { conn := example_connect(opts) defer conn.Close() - req := tarantool.NewUpdateRequest(517). + req := tarantool.NewUpdateRequest(617). Key(tarantool.IntKey{1111}). Operations(tarantool.NewOperations().Assign(1, "bye")) resp, err := conn.Do(req).Get() @@ -284,7 +284,7 @@ func ExampleUpsertRequest() { defer conn.Close() var req tarantool.Request - req = tarantool.NewUpsertRequest(517). + req = tarantool.NewUpsertRequest(617). Tuple([]interface{}{uint(1113), "first", "first"}). Operations(tarantool.NewOperations().Assign(1, "updated")) resp, err := conn.Do(req).Get() @@ -305,7 +305,7 @@ func ExampleUpsertRequest() { } fmt.Printf("response is %#v\n", resp.Data) - req = tarantool.NewSelectRequest(517). + req = tarantool.NewSelectRequest(617). Limit(100). Key(tarantool.IntKey{1113}) resp, err = conn.Do(req).Get() @@ -830,12 +830,12 @@ func ExampleSchema() { } space1 := schema.Spaces["test"] - space2 := schema.SpacesById[516] + space2 := schema.SpacesById[616] fmt.Printf("Space 1 ID %d %s\n", space1.Id, space1.Name) fmt.Printf("Space 2 ID %d %s\n", space2.Id, space2.Name) // Output: - // Space 1 ID 517 test - // Space 2 ID 516 schematest + // Space 1 ID 617 test + // Space 2 ID 616 schematest } // Example demonstrates how to retrieve information with space schema. @@ -854,7 +854,7 @@ func ExampleSpace() { // Access Space objects by name or ID. space1 := schema.Spaces["test"] - space2 := schema.SpacesById[516] // It's a map. + space2 := schema.SpacesById[616] // It's a map. fmt.Printf("Space 1 ID %d %s %s\n", space1.Id, space1.Name, space1.Engine) fmt.Printf("Space 1 ID %d %t\n", space1.FieldsCount, space1.Temporary) @@ -875,7 +875,7 @@ func ExampleSpace() { fmt.Printf("SpaceField 2 %s %s\n", spaceField2.Name, spaceField2.Type) // Output: - // Space 1 ID 517 test memtx + // Space 1 ID 617 test memtx // Space 1 ID 0 false // Index 0 primary // &{0 unsigned} &{2 string} diff --git a/multi/config.lua b/multi/config.lua index aca4db9b3..7364c0bd6 100644 --- a/multi/config.lua +++ b/multi/config.lua @@ -13,7 +13,7 @@ rawset(_G, 'get_cluster_nodes', get_cluster_nodes) box.once("init", function() local s = box.schema.space.create('test', { - id = 517, + id = 617, if_not_exists = true, }) s:create_index('primary', {type = 'tree', parts = {1, 'string'}, if_not_exists = true}) @@ -22,7 +22,7 @@ box.once("init", function() box.schema.user.grant('test', 'read,write,execute', 'universe') local sp = box.schema.space.create('SQL_TEST', { - id = 521, + id = 621, if_not_exists = true, format = { {name = "NAME0", type = "unsigned"}, diff --git a/multi/multi_test.go b/multi/multi_test.go index ef07d629b..d3a111a9f 100644 --- a/multi/multi_test.go +++ b/multi/multi_test.go @@ -16,7 +16,7 @@ import ( var server1 = "127.0.0.1:3013" var server2 = "127.0.0.1:3014" -var spaceNo = uint32(517) +var spaceNo = uint32(617) var spaceName = "test" var indexNo = uint32(0) var connOpts = tarantool.Opts{ diff --git a/tarantool_test.go b/tarantool_test.go index de7af9e91..fdb129d07 100644 --- a/tarantool_test.go +++ b/tarantool_test.go @@ -99,7 +99,7 @@ func convertUint64(v interface{}) (result uint64, err error) { } var server = "127.0.0.1:3013" -var spaceNo = uint32(517) +var spaceNo = uint32(617) var spaceName = "test" var indexNo = uint32(0) var indexName = "primary" @@ -1776,29 +1776,29 @@ func TestSchema(t *testing.T) { } var space, space2 *Space var ok bool - if space, ok = schema.SpacesById[516]; !ok { - t.Errorf("space with id = 516 was not found in schema.SpacesById") + if space, ok = schema.SpacesById[616]; !ok { + t.Errorf("space with id = 616 was not found in schema.SpacesById") } if space2, ok = schema.Spaces["schematest"]; !ok { t.Errorf("space with name 'schematest' was not found in schema.SpacesById") } if space != space2 { - t.Errorf("space with id = 516 and space with name schematest are different") + t.Errorf("space with id = 616 and space with name schematest are different") } - if space.Id != 516 { - t.Errorf("space 516 has incorrect Id") + if space.Id != 616 { + t.Errorf("space 616 has incorrect Id") } if space.Name != "schematest" { - t.Errorf("space 516 has incorrect Name") + t.Errorf("space 616 has incorrect Name") } if !space.Temporary { - t.Errorf("space 516 should be temporary") + t.Errorf("space 616 should be temporary") } if space.Engine != "memtx" { - t.Errorf("space 516 engine should be memtx") + t.Errorf("space 616 engine should be memtx") } if space.FieldsCount != 7 { - t.Errorf("space 516 has incorrect fields count") + t.Errorf("space 616 has incorrect fields count") } if space.FieldsById == nil { @@ -1908,20 +1908,20 @@ func TestSchema(t *testing.T) { } var rSpaceNo, rIndexNo uint32 - rSpaceNo, rIndexNo, err = schema.ResolveSpaceIndex(516, 3) - if err != nil || rSpaceNo != 516 || rIndexNo != 3 { + rSpaceNo, rIndexNo, err = schema.ResolveSpaceIndex(616, 3) + if err != nil || rSpaceNo != 616 || rIndexNo != 3 { t.Errorf("numeric space and index params not resolved as-is") } - rSpaceNo, _, err = schema.ResolveSpaceIndex(516, nil) - if err != nil || rSpaceNo != 516 { + rSpaceNo, _, err = schema.ResolveSpaceIndex(616, nil) + if err != nil || rSpaceNo != 616 { t.Errorf("numeric space param not resolved as-is") } rSpaceNo, rIndexNo, err = schema.ResolveSpaceIndex("schematest", "secondary") - if err != nil || rSpaceNo != 516 || rIndexNo != 3 { + if err != nil || rSpaceNo != 616 || rIndexNo != 3 { t.Errorf("symbolic space and index params not resolved") } rSpaceNo, _, err = schema.ResolveSpaceIndex("schematest", nil) - if err != nil || rSpaceNo != 516 { + if err != nil || rSpaceNo != 616 { t.Errorf("symbolic space param not resolved") } _, _, err = schema.ResolveSpaceIndex("schematest22", "secondary")