Skip to content

Commit 85e9990

Browse files
authored
Merge pull request #52 from essentialkaos/develop
Version 1.2.0
2 parents 81b73af + 3fddda7 commit 85e9990

File tree

6 files changed

+63
-44
lines changed

6 files changed

+63
-44
lines changed

.github/workflows/ci.yml

+17-10
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@ concurrency:
2222
group: ${{ github.workflow }}-${{ github.ref }}
2323
cancel-in-progress: true
2424

25-
env:
26-
SRC_DIR: src/github.com/${{ github.repository }}
27-
2825
jobs:
2926
Go:
3027
name: Go
@@ -35,20 +32,30 @@ jobs:
3532
go: [ '1.20.x' ]
3633

3734
steps:
35+
- name: Checkout
36+
uses: actions/checkout@v3
37+
3838
- name: Set up Go
3939
uses: actions/setup-go@v4
4040
with:
4141
go-version: ${{ matrix.go }}
4242

43-
- name: Checkout
44-
uses: actions/checkout@v3
45-
with:
46-
path: ${{env.SRC_DIR}}
47-
4843
- name: Download dependencies
49-
working-directory: ${{env.SRC_DIR}}
5044
run: make deps
5145

5246
- name: Build binary
53-
working-directory: ${{env.SRC_DIR}}
5447
run: make all
48+
49+
Typos:
50+
name: Typos
51+
runs-on: ubuntu-latest
52+
53+
needs: Go
54+
55+
steps:
56+
- name: Checkout
57+
uses: actions/checkout@v3
58+
59+
- name: Check spelling
60+
continue-on-error: true
61+
uses: crate-ci/typos@master

.typos.toml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
[files]
2+
extend-exclude = [
3+
"go.sum",
4+
]
5+
6+
[default.extend-identifiers]
7+
O_WRONLY = "O_WRONLY"
8+
Redy = "Redy"
9+
redy = "redy"

cli/cli.go

