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

Function TEST

src/tests/master_validation_tests.cpp:88–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

86
87
88TEST(MasterCallValidationTest, UpdateQuota)
89{
90 Option<Error> error;
91
92 // Test validation at the call level.
93 mesos::master::Call updateQuota;
94 updateQuota.set_type(mesos::master::Call::UPDATE_QUOTA);
95
96 // Missing `update_quota` field.
97 error = master::validation::master::call::validate(updateQuota);
98 EXPECT_SOME(error);
99
100 updateQuota.mutable_update_quota();
101
102 error = master::validation::master::call::validate(updateQuota);
103 EXPECT_NONE(error);
104
105 // Test validation at the config level.
106 mesos::quota::QuotaConfig config;
107
108 error = mesos::internal::master::quota::validate(config);
109 ASSERT_SOME(error);
110 EXPECT_TRUE(
111 strings::contains(error->message, "'QuotaConfig.role' must be set"))
112 << error->message;
113
114 config.set_role("");
115
116 error = mesos::internal::master::quota::validate(config);
117 ASSERT_SOME(error);
118 EXPECT_TRUE(strings::contains(error->message, "Invalid 'QuotaConfig.role'"))
119 << error->message;
120
121 // Once a role is set, it is valid to have no guarantee and no limit.
122 config.set_role("role");
123 error = mesos::internal::master::quota::validate(config);
124 ASSERT_NONE(error);
125
126 // Setting quota on "*" role is allowed.
127 config.set_role("*");
128 error = mesos::internal::master::quota::validate(config);
129 ASSERT_NONE(error);
130
131 auto resourceMap = [](const vector<pair<string, double>>& vector)
132 -> Map<string, Value::Scalar> {
133 Map<string, Value::Scalar> result;
134
135 foreachpair (const string& name, double value, vector) {
136 Value::Scalar scalar;
137 scalar.set_value(value);
138 result[name] = scalar;
139 }
140
141 return result;
142 };
143
144 // The quota endpoint only allows memory / disk up to
145 // 1 exabyte (in megabytes) or 1 trillion cores/ports/other.

Callers

nothing calls this directly

Calls 11

createDiskResourceFunction · 0.85
NoneClass · 0.85
createDiskSourceRawFunction · 0.85
createDiskSourceMountFunction · 0.85
createDiskSourceBlockFunction · 0.85
createDiskSourcePathFunction · 0.85
createPersistentVolumeFunction · 0.85
MegabytesFunction · 0.85
CopyFromMethod · 0.80
validateFunction · 0.50
containsFunction · 0.50

Tested by

no test coverage detected