Skip to content

Commit 52ef19d

Browse files
Merge pull request #1 from filipecosta90/publish.binaries
Included -a and -user connection options. Publishing binary artifacts via github
2 parents 90c2650 + cc0a12d commit 52ef19d

File tree

5 files changed

+175
-39
lines changed

5 files changed

+175
-39
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# For most projects, this workflow file will not need changing; you simply need
2+
# to commit it to your repository.
3+
#
4+
# You may wish to alter this file to override the set of languages analyzed,
5+
# or to provide custom queries or build logic.
6+
#
7+
# ******** NOTE ********
8+
# We have attempted to detect the languages in your repository. Please check
9+
# the `language` matrix defined below to confirm you have the correct set of
10+
# supported CodeQL languages.
11+
#
12+
name: "CodeQL"
13+
14+
on:
15+
push:
16+
branches:
17+
- master
18+
- main
19+
pull_request:
20+
# The branches below must be a subset of the branches above
21+
branches:
22+
- master
23+
- main
24+
schedule:
25+
- cron: '19 18 * * 4'
26+
27+
jobs:
28+
analyze:
29+
name: Analyze
30+
runs-on: ubuntu-latest
31+
permissions:
32+
actions: read
33+
contents: read
34+
security-events: write
35+
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
language: [ 'go' ]
40+
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
41+
# Learn more about CodeQL language support at https://git.io/codeql-language-support
42+
43+
steps:
44+
- name: Checkout repository
45+
uses: actions/checkout@v2
46+
47+
# Initializes the CodeQL tools for scanning.
48+
- name: Initialize CodeQL
49+
uses: github/codeql-action/init@v1
50+
with:
51+
languages: ${{ matrix.language }}
52+
# If you wish to specify custom queries, you can do so here or in a config file.
53+
# By default, queries listed here will override any specified in a config file.
54+
# Prefix the list here with "+" to use these queries and those in the config file.
55+
# queries: ./path/to/local/query, your-org/your-repo/queries@main
56+
57+
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
58+
# If this step fails, then you should remove it and run the build manually (see below)
59+
- name: Autobuild
60+
uses: github/codeql-action/autobuild@v1
61+
62+
# ℹ️ Command-line programs to run using the OS shell.
63+
# 📚 https://git.io/JvXDl
64+
65+
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
66+
# and modify them (or add more) to build your code if your project
67+
# uses a compiled language
68+
69+
#- run: |
70+
# make bootstrap
71+
# make release
72+
73+
- name: Perform CodeQL Analysis
74+
uses: github/codeql-action/analyze@v1

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# .github/workflows/github-release-publish.yml
2+
name: Publish artifacts to github release
3+
4+
on:
5+
release:
6+
types: [published]
7+
8+
jobs:
9+
releases-matrix:
10+
name: Release Go Binary
11+
runs-on: ubuntu-latest
12+
strategy:
13+
matrix:
14+
goos: [linux, darwin]
15+
goarch: [amd64, arm64]
16+
steps:
17+
- uses: actions/checkout@v3
18+
- uses: wangyoucao577/[email protected]
19+
with:
20+
github_token: ${{ secrets.GITHUB_TOKEN }}
21+
goos: ${{ matrix.goos }}
22+
goarch: ${{ matrix.goarch }}
23+
binary_name: "redisgraph-benchmark-go"
24+
sha256sum: true
25+
asset_name: redisgraph-benchmark-go-${{ matrix.goos }}-${{ matrix.goarch }}
26+
build_command: "make build"

.github/workflows/unit-tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ jobs:
44
test:
55
strategy:
66
matrix:
7-
go-version: [1.11.x, 1.12.x, 1.13.x, 1.14.x, 1.15.x]
8-
os: [ubuntu-latest, macos-latest, windows-latest]
7+
go-version: [1.17.x, 1.18.x, 1.19.x]
8+
os: [ubuntu-latest]
99
runs-on: ${{ matrix.os }}
1010
steps:
1111
- name: Install Go
@@ -15,4 +15,4 @@ jobs:
1515
- name: Checkout code
1616
uses: actions/checkout@v2
1717
- name: Test
18-
run: make test
18+
run: make test

