Commit e7c6b230 authored by Mikel Astiz's avatar Mikel Astiz Committed by Commit Bot

Fix loopback server sending unrequested progress markers

Most if not all sync integration tests output this red-herring and
annoying trace:
"Skipping unexpected progress marker for non-enabled type <type>".

The reason is that, prior to this patch, the loopback server returned
progress markers for all datatypes that the server knows about (i.e. at
least one entity exists).

Instead, let's mimic the real server and return progress markers for
types that have been requested by the client.

Bug: None
Change-Id: I7354c0f38afbd71cf06ab3e7e7c4113f44db6ee2
Reviewed-on: https://chromium-review.googlesource.com/c/1296545
Commit-Queue: Mikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#602295}
parent 8a5181a4
......@@ -78,12 +78,18 @@ class UpdateSieve {
// part of a GetUpdatesResponse. Update internal tracking of max versions as a
// side effect which will later be used to set response progress markers.
bool ClientWantsItem(const LoopbackServerEntity& entity) {
int64_t version = entity.GetVersion();
ModelType type = entity.GetModelType();
// Return only requested datatypes, which makes sure we don't add new
// entries to |response_version_map_|, which would otherwise send
// unnecessary (and unrequested) progress markers in the response.
auto it = request_version_map_.find(type);
if (it == request_version_map_.end())
return false;
DCHECK_NE(0U, request_version_map_.count(type));
int64_t version = entity.GetVersion();
response_version_map_[type] =
std::max(response_version_map_[type], version);
auto it = request_version_map_.find(type);
return it == request_version_map_.end() ? false : it->second < version;
return it->second < version;
}
private:
......
......@@ -159,6 +159,14 @@ TEST_F(LoopbackServerTest, GetUpdateCommand) {
EXPECT_EQ(3, response.get_updates().entries_size());
}
TEST_F(LoopbackServerTest, GetUpdateCommandShouldFilterByDataType) {
ClientToServerResponse response =
GetUpdatesForType(EntitySpecifics::kPreferenceFieldNumber);
// Expect bookmark nodes to be ignored.
EXPECT_EQ(0, response.get_updates().entries_size());
EXPECT_EQ(1, response.get_updates().new_progress_marker_size());
}
TEST_F(LoopbackServerTest, ClearServerDataCommand) {
ClientToServerMessage msg;
SyncerProtoUtil::SetProtocolVersion(&msg);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment