Skip to content

Add command and REST endpoint to list stream tracking info #9642

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 10, 2023

Conversation

acogoluegnes
Copy link
Contributor

No description provided.

@acogoluegnes acogoluegnes changed the title Add list_stream_tracking Add command and REST endpoint to list stream tracking info Oct 5, 2023
@mergify mergify bot added the bazel label Oct 5, 2023
@acogoluegnes acogoluegnes force-pushed the stream-list-tracking-info branch from 8598c3b to 4b8a442 Compare October 9, 2023 08:18
@acogoluegnes
Copy link
Contributor Author

acogoluegnes commented Oct 10, 2023

Acceptance Steps

Get the branch and start the broker:

cd /tmp
git clone [email protected]:rabbitmq/rabbitmq-server.git
cd rabbitmq-server
git checkout stream-list-tracking-info
make run-broker PLUGINS="rabbitmq_stream_management"

Open another tab in /tmp/rabbitmq-server and get the stream performance tool:

wget https://github.com/rabbitmq/rabbitmq-java-tools-binaries-dev/releases/download/v-stream-perf-test-latest/stream-perf-test-latest.jar

Once the broker is started, get the tracking info for a stream that does not exist:

sbin/rabbitmq-streams list_stream_tracking stream

Expected output:

Listing tracking information for stream stream ...
Error:
The stream does not exist.

Run the performance tool to create the stream:

java -jar stream-perf-test-latest.jar --rate 1000 --time 5

Get the tracking info:

sbin/rabbitmq-streams list_stream_tracking stream

Expected output (no tracking info yet):

Listing tracking information for stream stream ...

Run a consumer that does some offset tracking:

java -jar stream-perf-test-latest.jar --rate 1000 --time 5 --consumer-names consumer-1 --store-every 100

Get the tracking info:

sbin/rabbitmq-streams list_stream_tracking stream

Expected output (tracking_value does not matter):

Listing tracking information for stream stream ...
┌────────┬────────────┬────────────────┐
│ type   │ name       │ tracking_value │
├────────┼────────────┼────────────────┤
│ offset │ consumer-1 │ 14940          │
└────────┴────────────┴────────────────┘

Run a consumer with another name:

java -jar stream-perf-test-latest.jar --rate 1000 --time 5 --consumer-names consumer-2 --store-every 100

Get the tracking info:

sbin/rabbitmq-streams list_stream_tracking stream

Expected output, there should be 2 lines:

Listing tracking information for stream stream ...
┌────────┬────────────┬────────────────┐
│ type   │ name       │ tracking_value │
├────────┼────────────┼────────────────┤
│ offset │ consumer-2 │ 20085          │
├────────┼────────────┼────────────────┤
│ offset │ consumer-1 │ 14940          │
└────────┴────────────┴────────────────┘

Run a producer with deduplication:

java -jar stream-perf-test-latest.jar --rate 1000 --time 5 --consumer-names consumer-2 --store-every 100 --producer-names publisher-1

Get the tracking info:

sbin/rabbitmq-streams list_stream_tracking stream

Expected output, there should be 3 lines, one is for the producer (writer):

Listing tracking information for stream stream ...
┌────────┬─────────────┬────────────────┐
│ type   │ name        │ tracking_value │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-1 │ 4994           │
├────────┼─────────────┼────────────────┤
│ offset │ consumer-2  │ 25033          │
├────────┼─────────────┼────────────────┤
│ offset │ consumer-1  │ 14940          │
└────────┴─────────────┴────────────────┘

Run a producer with another name:

java -jar stream-perf-test-latest.jar --rate 1000 --time 5 --consumer-names consumer-2 --store-every 100 --producer-names publisher-2

Get the tracking info:

sbin/rabbitmq-streams list_stream_tracking stream

Expected output, there should be 4 lines, one more for the producer:

Listing tracking information for stream stream ...
┌────────┬─────────────┬────────────────┐
│ type   │ name        │ tracking_value │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-2 │ 5008           │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-1 │ 4994           │
├────────┼─────────────┼────────────────┤
│ offset │ consumer-2  │ 30183          │
├────────┼─────────────┼────────────────┤
│ offset │ consumer-1  │ 14940          │
└────────┴─────────────┴────────────────┘

Get only the writer lines:

sbin/rabbitmq-streams list_stream_tracking stream --writer

Expected output:

Listing tracking information for stream stream ...
┌────────┬─────────────┬────────────────┐
│ type   │ name        │ tracking_value │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-2 │ 5008           │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-1 │ 4994           │
└────────┴─────────────┴────────────────┘

Get only the consumer lines:

sbin/rabbitmq-streams list_stream_tracking stream --offset

Expected output:

Listing tracking information for stream stream ...
┌────────┬────────────┬────────────────┐
│ type   │ name       │ tracking_value │
├────────┼────────────┼────────────────┤
│ offset │ consumer-2 │ 30183          │
├────────┼────────────┼────────────────┤
│ offset │ consumer-1 │ 14940          │
└────────┴────────────┴────────────────┘

Get both (that's the default):

sbin/rabbitmq-streams list_stream_tracking stream --all

Expected output:

Listing tracking information for stream stream ...
┌────────┬─────────────┬────────────────┐
│ type   │ name        │ tracking_value │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-2 │ 5008           │
├────────┼─────────────┼────────────────┤
│ writer │ publisher-1 │ 4994           │
├────────┼─────────────┼────────────────┤
│ offset │ consumer-2  │ 30183          │
├────────┼─────────────┼────────────────┤
│ offset │ consumer-1  │ 14940          │
└────────┴─────────────┴────────────────┘

Wrong type:

sbin/rabbitmq-streams list_stream_tracking stream --foo

Expected output:

Error (argument validation): Invalid options for this command:
--foo :
Arguments given:
        list_stream_tracking stream --foo

Usage

rabbitmq-streams [--node <node>] [--longnames] [--quiet] list_stream_tracking <stream> [--all | --offset | --writer] [--vhost <vhost>]

REST endpoint:

curl -s -u guest:guest http://localhost:15672/api/stream/%2F/stream/tracking | jq .

Expected output (the actual offset/sequence values do not matter, only the names do):

{
  "writers": {
    "publisher-1": 4997,
    "publisher-2": 5017
  },
  "offsets": {
    "consumer-1": 7613,
    "consumer-2": 22775
  }
}

Only the producers:

curl -s -u guest:guest http://localhost:15672/api/stream/%2F/stream/tracking?type=writer | jq .

Expected output:

{
  "writers": {
    "publisher-1": 4997,
    "publisher-2": 5017
  }
}

Only the consumers:

curl -s -u guest:guest http://localhost:15672/api/stream/%2F/stream/tracking?type=offset | jq .

Expected output:

{
  "offsets": {
    "consumer-1": 7613,
    "consumer-2": 22775
  }
}

Correct output when there is no line, fix usage, formatting.
@acogoluegnes acogoluegnes force-pushed the stream-list-tracking-info branch from b840632 to 65d381e Compare October 10, 2023 08:58
@acogoluegnes acogoluegnes marked this pull request as ready for review October 10, 2023 09:35
Copy link
Contributor

@kjnilsson kjnilsson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@acogoluegnes acogoluegnes merged commit d47a987 into main Oct 10, 2023
@acogoluegnes acogoluegnes deleted the stream-list-tracking-info branch October 10, 2023 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants