Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCORE-1974 Add tests for role/permissions changed during client reset #7840

Merged
merged 16 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions src/realm/sync/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,71 @@ bool SyncError::is_client_reset_requested() const
return false;
}

std::ostream& operator<<(std::ostream& os, const ClientResyncMode& mode)
{
switch (mode) {
case ClientResyncMode::Manual:
return os << "Manual";
case ClientResyncMode::DiscardLocal:
return os << "DiscardLocal";
case ClientResyncMode::Recover:
return os << "Recover";
case ClientResyncMode::RecoverOrDiscard:
return os << "RecoverOrDiscard";
}
REALM_TERMINATE("Invalid ClientResyncMode value");
}

std::ostream& operator<<(std::ostream& os, const SyncClientHookEvent& event)
michael-wb marked this conversation as resolved.
Show resolved Hide resolved
{
switch (event) {
case SyncClientHookEvent::DownloadMessageReceived:
return os << "DownloadMessageReceived";
case SyncClientHookEvent::DownloadMessageIntegrated:
return os << "DownloadMessageIntegrated";
case SyncClientHookEvent::BootstrapMessageProcessed:
return os << "BootstrapMessageProcessed";
case SyncClientHookEvent::BootstrapProcessed:
return os << "BootstrapProcessed";
case SyncClientHookEvent::ErrorMessageReceived:
return os << "ErrorMessageReceived";
case SyncClientHookEvent::SessionActivating:
return os << "SessionActivating";
case SyncClientHookEvent::SessionSuspended:
return os << "SessionSuspended";
case SyncClientHookEvent::SessionConnected:
return os << "SessionConnected";
case SyncClientHookEvent::SessionResumed:
return os << "SessionResumed";
case SyncClientHookEvent::BindMessageSent:
return os << "BindMessageSent";
case SyncClientHookEvent::IdentMessageSent:
return os << "IdentMessageSent";
case SyncClientHookEvent::ClientResetMergeComplete:
return os << "ClientResetMergeComplete";
case SyncClientHookEvent::BootstrapBatchAboutToProcess:
return os << "BootstrapBatchAboutToProcess";
case SyncClientHookEvent::UploadMessageSent:
return os << "UploadMessageSent";
}
REALM_TERMINATE("Invalid SyncClientHookEvent value");
}

std::ostream& operator<<(std::ostream& os, const SyncClientHookAction& action)
{
switch (action) {
case SyncClientHookAction::NoAction:
return os << "NoAction";
case SyncClientHookAction::EarlyReturn:
return os << "EarlyReturn";
case SyncClientHookAction::SuspendWithRetryableError:
return os << "SuspendWithRetryableError";
case SyncClientHookAction::TriggerReconnect:
return os << "TriggerReconnect";
}
REALM_TERMINATE("Invalid SyncClientHookAction value");
}
michael-wb marked this conversation as resolved.
Show resolved Hide resolved

SyncConfig::SyncConfig(std::shared_ptr<SyncUser> user, bson::Bson partition)
: user(std::move(user))
, partition_value(partition.to_string())
Expand Down
17 changes: 3 additions & 14 deletions src/realm/sync/config.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,9 @@ enum class SyncClientHookAction {
TriggerReconnect,
};

inline std::ostream& operator<<(std::ostream& os, SyncClientHookAction action)
{
switch (action) {
case SyncClientHookAction::NoAction:
return os << "NoAction";
case SyncClientHookAction::EarlyReturn:
return os << "EarlyReturn";
case SyncClientHookAction::SuspendWithRetryableError:
return os << "SuspendWithRetryableError";
case SyncClientHookAction::TriggerReconnect:
return os << "TriggerReconnect";
}
REALM_TERMINATE("Invalid SyncClientHookAction value");
}
std::ostream& operator<<(std::ostream& os, const ClientResyncMode& mode);
std::ostream& operator<<(std::ostream& os, const SyncClientHookEvent& event);
std::ostream& operator<<(std::ostream& os, const SyncClientHookAction& action);

struct SyncClientHookData {
SyncClientHookEvent event;
Expand Down
26 changes: 2 additions & 24 deletions src/realm/sync/noinst/client_reset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,7 @@ using namespace realm;
using namespace _impl;
using namespace sync;

namespace realm {

std::ostream& operator<<(std::ostream& os, const ClientResyncMode& mode)
{
switch (mode) {
case ClientResyncMode::Manual:
os << "Manual";
break;
case ClientResyncMode::DiscardLocal:
os << "DiscardLocal";
break;
case ClientResyncMode::Recover:
os << "Recover";
break;
case ClientResyncMode::RecoverOrDiscard:
os << "RecoverOrDiscard";
break;
}
return os;
}

namespace _impl::client_reset {
namespace realm::_impl::client_reset {

static inline bool should_skip_table(const Transaction& group, TableKey key)
{
Expand Down Expand Up @@ -561,5 +540,4 @@ bool perform_client_reset_diff(DB& db_local, sync::ClientReset& reset_config, ut
return recover_local_changes;
}

} // namespace _impl::client_reset
} // namespace realm
} // namespace realm::_impl::client_reset
3 changes: 0 additions & 3 deletions src/realm/sync/noinst/client_reset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
#include <optional>

namespace realm {

std::ostream& operator<<(std::ostream& os, const ClientResyncMode& mode);

namespace sync {
class SubscriptionStore;

Expand Down
Loading
Loading