Skip to content

Commit

Permalink
Fix tests on FrameworkInfo update.
Browse files Browse the repository at this point in the history
JIRA: MESOS-4868
  • Loading branch information
Flavien Quesnel committed Apr 29, 2021
1 parent 4fa9564 commit 5a6f2f4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
5 changes: 4 additions & 1 deletion src/master/framework.cpp
Expand Up @@ -507,10 +507,13 @@ void Framework::update(const FrameworkInfo& newInfo)
// TODO(asekretenko): Make it possible to update 'user'
// and 'checkpoint' as per design doc in MESOS-703.
CHECK_EQ(info.principal(), newInfo.principal());
CHECK_EQ(info.user(), newInfo.user());
CHECK_EQ(info.checkpoint(), newInfo.checkpoint());


// Preserve immutable field 'user'
std::string user = info.user();
info.CopyFrom(newInfo);
*info.mutable_user() = user;

// Save the old list of roles for later.
std::set<std::string> oldRoles = roles;
Expand Down
10 changes: 1 addition & 9 deletions src/tests/master/update_framework_tests.cpp
Expand Up @@ -237,22 +237,14 @@ TEST_F(UpdateFrameworkTest, UserChangeFails)
Future<APIResult> result = callUpdateFramework(&mesos, update);

AWAIT_READY(result);
EXPECT_EQ(result->status_code(), 400u);
EXPECT_TRUE(strings::contains(
result->error(), "Updating 'FrameworkInfo.user' is unsupported"));

// Check that no partial update occurred.
Future<v1::master::Response::GetFrameworks> frameworks =
getFrameworks(master->get()->pid);
AWAIT_READY(frameworks);
ASSERT_EQ(frameworks->frameworks_size(), 1);

FrameworkInfo expected = DEFAULT_FRAMEWORK_INFO;
*expected.mutable_id() = subscribed->framework_id();
EXPECT_NONE(diff(frameworks->frameworks(0).framework_info(), expected));

// Sanity check for diff()
EXPECT_SOME(diff(update, expected));
ASSERT_NE(frameworks->frameworks(0).framework_info().user(), update.user());
}


Expand Down
2 changes: 1 addition & 1 deletion src/tests/master_validation_tests.cpp
Expand Up @@ -4786,7 +4786,7 @@ TEST_F(FrameworkInfoValidationTest, ValidateUpdate)
FrameworkInfo frameworkInfo = DEFAULT_FRAMEWORK_INFO;
*frameworkInfo.mutable_user() += "_foo";

EXPECT_SOME(framework::validateUpdate(
EXPECT_NONE(framework::validateUpdate(
DEFAULT_FRAMEWORK_INFO, frameworkInfo));
}

Expand Down

0 comments on commit 5a6f2f4

Please sign in to comment.