README.md

Lines changed: 54 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11

2+
[![license](https://img.shields.io/github/license/filipecosta90/pubsub-sub-bench.svg)](https://github.com/filipecosta90/pubsub-sub-bench)
3+
[![GitHub issues](https://img.shields.io/github/release/filipecosta90/pubsub-sub-bench.svg)](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest)
4+
[![codecov](https://codecov.io/github/filipecosta90/pubsub-sub-bench/branch/main/graph/badge.svg?token=B6ISQSDK3Y)](https://codecov.io/github/filipecosta90/pubsub-sub-bench)
5+
6+
27
## Overview
38

49
When benchmarking a Pub/Sub Systems, we specifically require two distinct roles ( publishers and subscribers ) as benchmark participants - this repo contains code to mimic the subscriber workload on Redis Pub/Sub.
@@ -10,24 +15,40 @@ Several aspects can dictate the overall system performance, like the:
1015
- Number of subscribers per channel (controlled on subscriber)
1116
- Subscriber distribution per shard and channel (controlled on subscriber)
1217

18+
## Installation
1319

14-
## Getting Started
20+
### Download Standalone binaries ( no Golang needed )
1521

16-
### Installing
17-
This benchmark go program is **know to be supported for go >= 1.11**.
18-
The easiest way to get and install the Subscriber Go program is to use `go get` and then `go install`:
22+
If you don't have go on your machine and just want to use the produced binaries you can download the following prebuilt bins:
1923

20-
```
21-
go get github.com/RedisLabs/pubsub-sub-bench
22-
cd $GOPATH/src/github.com/RedisLabs/pubsub-sub-bench
23-
make
24-
```
24+
https://github.com/filipecosta90/pubsub-sub-bench/releases/latest
25+
26+
| OS | Arch | Link |
27+
| :--- | :---: | ---: |
28+
| Linux | amd64 (64-bit X86) | [pubsub-sub-bench-linux-amd64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-linux-amd64.tar.gz) |
29+
| Linux | arm64 (64-bit ARM) | [pubsub-sub-bench-linux-arm64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-linux-arm64.tar.gz) |
30+
| Darwin | amd64 (64-bit X86) | [pubsub-sub-bench-darwin-amd64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-darwin-amd64.tar.gz) |
31+
| Darwin | arm64 (64-bit ARM) | [pubsub-sub-bench-darwin-arm64](https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-darwin-arm64.tar.gz) |
32+
33+
Here's how bash script to download and try it:
2534

26-
#### Updating
27-
To update the Subscriber Go program use `go get -u` to retrieve the latest version:.
35+
```bash
36+
wget -c https://github.com/filipecosta90/pubsub-sub-bench/releases/latest/download/pubsub-sub-bench-$(uname -mrs | awk '{ print tolower($1) }')-$(dpkg --print-architecture).tar.gz -O - | tar -xz
37+
38+
# give it a try
39+
./pubsub-sub-bench --help
2840
```
29-
go get -u github.com/RedisLabs/pubsub-sub-bench
30-
cd $GOPATH/src/github.com/RedisLabs/pubsub-sub-bench
41+
42+
43+
### Installation in a Golang env
44+
45+
To install the benchmark utility with a Go Env do as follow:
46+
47+
`go get` and then `go install`:
48+
```bash
49+
# Fetch this repo
50+
go get github.com/filipecosta90/pubsub-sub-bench
51+
cd $GOPATH/src/github.com/filipecosta90/pubsub-sub-bench
3152
make
3253
```
3354

@@ -40,33 +61,38 @@ Therefore you should only use this tool on go >= 1.11.
4061
## Usage of pubsub-sub-bench
4162

4263
```
43-
Usage of pubsub-sub-bench:
64+
Usage of ./pubsub-sub-bench:
65+
-a string
66+
Password for Redis Auth.
4467
-channel-maximum int
45-
channel ID maximum value ( each channel has a dedicated thread ). (default 100)
68+
channel ID maximum value ( each channel has a dedicated thread ). (default 100)
4669
-channel-minimum int
47-
channel ID minimum value ( each channel has a dedicated thread ). (default 1)
70+
channel ID minimum value ( each channel has a dedicated thread ). (default 1)
4871
-client-output-buffer-limit-pubsub string
49-
Specify client output buffer limits for clients subscribed to at least one pubsub channel or pattern. If the value specified is different that the one present on the DB, this setting will apply.
72+
Specify client output buffer limits for clients subscribed to at least one pubsub channel or pattern. If the value specified is different that the one present on the DB, this setting will apply.
5073
-client-update-tick int
51-
client update tick. (default 1)
74+
client update tick. (default 1)
5275
-host string
53-
redis host. (default "127.0.0.1")
76+
redis host. (default "127.0.0.1")
5477
-json-out-file string
55-
Name of json output file, if not set, will not print to json.
78+
Name of json output file, if not set, will not print to json.
5679
-messages int
57-
Number of total messages per subscriber per channel.
80+
Number of total messages per subscriber per channel.
5881
-oss-cluster-api-distribute-subscribers
59-
read cluster slots and distribute subscribers among them.
82+
read cluster slots and distribute subscribers among them.
6083
-port string
61-
redis port. (default "6379")
84+
redis port. (default "6379")
6285
-print-messages
63-
print messages.
86+
print messages.
6487
-subscriber-prefix string
65-
prefix for subscribing to channel, used in conjunction with key-minimum and key-maximum. (default "channel-")
88+
prefix for subscribing to channel, used in conjunction with key-minimum and key-maximum. (default "channel-")
6689
-subscribers-per-channel int
67-
number of subscribers per channel. (default 1)
90+
number of subscribers per channel. (default 1)
6891
-subscribers-placement-per-channel string
69-
(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner. (default "dense")
92+
(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner. (default "dense")
7093
-test-time int
71-
Number of seconds to run the test, after receiving the first message.
94+
Number of seconds to run the test, after receiving the first message.
95+
-user string
96+
Used to send ACL style 'AUTH username pass'. Needs -a.
97+
7298
```

subscriber.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ type testResult struct {
3333
Addresses []string `json:"Addresses"`
3434
}
3535

36-
func subscriberRoutine(addr string, subscriberName string, channel string, printMessages bool, stop chan struct{}, wg *sync.WaitGroup) {
36+
func subscriberRoutine(addr string, subscriberName string, channel string, printMessages bool, stop chan struct{}, wg *sync.WaitGroup, opts []radix.DialOpt) {
3737
// tell the caller we've stopped
3838
defer wg.Done()
3939

40-
conn, _, _, msgCh, _ := bootstrapPubSub(addr, subscriberName, channel)
40+
conn, _, _, msgCh, _ := bootstrapPubSub(addr, subscriberName, channel, opts)
4141
defer conn.Close()
4242

4343
for {
@@ -54,9 +54,9 @@ func subscriberRoutine(addr string, subscriberName string, channel string, print
5454
}
5555
}
5656

57-
func bootstrapPubSub(addr string, subscriberName string, channel string) (radix.Conn, error, radix.PubSubConn, chan radix.PubSubMessage, *time.Ticker) {
57+
func bootstrapPubSub(addr string, subscriberName string, channel string, opts []radix.DialOpt) (radix.Conn, error, radix.PubSubConn, chan radix.PubSubMessage, *time.Ticker) {
5858
// Create a normal redis connection
59-
conn, err := radix.Dial("tcp", addr)
59+
conn, err := radix.Dial("tcp", addr, opts...)
6060
if err != nil {
6161
log.Fatal(err)
6262
}
@@ -81,6 +81,8 @@ func bootstrapPubSub(addr string, subscriberName string, channel string) (radix.
8181
func main() {
8282
host := flag.String("host", "127.0.0.1", "redis host.")
8383
port := flag.String("port", "6379", "redis port.")
84+
password := flag.String("a", "", "Password for Redis Auth.")
85+
username := flag.String("user", "", "Used to send ACL style 'AUTH username pass'. Needs -a.")
8486
subscribers_placement := flag.String("subscribers-placement-per-channel", "dense", "(dense,sparse) dense - Place all subscribers to channel in a specific shard. sparse- spread the subscribers across as many shards possible, in a round-robin manner.")
8587
channel_minimum := flag.Int("channel-minimum", 1, "channel ID minimum value ( each channel has a dedicated thread ).")
8688
channel_maximum := flag.Int("channel-maximum", 100, "channel ID maximum value ( each channel has a dedicated thread ).")
@@ -98,13 +100,21 @@ func main() {
98100
var nodes []radix.ClusterNode
99101
var nodesAddresses []string
100102
var node_subscriptions_count []int
103+
opts := make([]radix.DialOpt, 0)
104+
if *password != "" {
105+
if *username != "" {
106+
opts = append(opts, radix.DialAuthUser(*username, *password))
107+
} else {
108+
opts = append(opts, radix.DialAuthPass(*password))
109+
}
110+
}
101111

102112
if *test_time != 0 && *messages_per_channel_subscriber != 0 {
103113
log.Fatal(fmt.Errorf("--messages and --test-time are mutially exclusive ( please specify one or the other )"))
104114
}
105115

106116
if *distributeSubscribers {
107-
nodes, nodesAddresses, node_subscriptions_count = getClusterNodesFromTopology(host, port, nodes, nodesAddresses, node_subscriptions_count)
117+
nodes, nodesAddresses, node_subscriptions_count = getClusterNodesFromTopology(host, port, nodes, nodesAddresses, node_subscriptions_count, opts)
108118
} else {
109119
nodes, nodesAddresses, node_subscriptions_count = getClusterNodesFromArgs(nodes, port, host, nodesAddresses, node_subscriptions_count)
110120
}
@@ -132,7 +142,7 @@ func main() {
132142
channel := fmt.Sprintf("%s%d", *subscribe_prefix, channel_id)
133143
subscriberName := fmt.Sprintf("subscriber#%d-%s%d", channel_subscriber_number, *subscribe_prefix, channel_id)
134144
wg.Add(1)
135-
go subscriberRoutine(addr.Addr, subscriberName, channel, *printMessages, stopChan, &wg)
145+
go subscriberRoutine(addr.Addr, subscriberName, channel, *printMessages, stopChan, &wg, opts)
136146
}
137147
}
138148
}
@@ -205,9 +215,9 @@ func getClusterNodesFromArgs(nodes []radix.ClusterNode, port *string, host *stri
205215
return nodes, nodesAddresses, node_subscriptions_count
206216
}
207217

208-
func getClusterNodesFromTopology(host *string, port *string, nodes []radix.ClusterNode, nodesAddresses []string, node_subscriptions_count []int) ([]radix.ClusterNode, []string, []int) {
218+
func getClusterNodesFromTopology(host *string, port *string, nodes []radix.ClusterNode, nodesAddresses []string, node_subscriptions_count []int, opts []radix.DialOpt) ([]radix.ClusterNode, []string, []int) {
209219
// Create a normal redis connection
210-
conn, err := radix.Dial("tcp", fmt.Sprintf("%s:%s", *host, *port))
220+
conn, err := radix.Dial("tcp", fmt.Sprintf("%s:%s", *host, *port), opts...)
211221
if err != nil {
212222
panic(err)
213223
}

0 commit comments

Comments
 (0)