diff --git a/RUNNING_TESTS.md b/RUNNING_TESTS.md index 0f5c1f0609..3bf395bbe1 100644 --- a/RUNNING_TESTS.md +++ b/RUNNING_TESTS.md @@ -17,11 +17,15 @@ and perform protocol encoder/decoder code generation. On Windows run: - build.bat +``` powershell +build.bat +``` -On osx/linux run: +On MacOS and linux run: - build.sh +``` shell +build.sh +``` This will complete the code AMQP 0-9-1 protocol code generation and build all projects. After this open the solution in Visual Studio. @@ -34,40 +38,56 @@ may take some time for the adapter to discover tests in the assemblies. The test suite assumes there's a RabbitMQ node running locally with all defaults, and the tests will need to be able to run commands against the [`rabbitmqctl`](https://www.rabbitmq.com/rabbitmqctl.8.html) tool for that node. -Two options to accomplish this are: +Two options to accomplish this are covered below. + +### Using RabbitMQ Umbrella Repository 1. Team RabbitMQ uses [rabbitmq-public-umbrella](https://github.com/rabbitmq/rabbitmq-public-umbrella), which sets up a local RabbitMQ server [built from source](https://www.rabbitmq.com/build-server.html): - ``` - git clone https://github.com/rabbitmq/rabbitmq-public-umbrella umbrella - cd umbrella - make co - cd deps/rabbit - make - make run-broker - ``` -2. You can load a RabbitMQ node in a [docker](https://www.docker.com/) container. You will need to create an environment variable `RABBITMQ_RABBITMQCTL_PATH` and set it to `DOCKER:` (for example `DOCKER:rabbitmq01`). This tells the unit tests to run the `rabbitmqctl` commands through docker, in the format `docker exec rabbitmq01 rabbitmqctl `: - ``` - docker run -d --hostname rabbitmq01 --name rabbitmq01 -p 15672:15672 -p 5672:5672 rabbitmq:3-management - ``` +``` +git clone https://github.com/rabbitmq/rabbitmq-public-umbrella umbrella +cd umbrella +make co +cd deps/rabbit +make +make run-broker +``` - Then, to run the tests on Windows use: +`rabbitmqctl` location will be computed using a relative path in the umbrella. +It is possible to override the location using `RABBITMQ_RABBITMQCTL_PATH`: - ``` - run-test.bat - ``` +``` +RABBITMQ_RABBITMQCTL_PATH=/path/to/rabbitmqctl dotnet test projects/Unit +``` - On MacOS, Linux, BSD use: +### Using a Docker Container - ``` - run-test.sh - ``` +It is also possible to run a RabbitMQ node in a [Docker](https://www.docker.com/) container. Set the environment variable `RABBITMQ_RABBITMQCTL_PATH` to `DOCKER:` (for example `DOCKER:rabbitmq01`). This tells the unit tests to run the `rabbitmqctl` commands through Docker, in the format `docker exec rabbitmq01 rabbitmqctl `: -Running individual tests and fixtures on Windows is trivial using the Visual Studio test runner. -To run a specific tests fixture on MacOS or Linux, use the NUnit filter expressions to select the tests -to be run: +``` shell +docker run -d --hostname rabbitmq01 --name rabbitmq01 -p 15672:15672 -p 5672:5672 rabbitmq:3-management +``` +### Running All Tests + +Then, to run the tests use: + +``` powershell +run-test.bat +``` + +On MacOS, Linux, BSD use: + +``` shell +run-test.sh ``` + +### Running Individual Suites or Test Casess + +Running individual tests and fixtures on Windows is trivial using the Visual Studio test runner. +To run a specific tests fixture on MacOS or Linux, use the NUnit filter expressions to select the tests to be run: + +``` shell dotnet test projects/Unit --filter "Name~TestAmqpUriParseFail" dotnet test projects/Unit --filter "FullyQualifiedName~RabbitMQ.Client.Unit.TestHeartbeats" diff --git a/_site b/_site index 6d7fc8d20e..b15c6d3532 160000 --- a/_site +++ b/_site @@ -1 +1 @@ -Subproject commit 6d7fc8d20e96310bfde5eb9cd6a261c920415d3a +Subproject commit b15c6d3532d726154b4371cd9b6ddcc12898f79d diff --git a/projects/RabbitMQ.Client/client/api/IBasicPublishBatch.cs b/projects/RabbitMQ.Client/client/api/IBasicPublishBatch.cs index f811512ead..a130656907 100644 --- a/projects/RabbitMQ.Client/client/api/IBasicPublishBatch.cs +++ b/projects/RabbitMQ.Client/client/api/IBasicPublishBatch.cs @@ -37,11 +37,13 @@ // The Initial Developer of the Original Code is Pivotal Software, Inc. // Copyright (c) 2007-2020 VMware, Inc. All rights reserved. //--------------------------------------------------------------------------- +using System; + namespace RabbitMQ.Client { public interface IBasicPublishBatch { - void Add(string exchange, string routingKey, bool mandatory, IBasicProperties properties, byte[] body); + void Add(string exchange, string routingKey, bool mandatory, IBasicProperties properties, ReadOnlyMemory body); void Publish(); } } diff --git a/projects/RabbitMQ.Client/client/impl/BasicPublishBatch.cs b/projects/RabbitMQ.Client/client/impl/BasicPublishBatch.cs index 7f4721e323..9da58658ce 100644 --- a/projects/RabbitMQ.Client/client/impl/BasicPublishBatch.cs +++ b/projects/RabbitMQ.Client/client/impl/BasicPublishBatch.cs @@ -38,6 +38,7 @@ // Copyright (c) 2007-2020 VMware, Inc. All rights reserved. //--------------------------------------------------------------------------- +using System; using System.Collections.Generic; using RabbitMQ.Client.Framing.Impl; @@ -48,12 +49,12 @@ class BasicPublishBatch : IBasicPublishBatch { private readonly List _commands = new List(); private readonly ModelBase _model; - internal BasicPublishBatch (ModelBase model) + internal BasicPublishBatch(ModelBase model) { _model = model; } - public void Add(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, byte[] body) + public void Add(string exchange, string routingKey, bool mandatory, IBasicProperties basicProperties, ReadOnlyMemory body) { IBasicProperties bp = basicProperties ?? _model.CreateBasicProperties(); var method = new BasicPublish