forked from kyma-incubator/compass
-
Notifications
You must be signed in to change notification settings - Fork 1
/
gen.go
79 lines (65 loc) · 1.43 KB
/
gen.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
package main
import (
"bufio"
"fmt"
"os"
)
func main() {
appFile, err := os.Create("./sql/03_app.csv")
if err != nil {
panic(err)
}
defer appFile.Close()
apiFile, err := os.Create("./sql/04_api.csv")
if err != nil {
panic(err)
}
defer apiFile.Close()
evFile, err := os.Create("./sql/05_ev.csv")
if err != nil {
panic(err)
}
defer evFile.Close()
docFile, err := os.Create("./sql/06_doc.csv")
if err != nil {
panic(err)
}
defer docFile.Close()
appBuff := bufio.NewWriter(appFile)
apiBuff := bufio.NewWriter(apiFile)
evBuff := bufio.NewWriter(evFile)
docBuff := bufio.NewWriter(docFile)
apps := 1000
apis := 10
events := 10
docs := 10
for i := 0; i < apps; i++ {
panicOnWritingErrors(fmt.Fprintf(appBuff, "%d,app-%d,tenant-%d\n", i, i, i))
for k := 0; k < apis; k++ {
panicOnWritingErrors(fmt.Fprintf(apiBuff, "%d,api-%d,%d\n", k+i*apis, k+i*apis, i))
}
for k := 0; k < events; k++ {
panicOnWritingErrors(fmt.Fprintf(evBuff, "%d,ev-%d,%d\n", k+i*apis, k+i*apis, i))
}
for k := 0; k < docs; k++ {
panicOnWritingErrors(fmt.Fprintf(docBuff, "%d,doc-%d,%d\n", k+i*apis, k+i*apis, i))
}
}
if err := appBuff.Flush(); err != nil {
panic(err)
}
if err := apiBuff.Flush(); err != nil {
panic(err)
}
if err := evBuff.Flush(); err != nil {
panic(err)
}
if err := docBuff.Flush(); err != nil {
panic(err)
}
}
func panicOnWritingErrors(_ int, err error) {
if err != nil {
panic(err)
}
}