summaryrefslogtreecommitdiffstats
path: root/src/test/client/commands.cc
blob: c1fe763316e50ca4263d5fc30b6f81a76a5ff9da (plain)
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
#include <errno.h>

#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>

#include <fmt/format.h>

#include "test/client/TestClient.h"


TEST_F(TestClient, SingleTargetMdsCommand) {
    auto mds_spec = "a";
    auto cmd = "{\"prefix\": \"session ls\", \"format\": \"json\"}";
    bufferlist inbl;
    bufferlist outbl;
    std::string outs;
    std::vector<std::string> cmdv;
    C_SaferCond cond;

    cmdv.push_back(cmd);
    int r = client->mds_command(mds_spec, cmdv, inbl, &outbl, &outs, &cond);
    r = cond.wait();

    std::cout << "SingleTargetMdsCommand: " << outbl.c_str() << std::endl;

    ASSERT_TRUE(r == 0 || r == -38);
}

TEST_F(TestClient, MultiTargetMdsCommand) {
    auto mds_spec = "*";
    auto cmd = "{\"prefix\": \"session ls\", \"format\": \"json\"}";
    bufferlist inbl;
    bufferlist outbl;
    std::string outs;
    std::vector<std::string> cmdv;
    C_SaferCond cond;

    cmdv.push_back(cmd);
    std::cout << "MultiTargetMds: " << std::endl;
    int r = client->mds_command(mds_spec, cmdv, inbl, &outbl, &outs, &cond);
    r = cond.wait();

    std::cout << "MultiTargetMdsCommand: " << outbl.c_str() << std::endl;

    ASSERT_TRUE(r == 0 || r == -38);
}