Ejemplo n.º 1
0
 NetworkInterfaceMock::NetworkInterfaceMock(CommandProcessorFn fn)  :
                 _simulatedNetworkLatencyMillis(0),
                 _helper(fn) {
     StatusWith<Date_t> initialNow = dateFromISOString("2014-08-01T00:00:00Z");
     fassert(18655, initialNow.getStatus());
     _now = initialNow.getValue();
 }
Ejemplo n.º 2
0
NetworkInterfaceMock::NetworkInterfaceMock()
    : _waitingToRunMask(0),
      _currentlyRunning(kNoThread),
      _now(fassertStatusOK(18653, dateFromISOString("2014-08-01T00:00:00Z"))),
      _hasStarted(false),
      _inShutdown(false),
      _executorNextWakeupDate(Date_t::max()) {}
                upsert: true,
                writeConcern: { w: "majority", j: true, wtimeout: 100 }
            })"));

            ASSERT_EQUALS(expectedCmd, request.cmdObj);
        },
        RemoteCommandResponse(fromjson(R"({
                ok: 1,
                value: {
                    _id: "abcd",
                    ping: { $date: "2014-03-11T09:17:18.098Z" }
                }
            })"),
                              Milliseconds(0)));

    Date_t ping(dateFromISOString("2014-03-11T09:17:18.098Z").getValue());
    auto status = catalog.ping("abcd", ping);
    ASSERT_OK(status);
}

TEST(DistLockCatalogImpl, PingTargetError) {
    RemoteCommandTargeterMock targeter;
    RemoteCommandRunnerMock executor;

    targeter.setFindHostReturnValue({ErrorCodes::InternalError, "can't target"});

    DistLockCatalogImpl catalog(&targeter, &executor, kWTimeout);

    auto status = catalog.ping("abcd", Date_t::now());
    ASSERT_NOT_OK(status);
}