Skip to content
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

Add -sni option #253

Merged
merged 1 commit into from
Dec 1, 2020
Merged

Add -sni option #253

merged 1 commit into from
Dec 1, 2020

Conversation

acogoluegnes
Copy link
Collaborator

Fixes #252

@acogoluegnes
Copy link
Collaborator Author

To accept:

Start a broker with TLS enabled:

cd /tmp
git clone https://github.com/michaelklishin/tls-gen.git
cd tls-gen/basic
make
docker run -it --rm --name rabbitmq -p 5672:5672 -p 5671:5671 -e RABBITMQ_SSL_CACERTFILE=/tmp/tls-gen/basic/result/ca_certificate.pem -e RABBITMQ_SSL_CERTFILE=/tmp/tls-gen/basic/result/server_certificate.pem -e RABBITMQ_SSL_KEYFILE=/tmp/tls-gen/basic/result/server_key.pem -e RABBITMQ_SSL_VERIFY=verify_peer -e RABBITMQ_SSL_FAIL_IF_NO_PEER_CERT=false -v /tmp/tls-gen/basic/result/:/tmp/tls-gen/basic/result/ rabbitmq:3

Open another terminal and checkout PerfTest:

cd /tmp
git clone git@github.com:rabbitmq/rabbitmq-perf-test.git
cd rabbitmq-perf-test
make binary
tar xf target/rabbitmq-perf-test-2.13.0-SNAPSHOT-bin.tar.gz

Start with with SNI, stop once the metrics show up:

rabbitmq-perf-test-2.13.0-SNAPSHOT/bin/runjava -Djavax.net.debug=ssl:handshake com.rabbitmq.perf.PerfTest -r 500 -uris amqps://localhost -sni $(hostname) 2> log.txt

Check in the Java TLS log that SNI has been set up

more log.txt | grep -B 5 -A 5 "value=$(hostname)"

It should output something like:

