blob: 7a58fe3d8614149ad7ea66316afce211a1f2e6d0 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/messagebus/errorcode.h>
#include <vespa/messagebus/routing/retrytransienterrorspolicy.h>
#include <vespa/messagebus/testlib/receptor.h>
#include <vespa/messagebus/testlib/simplemessage.h>
#include <vespa/messagebus/testlib/simpleprotocol.h>
#include <vespa/messagebus/testlib/slobrok.h>
#include <vespa/messagebus/testlib/testserver.h>
#include <vespa/vespalib/testkit/testapp.h>
using namespace mbus;
class MyMessage : public SimpleMessage {
public:
MyMessage() : SimpleMessage("foo") { }
bool hasBucketSequence() const override { return true; }
};
TEST("bucketsequence_test") {
Slobrok slobrok;
TestServer server(MessageBusParams()
.addProtocol(std::make_shared<SimpleProtocol>())
.setRetryPolicy(std::make_shared<RetryTransientErrorsPolicy>()),
RPCNetworkParams(slobrok.config()));
Receptor receptor;
SourceSession::UP session = server.mb.createSourceSession(
SourceSessionParams()
.setReplyHandler(receptor));
auto msg = std::make_unique<MyMessage>();
msg->setRoute(Route::parse("foo"));
ASSERT_TRUE(session->send(std::move(msg)).isAccepted());
Reply::UP reply = receptor.getReply();
ASSERT_TRUE(reply);
EXPECT_EQUAL(1u, reply->getNumErrors());
EXPECT_EQUAL((uint32_t)ErrorCode::SEQUENCE_ERROR, reply->getError(0).getCode());
}
TEST_MAIN() { TEST_RUN_ALL(); }
|