+28-26
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import (
3535
// Application info
3636
const (
3737
APP = "RDS Payload Generator"
38-
VER = "1.1.3"
38+
VER = "1.2.0"
3939
DESC = "Payload generator for Redis-Split"
4040
)
4141

@@ -66,7 +66,7 @@ type RedisStore struct {
6666
// ////////////////////////////////////////////////////////////////////////////////// //
6767

6868
var optMap = options.Map{
69-
OPT_DIR: {Value: "/opt/redis-split"},
69+
OPT_DIR: {},
7070
OPT_KEYS: {Type: options.INT, Value: 5000, Min: 10, Max: 1000000},
7171
OPT_RATIO: {Type: options.INT, Value: 4, Min: 1, Max: 100},
7272
OPT_NO_COLOR: {Type: options.BOOL},
@@ -150,31 +150,19 @@ func configureUI() {
150150

151151
// checkRDSInstallation checks Redis-Split installation
152152
func checkRDSInstallation() {
153-
rdsDir := options.GetS(OPT_DIR)
154-
metaDir := rdsDir + "/meta"
155-
156-
if !fsutil.IsExist(rdsDir) {
157-
printError("Directory %s doesn't exist", rdsDir)
158-
os.Exit(1)
159-
}
160-
161-
if !fsutil.IsExist(metaDir) {
162-
printError("Directory %s doesn't exist", metaDir)
163-
os.Exit(1)
164-
}
153+
rdsDir := getRDSMainDir()
154+
err := fsutil.ValidatePerms("DRX", rdsDir)
165155

166-
if !fsutil.IsDir(rdsDir) {
167-
printError("%s is not a directory", metaDir)
156+
if err != nil {
157+
printError(err.Error())
168158
os.Exit(1)
169159
}
170160

171-
if !fsutil.IsDir(metaDir) {
172-
printError("%s is not a directory", metaDir)
173-
os.Exit(1)
174-
}
161+
metaDir := rdsDir + "/meta"
162+
err = fsutil.ValidatePerms("DRX", metaDir)
175163

176-
if fsutil.IsEmptyDir(metaDir) {
177-
printError("No instances are created")
164+
if err != nil {
165+
printError(err.Error())
178166
os.Exit(1)
179167
}
180168
}
@@ -188,7 +176,7 @@ func generatePayload() {
188176
var reads, writes int64
189177

190178
store := &RedisStore{make(map[string]*redy.Client)}
191-
metaDir := options.GetS(OPT_DIR) + "/meta"
179+
metaDir := getRDSMainDir() + "/meta"
192180
maxKey := options.GetI(OPT_KEYS)
193181
ratio := options.GetI(OPT_RATIO)
194182

@@ -230,6 +218,20 @@ func generatePayload() {
230218
}
231219
}
232220

221+
// getRDSMainDir returns path to main Redis-Split directory
222+
func getRDSMainDir() string {
223+
return fsutil.ProperPath("DRX",
224+
[]string{
225+
options.GetS(OPT_DIR),
226+
"/opt/redis-split",
227+
"/srv/redis-split",
228+
"/srv2/redis-split",
229+
"/srv3/redis-split",
230+
"/srv4/redis-split",
231+
},
232+
)
233+
}
234+
233235
// getPause returns pause between requests
234236
func getPause() time.Duration {
235237
r := 0.001 * float64(rand.Int(25))
@@ -243,7 +245,7 @@ func getKey(max int) string {
243245

244246
// isInstanceWorks returns true if instance is works
245247
func isInstanceWorks(id string) bool {
246-
pidDir := options.GetS(OPT_DIR) + "/pid"
248+
pidDir := getRDSMainDir() + "/pid"
247249
pidFile := fmt.Sprintf("%s/%s.pid", pidDir, id)
248250

249251
return fsutil.IsExist(pidFile)
@@ -326,9 +328,9 @@ func printMan() {
326328
func genUsage() *usage.Info {
327329
info := usage.NewInfo()
328330

329-
info.AddOption(OPT_DIR, "Redis-Split main dir", "dir")
331+
info.AddOption(OPT_DIR, "Path to Redis-Split main dir", "dir")
330332
info.AddOption(OPT_KEYS, "Number of keys {s-}(10-1000000 default: 5000){!}")
331-
info.AddOption(OPT_RATIO, "Writes/reads ration {s-}(1-100 default: 4){!}")
333+
info.AddOption(OPT_RATIO, "Writes/reads ratio {s-}(1-100 default: 4){!}")
332334
info.AddOption(OPT_NO_COLOR, "Disable colors in output")
333335
info.AddOption(OPT_HELP, "Show this help message")
334336
info.AddOption(OPT_VER, "Show version")

cli/support/support_linux.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func showOSInfo() {
3434
printInfo(12, "ID Like", osInfo.IDLike)
3535
printInfo(12, "Version ID", osInfo.VersionID)
3636
printInfo(12, "Version Code", osInfo.VersionCodename)
37+
printInfo(12, "Platform ID", osInfo.PlatformID)
3738
printInfo(12, "CPE", osInfo.CPEName)
3839
}
3940

@@ -81,8 +82,8 @@ func showEnvInfo(pkgs Pkgs) {
8182
// collectEnvInfo collects info about packages
8283
func collectEnvInfo() Pkgs {
8384
return Pkgs{
84-
getPackageInfo("redis"),
85-
getPackageInfo("redis-client"),
85+
getPackageInfo("redis", "redis5", "redis6", "redis7"),
86+
getPackageInfo("redis-cli", "redis5-cli", "redis6-cli", "redis7-cli"),
8687
getPackageInfo("redis-split"),
8788
getPackageInfo("redis-split-sync"),
8889
}

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ go 1.18
44

55
require (
66
github.com/essentialkaos/depsy v1.1.0
7-
github.com/essentialkaos/ek/v12 v12.68.0
8-
github.com/essentialkaos/redy/v4 v4.3.3
7+
github.com/essentialkaos/ek/v12 v12.73.2
8+
github.com/essentialkaos/redy/v4 v4.4.0
99
)
1010

1111
require golang.org/x/sys v0.10.0 // indirect

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
github.com/essentialkaos/check v1.4.0 h1:kWdFxu9odCxUqo1NNFNJmguGrDHgwi3A8daXX1nkuKk=
22
github.com/essentialkaos/depsy v1.1.0 h1:U6dp687UkQwXlZU17Hg2KMxbp3nfZAoZ8duaeUFYvJI=
33
github.com/essentialkaos/depsy v1.1.0/go.mod h1:kpiTAV17dyByVnrbNaMcZt2jRwvuXClUYOzpyJQwtG8=
4-
github.com/essentialkaos/ek/v12 v12.68.0 h1:/tNqKHfGypPUUu+aQ8LcmmWWEOO8itJZoJgOCPOZFY8=
5-
github.com/essentialkaos/ek/v12 v12.68.0/go.mod h1:CAPhbYcAiQsCP7CMyBlkgD/MgvuLcbr4EXjCIKn3DIk=
6-
github.com/essentialkaos/redy/v4 v4.3.3 h1:caq2gTnwTXdkq/j6tD0BNqzbTGVSZwZq+xmZSAgKEYg=
7-
github.com/essentialkaos/redy/v4 v4.3.3/go.mod h1:0TUOQZGzhRmZD13sCVUtYUYCa3Xd8v0zu2TgV6dwcHk=
4+
github.com/essentialkaos/ek/v12 v12.73.2 h1:MrHHcH1/qOmeMGruRdtcyWTxHQh85QEvxc8aUmjY07c=
5+
github.com/essentialkaos/ek/v12 v12.73.2/go.mod h1:juDcZWOWaj1QmYShZkT9RzdqJ3n0tmeP/iq4sw5fQF0=
6+
github.com/essentialkaos/redy/v4 v4.4.0 h1:6r6AkZiDkFWPqnvl0M+u7mcaaWQaeeiZOoLqLAMcnzQ=
7+
github.com/essentialkaos/redy/v4 v4.4.0/go.mod h1:0TUOQZGzhRmZD13sCVUtYUYCa3Xd8v0zu2TgV6dwcHk=
88
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
99
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
1010
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=

0 commit comments

Comments
 (0)