Skip to content

Commit

Permalink
CBL-6289: Re-enable Actions Replication tests (#2190)
Browse files Browse the repository at this point in the history
  • Loading branch information
callumbirks authored Dec 18, 2024
1 parent a79ab49 commit 27d3530
Show file tree
Hide file tree
Showing 12 changed files with 173 additions and 712 deletions.
1 change: 1 addition & 0 deletions C/include/c4Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ CBL_CORE_API C4SliceResult c4doc_getRevisionHistory(C4Document* doc, unsigned ma
CBL_CORE_API C4SliceResult c4doc_getSelectedRevIDGlobalForm(C4Document* doc) C4API;

/** Selects the parent of the selected revision, if it's known, else returns false.
* Throws if the document is a version-vectors document.
\note The caller must use a lock for Document when this function is called. */
NODISCARD CBL_CORE_API bool c4doc_selectParentRevision(C4Document* doc) C4API;

Expand Down
14 changes: 14 additions & 0 deletions Replicator/Replicator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,20 @@ namespace litecore::repl {
"Incompatible replication protocol "
"(missing 'Sec-WebSocket-Protocol' response header)"_sl));
}

const auto& compats = repl::kCompatProtocols;

string acceptedProtocol;
stringstream s(headers["Sec-WebSocket-Protocol"].asString());
string protocol;
while ( getline(s, protocol, ',') ) {
auto i = std::find(compats.begin(), compats.end(), protocol);
if ( i != compats.end() ) {
acceptedProtocol = protocol;
break;
}
}

if ( _delegate ) _delegate->replicatorGotHTTPResponse(this, status, headers);
if ( slice x_corr = headers.get("X-Correlation-Id"_sl); x_corr ) {
_correlationID = x_corr;
Expand Down
3 changes: 2 additions & 1 deletion Replicator/tests/ReplParams.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//

#include "ReplParams.hh"
#include <cstdint>

ReplParams::ReplParams(const std::vector<C4ReplicationCollection>& collections_) : C4ReplicatorParameters() {
_collectionVector = {collections_};
Expand Down Expand Up @@ -70,7 +71,7 @@ ReplParams& ReplParams::setCollectionOptions(C4CollectionSpec collectionSpec, co
return *this;
}

ReplParams& ReplParams::setDocIDs(const std::vector<std::unordered_map<alloc_slice, unsigned>>& docIDs) {
ReplParams& ReplParams::setDocIDs(const std::vector<std::unordered_map<alloc_slice, uint64_t>>& docIDs) {
for ( size_t i = 0; i < docIDs.size(); ++i ) {
fleece::Encoder enc;
enc.beginArray();
Expand Down
5 changes: 3 additions & 2 deletions Replicator/tests/ReplParams.hh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "fleece/Expert.hh"
#include "c4ReplicatorTypes.h"
#include "ReplicatorOptions.hh"
#include <cstdint>
#include <vector>
#include <unordered_map>

Expand Down Expand Up @@ -57,11 +58,11 @@ class ReplParams : public C4ReplicatorParameters {
// Set an option for all collections
ReplParams& setCollectionOptions(const AllocedDict& options);
// Set docIDs in options of each collection
ReplParams& setDocIDs(const std::vector<std::unordered_map<alloc_slice, unsigned>>& docIDs);
ReplParams& setDocIDs(const std::vector<std::unordered_map<alloc_slice, uint64_t>>& docIDs);

// Same as above, with array parameter
template <size_t N>
ReplParams& setDocIDs(const std::array<std::unordered_map<alloc_slice, unsigned>, N>& docIDs) {
ReplParams& setDocIDs(const std::array<std::unordered_map<alloc_slice, uint64_t>, N>& docIDs) {
return setDocIDs({docIDs.begin(), docIDs.end()});
}

Expand Down
4 changes: 3 additions & 1 deletion Replicator/tests/ReplicatorAPITest.hh
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ class ReplicatorAPITest : public C4Test {

static std::once_flag once;

ReplicatorAPITest() : C4Test(0), _sg({kDefaultAddress, kScratchDBName}) {
ReplicatorAPITest() : ReplicatorAPITest(0) {}

explicit ReplicatorAPITest(int option) : C4Test(option), _sg({kDefaultAddress, kScratchDBName}) {
std::call_once(once, [&]() {
// Register the BuiltInWebSocket class as the C4Replicator's WebSocketImpl.
C4RegisterBuiltInWebSocket();
Expand Down
Loading

0 comments on commit 27d3530

Please sign in to comment.