"extensions"          : [
    "server_name (0)": {
      type=host_name (0), value=acogoluegnes-inspiron
    },
    "supported_groups (10)": {
      "versions": [secp256r1, secp384r1, secp521r1, ffdhe2048, ffdhe3072, ffdhe4096, ffdhe6144, ffdhe8192]
    },
    "ec_point_formats (11)": {
--

Without SNI:

rabbitmq-perf-test-2.13.0-SNAPSHOT/bin/runjava -Djavax.net.debug=ssl:handshake com.rabbitmq.perf.PerfTest -r 500 -uris amqps://localhost 2> log.txt
more log.txt | grep -B 5 -A 5 "value=$(hostname)"

Should output nothing.

Same tests, but with the NIO connector (--nio-threads parameter):

rabbitmq-perf-test-2.13.0-SNAPSHOT/bin/runjava -Djavax.net.debug=ssl:handshake com.rabbitmq.perf.PerfTest -r 500 -uris amqps://localhost --nio-threads 10 -sni $(hostname) 2> log.txt
more log.txt | grep -B 5 -A 5 "value=$(hostname)"

rabbitmq-perf-test-2.13.0-SNAPSHOT/bin/runjava -Djavax.net.debug=ssl:handshake com.rabbitmq.perf.PerfTest -r 500 -uris amqps://localhost --nio-threads 10 2> log.txt
more log.txt | grep -B 5 -A 5 "value=$(hostname)"

@Gsantomaggio
Copy link
Member

Looks good to me
Tested on Kubernetes.

With the right SNI tgir-s01e08-bugs.rabbitmq.com:

 rabbitmq-perf-test-2.13.0-SNAPSHOT/bin/runjava -Djavax.net.debug=ssl:handshake com.rabbitmq.perf.PerfTest -r 500 -uris amqps://test:test@10.101.46.98  --nio-threads 2  -sni tgir-s01e08-bugs.rabbitmq.com

....
id: test-082723-362, time: 2.000s, sent: 500 msg/s, received: 501 msg/s, min/median/75th/95th/99th consumer latency: 561/728/822/1261/1752 µs                                                                                        
id: test-082723-362, time: 3.000s, sent: 500 msg/s, received: 500 msg/s, min/median/75th/95th/99th consumer latency: 505/679/774/1157/2761 µs  

With the wrong SNI tgir-s01e08-nohost.rabbitmq.com:

...
Main thread caught exception: java.util.concurrent.TimeoutException                                                                                                                                                                  
08:33:38.207 [main] ERROR com.rabbitmq.perf.PerfTest - Main thread caught exception                                                                                                                                                  
java.util.concurrent.TimeoutException: null

@acogoluegnes acogoluegnes merged commit 17f09de into master Dec 1, 2020
@michaelklishin michaelklishin deleted the rabbitmq-perf-test-252-sni branch December 1, 2020 15:38
@gerhard
Copy link
Contributor

gerhard commented Dec 28, 2020

Could we expose this as an environment variable? I am not seeing it in 2.13 via --help --env

# docker run -it --rm pivotalrabbitmq/perf-test:2.13.0 --help --env

usage: <program>. For multi-value options, separate values with commas,
                  e.g. VARIABLE_RATE='100:60,1000:10,500:15'
 AUTO_DELETE                    should the queue be auto-deleted, default
                                is true
 AUTOACK                        auto ack
 BODY                           comma-separated list of files to use in
                                message bodies
 BODY_CONTENT_TYPE              body content-type
 BODY_COUNT                     number of pre-generated message bodies.
                                Use with --json-body. Default is 100.
 BODY_FIELD_COUNT               number of pre-generated fields and values
                                for body. Use with --json-body. Default is
                                1000.
 CMESSAGES                      consumer message count
 CONFIRM                        max unconfirmed publishes
 CONFIRM_TIMEOUT                waiting timeout for unconfirmed publishes
                                before failing (in seconds)
 CONNECTION_RECOVERY_INTERVAL   connection recovery interval in seconds.
                                Default is 5 seconds. Interval syntax,
                                e.g. 30-60, is supported to specify an
                                random interval between 2 values between
                                each attempt.
 CONSUMER_ARGS                  consumer arguments as key/values pairs,
                                separated by commas, e.g. x-priority=10
 CONSUMER_CHANNEL_COUNT         channels per consumer
 CONSUMER_LATENCY               consumer latency in microseconds
 CONSUMER_RATE                  consumer rate limit
 CONSUMERS                      consumer count
 CONSUMERS_THREAD_POOLS         number of thread pools to use for all
                                consumers, default is to use a thread pool
                                for each consumer
 CTXSIZE                        consumer tx size
 DISABLE_CONNECTION_RECOVERY    disable automatic connection recovery
 EXCHANGE                       exchange name
 EXCLUSIVE                      use server-named exclusive queues. Such
                                queues can only be used by their declaring
                                connection!
 FLAG                           message flag(s), supported values:
                                persistent and mandatory. Use the option
                                several times to specify several values.
 FRAMEMAX                       frame max
 GLOBAL_QOS                     channel prefetch count
 HEARTBEAT                      heartbeat interval
 HEARTBEAT_SENDER_THREADS       number of threads for producers and
                                consumers heartbeat senders
 ID                             test ID
 INTERVAL                       sampling interval in seconds
 JSON_BODY                      generate a random JSON document for
                                message body. Use with --size.
 LEGACY_METRICS                 display legacy metrics (min/avg/max
                                latency)
 MESSAGE_PROPERTIES             message properties as key/value pairs,
                                separated by commas, e.g. priority=5
 METRICS_HELP                   show metrics usage
 MULTI_ACK_EVERY                multi ack every
 NACK                           nack and requeue messages
 NIO_THREAD_POOL                size of NIO thread pool, should be
                                slightly higher than number of NIO threads
 NIO_THREADS                    number of NIO threads to use
 OUTPUT_FILE                    output file for timing results
 PMESSAGES                      producer message count
 POLLING                        use basic.get to consume messages. Do not
                                use this in real applications.
 POLLING_INTERVAL               time to wait before polling with
                                basic.get, in millisecond, default is 0.
 PREDECLARED                    allow use of predeclared objects
 PRODUCER_CHANNEL_COUNT         channels per producer
 PRODUCER_RANDOM_START_DELAY    max random delay in seconds to start
                                producers
 PRODUCER_SCHEDULER_THREADS     number of threads to use when using
                                --publishing-interval
 PRODUCERS                      producer count
 PTXSIZE                        producer tx size
 PUBLISHING_INTERVAL            publishing interval in seconds (opposite
                                of producer rate limit)
 QOS                            consumer prefetch count
 QUEUE                          queue name
 QUEUE_ARGS                     queue arguments as key/value pairs,
                                separated by commas, e.g. x-max-length=10
 QUEUE_PATTERN                  queue name pattern for creating queues in
                                sequence
 QUEUE_PATTERN_FROM             queue name pattern range start (inclusive)
 QUEUE_PATTERN_TO               queue name pattern range end (inclusive)
 RANDOM_ROUTING_KEY             use random routing key per message
 RATE                           producer rate limit
 ROUTING_KEY                    routing key
 ROUTING_KEY_CACHE_SIZE         size of the random routing keys cache. See
                                --random-routing-key.
 SASL_EXTERNAL                  use SASL EXTERNAL authentication, default
                                is false. Set to true if using client
                                certificate authentication with the
                                rabbitmq_auth_mechanism_ssl plugin.
 SERVER_NAME_INDICATION         server names for Server Name Indication
                                TLS parameter, separated by commas
 SERVERS_STARTUP_TIMEOUT        start timeout in seconds (in case the
                                servers(s) is (are) not available when the
                                run starts). Default is to fail
                                immediately if the servers(s) is (are) not
                                available.
 SERVERS_UP_LIMIT               number of available servers needed before
                                starting the run. Used in conjunction with
                                --servers-start-timeout. Default is
                                deduced from --uri or --uris.
 SHUTDOWN_TIMEOUT               shutdown timeout, default is 5 seconds
 SIZE                           message size in bytes
 SKIP_BINDING_QUEUES            don't bind queues to the exchange
 SLOW_START                     start consumers slowly (1 sec delay
                                between each)
 TIME                           run duration in seconds (unlimited by
                                default)
 TYPE                           exchange type
 URI                            connection URI
 URIS                           connection URIs (separated by commas)
 USE_DEFAULT_SSL_CONTEXT        use JVM default SSL context
 USE_MILLIS                     should latency be collected in
                                milliseconds, default is false. Set to
                                true if producers are consumers run on
                                different machines.
 VARIABLE_LATENCY               variable consumer processing latency with
                                [MICROSECONDS]:[DURATION] syntax, where
                                [MICROSECONDS] integer >= 0 and [DURATION]
                                integer > 0. Use the option several times
                                to specify several values.
 VARIABLE_RATE                  variable publishing rate with
                                [RATE]:[DURATION] syntax, where [RATE]
                                integer >= 0 and [DURATION] integer > 0.
                                Use the option several times to specify
                                several values.
 VARIABLE_SIZE                  variable message size with
                                [SIZE]:[DURATION] syntax, where [SIZE]
                                integer > 0 and [DURATION] integer > 0.
                                Use the option several times to specify
                                several values.

@acogoluegnes
Copy link
Collaborator Author

 SERVER_NAME_INDICATION         server names for Server Name Indication
                                TLS parameter, separated by commas

It's there, the environment variables variant uses only the options long name.

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.

[RFE] Add parameters to enable SNI
3 participants