-
Notifications
You must be signed in to change notification settings - Fork 66
/
tarantool_test.go
110 lines (93 loc) · 2.67 KB
/
tarantool_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
package tarantool
import(
"testing"
"fmt"
)
func TestClient(t *testing.T) {
server := "127.0.0.1:3013"
spaceNo := uint32(512)
indexNo := uint32(0)
limit := uint32(10)
offset := uint32(0)
iterator := IterAll
key := []interface{}{ 12 }
tuple1 := []interface{}{ 12, "Hello World", "Olga" }
tuple2 := []interface{}{ 12, "Hello Mars", "Anna" }
upd_tuple := []interface{}{ []interface{}{ "=", 1, "Hello Moon" }, []interface{}{ "#", 2, 1 } }
functionName := "box.cfg()"
functionTuple := []interface{}{ "box.schema.SPACE_ID" }
client, err := Connect(server)
if err != nil {
t.Errorf("No connection available")
}
var resp *Response
resp, err = client.Ping()
fmt.Println("Ping")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Insert(spaceNo, tuple1)
fmt.Println("Insert")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Select(spaceNo, indexNo, offset, limit, iterator, key)
fmt.Println("Select")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Replace(spaceNo, tuple2)
fmt.Println("Replace")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Select(spaceNo, indexNo, offset, limit, iterator, key)
fmt.Println("Select")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Update(spaceNo, indexNo, key, upd_tuple)
fmt.Println("Update")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Select(spaceNo, indexNo, offset, limit, iterator, key)
fmt.Println("Select")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
responses := make(chan *Response)
cnt1 := 50
cnt2 := 500
for j := 0; j < cnt1; j++ {
for i := 0; i < cnt2; i++ {
go func(){
resp, err = client.Select(spaceNo, indexNo, offset, limit, iterator, key)
responses <- resp
}()
}
for i := 0; i < cnt2; i++ {
resp = <-responses
// fmt.Println(resp)
}
}
resp, err = client.Delete(spaceNo, indexNo, key)
fmt.Println("Delete")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
resp, err = client.Call(functionName, functionTuple)
fmt.Println("Call")
fmt.Println("ERROR", err)
fmt.Println("Code", resp.Code)
fmt.Println("Data", resp.Data)
fmt.Println("----")
}