aboutsummaryrefslogtreecommitdiffstats
path: root/messagebus/src/vespa/messagebus/testlib/testserver.h
blob: f3f349e52b93534af0714e9ee0d9314da9ed61bb (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
41
42
43
44
45
46
47
48
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/messagebus/messagebus.h>
#include <vespa/messagebus/network/rpcnetwork.h>
#include <vespa/messagebus/network/rpcnetworkparams.h>
#include <vespa/fnet/frt/supervisor.h>

namespace mbus {

class Identity;
class RoutingTableSpec;
class Slobrok;
class SlobrokState;

class VersionedRPCNetwork : public RPCNetwork {
private:
    vespalib::Version _version;

protected:
    const vespalib::Version &getVersion() const override { return _version; }

public:
    VersionedRPCNetwork(const RPCNetworkParams &params);
    ~VersionedRPCNetwork() override;
    void setVersion(const vespalib::Version &version);
};

class TestServer {
public:
    using UP = std::unique_ptr<TestServer>;
    TestServer(const TestServer &) = delete;
    TestServer & operator = (const TestServer &) = delete;

    VersionedRPCNetwork net;
    MessageBus mb;

    TestServer(const Identity &ident, const RoutingSpec &spec, const Slobrok &slobrok,
               IProtocol::SP protocol = IProtocol::SP());
    TestServer(const MessageBusParams &mbusParams, const RPCNetworkParams &netParams);
    ~TestServer();

    bool waitSlobrok(const string &pattern, uint32_t cnt = 1);
    bool waitState(const SlobrokState &slobrokState);
};

} // namespace mbus