MCPcopy Create free account
hub / github.com/apache/mesos / checkWithGetRequest

Method checkWithGetRequest

src/tests/dynamic_weights_tests.cpp:85–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

83 DynamicWeightsTest() {}
84
85 void checkWithGetRequest(
86 const PID<Master>& master,
87 const Credential& credential,
88 const Option<string>& _weights = None())
89 {
90 Future<Response> response = process::http::request(
91 process::http::createRequest(
92 master,
93 "GET",
94 false,
95 "weights",
96 createBasicAuthHeaders(credential)));
97
98 AWAIT_EXPECT_RESPONSE_STATUS_EQ(OK().status, response);
99 AWAIT_EXPECT_RESPONSE_HEADER_EQ(APPLICATION_JSON, "Content-Type", response);
100
101 Try<JSON::Value> parse = JSON::parse(response->body);
102 ASSERT_SOME(parse);
103
104 // Create Protobuf representation of weights.
105 Try<RepeatedPtrField<WeightInfo>> weightInfos =
106 ::protobuf::parse<RepeatedPtrField<WeightInfo>>(parse.get());
107
108 ASSERT_SOME(weightInfos);
109
110 hashmap<string, double> weights =
111 convertToHashmap(weightInfos.get());
112
113 if (_weights.isNone()) {
114 EXPECT_TRUE(weights.empty());
115 } else if (_weights == GET_WEIGHTS1) {
116 EXPECT_EQ(1u, weights.size());
117 EXPECT_EQ(2.0, weights["role1"]);
118 } else if (_weights == GET_WEIGHTS2) {
119 EXPECT_EQ(1u, weights.size());
120 EXPECT_EQ(4.0, weights["role2"]);
121 } else if (_weights == UPDATED_WEIGHTS1) {
122 EXPECT_EQ(2u, weights.size());
123 EXPECT_EQ(2.0, weights["role1"]);
124 EXPECT_EQ(4.0, weights["role2"]);
125 } else if (_weights == UPDATED_WEIGHTS2) {
126 EXPECT_EQ(3u, weights.size());
127 EXPECT_EQ(1.0, weights["role1"]);
128 EXPECT_EQ(4.0, weights["role2"]);
129 EXPECT_EQ(2.5, weights["role3"]);
130 } else {
131 EXPECT_EQ(_weights.get(), "Unexpected weights string.");
132 }
133 }
134
135protected:
136 const string ROLE1 = "role1";

Callers

nothing calls this directly

Calls 11

NoneClass · 0.85
requestFunction · 0.85
createRequestFunction · 0.85
createBasicAuthHeadersFunction · 0.85
OKClass · 0.85
convertToHashmapFunction · 0.85
parseFunction · 0.50
getMethod · 0.45
isNoneMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected