1*14675a02SAndroid Build Coastguard Worker /* 2*14675a02SAndroid Build Coastguard Worker * Copyright 2020 Google LLC 3*14675a02SAndroid Build Coastguard Worker * 4*14675a02SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License"); 5*14675a02SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License. 6*14675a02SAndroid Build Coastguard Worker * You may obtain a copy of the License at 7*14675a02SAndroid Build Coastguard Worker * 8*14675a02SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0 9*14675a02SAndroid Build Coastguard Worker * 10*14675a02SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software 11*14675a02SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS, 12*14675a02SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*14675a02SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and 14*14675a02SAndroid Build Coastguard Worker * limitations under the License. 15*14675a02SAndroid Build Coastguard Worker */ 16*14675a02SAndroid Build Coastguard Worker #ifndef FCP_CLIENT_TEST_HELPERS_H_ 17*14675a02SAndroid Build Coastguard Worker #define FCP_CLIENT_TEST_HELPERS_H_ 18*14675a02SAndroid Build Coastguard Worker 19*14675a02SAndroid Build Coastguard Worker #include <functional> 20*14675a02SAndroid Build Coastguard Worker #include <string> 21*14675a02SAndroid Build Coastguard Worker #include <utility> 22*14675a02SAndroid Build Coastguard Worker #include <variant> 23*14675a02SAndroid Build Coastguard Worker #include <vector> 24*14675a02SAndroid Build Coastguard Worker 25*14675a02SAndroid Build Coastguard Worker #include "absl/status/status.h" 26*14675a02SAndroid Build Coastguard Worker #include "absl/status/statusor.h" 27*14675a02SAndroid Build Coastguard Worker #include "fcp/base/monitoring.h" 28*14675a02SAndroid Build Coastguard Worker #include "fcp/client/engine/example_iterator_factory.h" 29*14675a02SAndroid Build Coastguard Worker #include "fcp/client/event_publisher.h" 30*14675a02SAndroid Build Coastguard Worker #include "fcp/client/federated_protocol.h" 31*14675a02SAndroid Build Coastguard Worker #include "fcp/client/federated_select.h" 32*14675a02SAndroid Build Coastguard Worker #include "fcp/client/flags.h" 33*14675a02SAndroid Build Coastguard Worker #include "fcp/client/http/http_client.h" 34*14675a02SAndroid Build Coastguard Worker #include "fcp/client/log_manager.h" 35*14675a02SAndroid Build Coastguard Worker #include "fcp/client/opstats/opstats_db.h" 36*14675a02SAndroid Build Coastguard Worker #include "fcp/client/opstats/opstats_logger.h" 37*14675a02SAndroid Build Coastguard Worker #include "fcp/client/phase_logger.h" 38*14675a02SAndroid Build Coastguard Worker #include "fcp/client/secagg_event_publisher.h" 39*14675a02SAndroid Build Coastguard Worker #include "fcp/client/secagg_runner.h" 40*14675a02SAndroid Build Coastguard Worker #include "fcp/client/simple_task_environment.h" 41*14675a02SAndroid Build Coastguard Worker #include "gmock/gmock.h" 42*14675a02SAndroid Build Coastguard Worker #include "google/protobuf/duration.pb.h" 43*14675a02SAndroid Build Coastguard Worker #include "tensorflow/core/example/example.pb.h" 44*14675a02SAndroid Build Coastguard Worker #include "tensorflow/core/example/feature.pb.h" 45*14675a02SAndroid Build Coastguard Worker 46*14675a02SAndroid Build Coastguard Worker namespace fcp { 47*14675a02SAndroid Build Coastguard Worker namespace client { 48*14675a02SAndroid Build Coastguard Worker 49*14675a02SAndroid Build Coastguard Worker class MockSecAggEventPublisher : public SecAggEventPublisher { 50*14675a02SAndroid Build Coastguard Worker public: 51*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishStateTransition, 52*14675a02SAndroid Build Coastguard Worker (::fcp::secagg::ClientState state, size_t last_sent_message_size, 53*14675a02SAndroid Build Coastguard Worker size_t last_received_message_size), 54*14675a02SAndroid Build Coastguard Worker (override)); 55*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishError, (), (override)); 56*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishAbort, 57*14675a02SAndroid Build Coastguard Worker (bool client_initiated, const std::string& error_message), 58*14675a02SAndroid Build Coastguard Worker (override)); 59*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, set_execution_session_id, (int64_t execution_session_id), 60*14675a02SAndroid Build Coastguard Worker (override)); 61*14675a02SAndroid Build Coastguard Worker }; 62*14675a02SAndroid Build Coastguard Worker 63*14675a02SAndroid Build Coastguard Worker class MockEventPublisher : public EventPublisher { 64*14675a02SAndroid Build Coastguard Worker public: 65*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalCheckin, (), (override)); 66*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalPlanUriReceived, 67*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 68*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 69*14675a02SAndroid Build Coastguard Worker (override)); 70*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalPlanReceived, 71*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 72*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 73*14675a02SAndroid Build Coastguard Worker (override)); 74*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalNotConfigured, 75*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 76*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 77*14675a02SAndroid Build Coastguard Worker (override)); 78*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalRejected, 79*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 80*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 81*14675a02SAndroid Build Coastguard Worker (override)); 82*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckin, (), (override)); 83*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinFinished, 84*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 85*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 86*14675a02SAndroid Build Coastguard Worker (override)); 87*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishRejected, (), (override)); 88*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishReportStarted, (int64_t report_size_bytes), 89*14675a02SAndroid Build Coastguard Worker (override)); 90*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishReportFinished, 91*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 92*14675a02SAndroid Build Coastguard Worker absl::Duration report_duration), 93*14675a02SAndroid Build Coastguard Worker (override)); 94*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishPlanExecutionStarted, (), (override)); 95*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishTensorFlowError, 96*14675a02SAndroid Build Coastguard Worker (int example_count, absl::string_view error_message), (override)); 97*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishIoError, (absl::string_view error_message), 98*14675a02SAndroid Build Coastguard Worker (override)); 99*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishExampleSelectorError, 100*14675a02SAndroid Build Coastguard Worker (int example_count, absl::string_view error_message), (override)); 101*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishInterruption, 102*14675a02SAndroid Build Coastguard Worker (const ExampleStats& example_stats, absl::Time start_time), 103*14675a02SAndroid Build Coastguard Worker (override)); 104*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishPlanCompleted, 105*14675a02SAndroid Build Coastguard Worker (const ExampleStats& example_stats, absl::Time start_time), 106*14675a02SAndroid Build Coastguard Worker (override)); 107*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, SetModelIdentifier, (const std::string& model_identifier), 108*14675a02SAndroid Build Coastguard Worker (override)); 109*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishTaskNotStarted, (absl::string_view error_message), 110*14675a02SAndroid Build Coastguard Worker (override)); 111*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishNonfatalInitializationError, 112*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message), (override)); 113*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishFatalInitializationError, 114*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message), (override)); 115*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalCheckinIoError, 116*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 117*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 118*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 119*14675a02SAndroid Build Coastguard Worker (override)); 120*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalCheckinClientInterrupted, 121*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 122*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 123*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 124*14675a02SAndroid Build Coastguard Worker (override)); 125*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalCheckinServerAborted, 126*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 127*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 128*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 129*14675a02SAndroid Build Coastguard Worker (override)); 130*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalCheckinErrorInvalidPayload, 131*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 132*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 133*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 134*14675a02SAndroid Build Coastguard Worker (override)); 135*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalComputationStarted, (), (override)); 136*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalComputationInvalidArgument, 137*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 138*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 139*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 140*14675a02SAndroid Build Coastguard Worker (override)); 141*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalComputationExampleIteratorError, 142*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 143*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 144*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 145*14675a02SAndroid Build Coastguard Worker (override)); 146*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalComputationTensorflowError, 147*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 148*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 149*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 150*14675a02SAndroid Build Coastguard Worker (override)); 151*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalComputationInterrupted, 152*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 153*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 154*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 155*14675a02SAndroid Build Coastguard Worker (override)); 156*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishEligibilityEvalComputationCompleted, 157*14675a02SAndroid Build Coastguard Worker (const ExampleStats& example_stats, 158*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 159*14675a02SAndroid Build Coastguard Worker (override)); 160*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinIoError, 161*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 162*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 163*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 164*14675a02SAndroid Build Coastguard Worker (override)); 165*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinClientInterrupted, 166*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 167*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 168*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 169*14675a02SAndroid Build Coastguard Worker (override)); 170*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinServerAborted, 171*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 172*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 173*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 174*14675a02SAndroid Build Coastguard Worker (override)); 175*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinInvalidPayload, 176*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 177*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 178*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 179*14675a02SAndroid Build Coastguard Worker (override)); 180*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishRejected, 181*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 182*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 183*14675a02SAndroid Build Coastguard Worker (override)); 184*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinPlanUriReceived, 185*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 186*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 187*14675a02SAndroid Build Coastguard Worker (override)); 188*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishCheckinFinishedV2, 189*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 190*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 191*14675a02SAndroid Build Coastguard Worker (override)); 192*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationStarted, (), (override)); 193*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationInvalidArgument, 194*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 195*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 196*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 197*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 198*14675a02SAndroid Build Coastguard Worker (override)); 199*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationIOError, 200*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 201*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 202*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 203*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 204*14675a02SAndroid Build Coastguard Worker (override)); 205*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationExampleIteratorError, 206*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 207*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 208*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 209*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 210*14675a02SAndroid Build Coastguard Worker (override)); 211*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationTensorflowError, 212*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 213*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 214*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 215*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 216*14675a02SAndroid Build Coastguard Worker (override)); 217*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationInterrupted, 218*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 219*14675a02SAndroid Build Coastguard Worker const ExampleStats& example_stats, 220*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 221*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 222*14675a02SAndroid Build Coastguard Worker (override)); 223*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishComputationCompleted, 224*14675a02SAndroid Build Coastguard Worker (const ExampleStats& example_stats, 225*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 226*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 227*14675a02SAndroid Build Coastguard Worker (override)); 228*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishResultUploadStarted, (), (override)); 229*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishResultUploadIOError, 230*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 231*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 232*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 233*14675a02SAndroid Build Coastguard Worker (override)); 234*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishResultUploadClientInterrupted, 235*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 236*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 237*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 238*14675a02SAndroid Build Coastguard Worker (override)); 239*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishResultUploadServerAborted, 240*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 241*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 242*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 243*14675a02SAndroid Build Coastguard Worker (override)); 244*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishResultUploadCompleted, 245*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 246*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 247*14675a02SAndroid Build Coastguard Worker (override)); 248*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishFailureUploadStarted, (), (override)); 249*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishFailureUploadIOError, 250*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 251*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 252*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 253*14675a02SAndroid Build Coastguard Worker (override)); 254*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishFailureUploadClientInterrupted, 255*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 256*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 257*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 258*14675a02SAndroid Build Coastguard Worker (override)); 259*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishFailureUploadServerAborted, 260*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 261*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 262*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 263*14675a02SAndroid Build Coastguard Worker (override)); 264*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, PublishFailureUploadCompleted, 265*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 266*14675a02SAndroid Build Coastguard Worker absl::Duration phase_duration), 267*14675a02SAndroid Build Coastguard Worker (override)); 268*14675a02SAndroid Build Coastguard Worker secagg_event_publisher()269*14675a02SAndroid Build Coastguard Worker SecAggEventPublisher* secagg_event_publisher() override { 270*14675a02SAndroid Build Coastguard Worker return &secagg_event_publisher_; 271*14675a02SAndroid Build Coastguard Worker } 272*14675a02SAndroid Build Coastguard Worker 273*14675a02SAndroid Build Coastguard Worker private: 274*14675a02SAndroid Build Coastguard Worker ::testing::NiceMock<MockSecAggEventPublisher> secagg_event_publisher_; 275*14675a02SAndroid Build Coastguard Worker }; 276*14675a02SAndroid Build Coastguard Worker 277*14675a02SAndroid Build Coastguard Worker // A mock FederatedProtocol implementation, which keeps track of the stages in 278*14675a02SAndroid Build Coastguard Worker // the protocol and returns a different set of network stats and RetryWindow for 279*14675a02SAndroid Build Coastguard Worker // each stage, making it easier to write accurate assertions in unit tests. 280*14675a02SAndroid Build Coastguard Worker class MockFederatedProtocol : public FederatedProtocol { 281*14675a02SAndroid Build Coastguard Worker public: 282*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats 283*14675a02SAndroid Build Coastguard Worker kPostEligibilityCheckinPlanUriReceivedNetworkStats = { 284*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 280, 285*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 380, 286*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(25)}; 287*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats kPostEligibilityCheckinNetworkStats = { 288*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 300, 289*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 400, 290*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(50)}; 291*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats kPostReportEligibilityEvalErrorNetworkStats = { 292*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 400, 293*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 500, 294*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(150)}; 295*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats kPostCheckinPlanUriReceivedNetworkStats = { 296*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 2970, 297*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 3970, 298*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(225)}; 299*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats kPostCheckinNetworkStats = { 300*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 3000, 301*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 4000, 302*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(250)}; 303*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats kPostReportCompletedNetworkStats = { 304*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 30000, 305*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 40000, 306*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(350)}; 307*14675a02SAndroid Build Coastguard Worker constexpr static NetworkStats kPostReportNotCompletedNetworkStats = { 308*14675a02SAndroid Build Coastguard Worker .bytes_downloaded = 29999, 309*14675a02SAndroid Build Coastguard Worker .bytes_uploaded = 39999, 310*14675a02SAndroid Build Coastguard Worker .network_duration = absl::Milliseconds(450)}; 311*14675a02SAndroid Build Coastguard Worker 312*14675a02SAndroid Build Coastguard Worker static google::internal::federatedml::v2::RetryWindow GetInitialRetryWindow()313*14675a02SAndroid Build Coastguard Worker GetInitialRetryWindow() { 314*14675a02SAndroid Build Coastguard Worker google::internal::federatedml::v2::RetryWindow retry_window; 315*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_min()->set_seconds(0L); 316*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_max()->set_seconds(1L); 317*14675a02SAndroid Build Coastguard Worker *retry_window.mutable_retry_token() = "INITIAL"; 318*14675a02SAndroid Build Coastguard Worker return retry_window; 319*14675a02SAndroid Build Coastguard Worker } 320*14675a02SAndroid Build Coastguard Worker 321*14675a02SAndroid Build Coastguard Worker static google::internal::federatedml::v2::RetryWindow GetPostEligibilityCheckinRetryWindow()322*14675a02SAndroid Build Coastguard Worker GetPostEligibilityCheckinRetryWindow() { 323*14675a02SAndroid Build Coastguard Worker google::internal::federatedml::v2::RetryWindow retry_window; 324*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_min()->set_seconds(100L); 325*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_max()->set_seconds(101L); 326*14675a02SAndroid Build Coastguard Worker *retry_window.mutable_retry_token() = "POST_ELIGIBILITY"; 327*14675a02SAndroid Build Coastguard Worker return retry_window; 328*14675a02SAndroid Build Coastguard Worker } 329*14675a02SAndroid Build Coastguard Worker 330*14675a02SAndroid Build Coastguard Worker static google::internal::federatedml::v2::RetryWindow GetPostCheckinRetryWindow()331*14675a02SAndroid Build Coastguard Worker GetPostCheckinRetryWindow() { 332*14675a02SAndroid Build Coastguard Worker google::internal::federatedml::v2::RetryWindow retry_window; 333*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_min()->set_seconds(200L); 334*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_max()->set_seconds(201L); 335*14675a02SAndroid Build Coastguard Worker *retry_window.mutable_retry_token() = "POST_CHECKIN"; 336*14675a02SAndroid Build Coastguard Worker return retry_window; 337*14675a02SAndroid Build Coastguard Worker } 338*14675a02SAndroid Build Coastguard Worker 339*14675a02SAndroid Build Coastguard Worker static google::internal::federatedml::v2::RetryWindow GetPostReportCompletedRetryWindow()340*14675a02SAndroid Build Coastguard Worker GetPostReportCompletedRetryWindow() { 341*14675a02SAndroid Build Coastguard Worker google::internal::federatedml::v2::RetryWindow retry_window; 342*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_min()->set_seconds(300L); 343*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_max()->set_seconds(301L); 344*14675a02SAndroid Build Coastguard Worker *retry_window.mutable_retry_token() = "POST_REPORT_COMPLETED"; 345*14675a02SAndroid Build Coastguard Worker return retry_window; 346*14675a02SAndroid Build Coastguard Worker } 347*14675a02SAndroid Build Coastguard Worker 348*14675a02SAndroid Build Coastguard Worker static google::internal::federatedml::v2::RetryWindow GetPostReportNotCompletedRetryWindow()349*14675a02SAndroid Build Coastguard Worker GetPostReportNotCompletedRetryWindow() { 350*14675a02SAndroid Build Coastguard Worker google::internal::federatedml::v2::RetryWindow retry_window; 351*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_min()->set_seconds(400L); 352*14675a02SAndroid Build Coastguard Worker retry_window.mutable_delay_max()->set_seconds(401L); 353*14675a02SAndroid Build Coastguard Worker *retry_window.mutable_retry_token() = "POST_REPORT_NOT_COMPLETED"; 354*14675a02SAndroid Build Coastguard Worker return retry_window; 355*14675a02SAndroid Build Coastguard Worker } 356*14675a02SAndroid Build Coastguard Worker MockFederatedProtocol()357*14675a02SAndroid Build Coastguard Worker explicit MockFederatedProtocol() {} 358*14675a02SAndroid Build Coastguard Worker 359*14675a02SAndroid Build Coastguard Worker // We override the real FederatedProtocol methods so that we can intercept the 360*14675a02SAndroid Build Coastguard Worker // progression of protocol stages, and expose dedicate gMock-overridable 361*14675a02SAndroid Build Coastguard Worker // methods for use in tests. EligibilityEvalCheckin(std::function<void (const EligibilityEvalTask &)> payload_uris_received_callback)362*14675a02SAndroid Build Coastguard Worker absl::StatusOr<EligibilityEvalCheckinResult> EligibilityEvalCheckin( 363*14675a02SAndroid Build Coastguard Worker std::function<void(const EligibilityEvalTask&)> 364*14675a02SAndroid Build Coastguard Worker payload_uris_received_callback) final { 365*14675a02SAndroid Build Coastguard Worker absl::StatusOr<EligibilityEvalCheckinResult> result = 366*14675a02SAndroid Build Coastguard Worker MockEligibilityEvalCheckin(); 367*14675a02SAndroid Build Coastguard Worker if (result.ok() && 368*14675a02SAndroid Build Coastguard Worker std::holds_alternative<FederatedProtocol::EligibilityEvalTask>( 369*14675a02SAndroid Build Coastguard Worker *result)) { 370*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostEligibilityCheckinPlanUriReceivedNetworkStats; 371*14675a02SAndroid Build Coastguard Worker payload_uris_received_callback( 372*14675a02SAndroid Build Coastguard Worker std::get<FederatedProtocol::EligibilityEvalTask>(*result)); 373*14675a02SAndroid Build Coastguard Worker } 374*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostEligibilityCheckinNetworkStats; 375*14675a02SAndroid Build Coastguard Worker retry_window_ = GetPostEligibilityCheckinRetryWindow(); 376*14675a02SAndroid Build Coastguard Worker return result; 377*14675a02SAndroid Build Coastguard Worker }; 378*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<EligibilityEvalCheckinResult>, 379*14675a02SAndroid Build Coastguard Worker MockEligibilityEvalCheckin, ()); 380*14675a02SAndroid Build Coastguard Worker ReportEligibilityEvalError(absl::Status error_status)381*14675a02SAndroid Build Coastguard Worker void ReportEligibilityEvalError(absl::Status error_status) final { 382*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostReportEligibilityEvalErrorNetworkStats; 383*14675a02SAndroid Build Coastguard Worker retry_window_ = GetPostEligibilityCheckinRetryWindow(); 384*14675a02SAndroid Build Coastguard Worker MockReportEligibilityEvalError(error_status); 385*14675a02SAndroid Build Coastguard Worker } 386*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, MockReportEligibilityEvalError, 387*14675a02SAndroid Build Coastguard Worker (absl::Status error_status)); 388*14675a02SAndroid Build Coastguard Worker Checkin(const std::optional<::google::internal::federatedml::v2::TaskEligibilityInfo> & task_eligibility_info,std::function<void (const FederatedProtocol::TaskAssignment &)> payload_uris_received_callback)389*14675a02SAndroid Build Coastguard Worker absl::StatusOr<CheckinResult> Checkin( 390*14675a02SAndroid Build Coastguard Worker const std::optional< 391*14675a02SAndroid Build Coastguard Worker ::google::internal::federatedml::v2::TaskEligibilityInfo>& 392*14675a02SAndroid Build Coastguard Worker task_eligibility_info, 393*14675a02SAndroid Build Coastguard Worker std::function<void(const FederatedProtocol::TaskAssignment&)> 394*14675a02SAndroid Build Coastguard Worker payload_uris_received_callback) final { 395*14675a02SAndroid Build Coastguard Worker absl::StatusOr<CheckinResult> result = MockCheckin(task_eligibility_info); 396*14675a02SAndroid Build Coastguard Worker if (result.ok() && 397*14675a02SAndroid Build Coastguard Worker std::holds_alternative<FederatedProtocol::TaskAssignment>(*result)) { 398*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostCheckinPlanUriReceivedNetworkStats; 399*14675a02SAndroid Build Coastguard Worker payload_uris_received_callback( 400*14675a02SAndroid Build Coastguard Worker std::get<FederatedProtocol::TaskAssignment>(*result)); 401*14675a02SAndroid Build Coastguard Worker } 402*14675a02SAndroid Build Coastguard Worker retry_window_ = GetPostCheckinRetryWindow(); 403*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostCheckinNetworkStats; 404*14675a02SAndroid Build Coastguard Worker return result; 405*14675a02SAndroid Build Coastguard Worker }; 406*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<CheckinResult>, MockCheckin, 407*14675a02SAndroid Build Coastguard Worker (const std::optional< 408*14675a02SAndroid Build Coastguard Worker ::google::internal::federatedml::v2::TaskEligibilityInfo>& 409*14675a02SAndroid Build Coastguard Worker task_eligibility_info)); 410*14675a02SAndroid Build Coastguard Worker PerformMultipleTaskAssignments(const std::vector<std::string> & task_names)411*14675a02SAndroid Build Coastguard Worker absl::StatusOr<MultipleTaskAssignments> PerformMultipleTaskAssignments( 412*14675a02SAndroid Build Coastguard Worker const std::vector<std::string>& task_names) final { 413*14675a02SAndroid Build Coastguard Worker absl::StatusOr<MultipleTaskAssignments> result = 414*14675a02SAndroid Build Coastguard Worker MockPerformMultipleTaskAssignments(task_names); 415*14675a02SAndroid Build Coastguard Worker retry_window_ = GetPostCheckinRetryWindow(); 416*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostCheckinPlanUriReceivedNetworkStats; 417*14675a02SAndroid Build Coastguard Worker return result; 418*14675a02SAndroid Build Coastguard Worker }; 419*14675a02SAndroid Build Coastguard Worker 420*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<MultipleTaskAssignments>, 421*14675a02SAndroid Build Coastguard Worker MockPerformMultipleTaskAssignments, 422*14675a02SAndroid Build Coastguard Worker (const std::vector<std::string>& task_names)); 423*14675a02SAndroid Build Coastguard Worker ReportCompleted(ComputationResults results,absl::Duration plan_duration,std::optional<std::string> aggregation_session_id)424*14675a02SAndroid Build Coastguard Worker absl::Status ReportCompleted( 425*14675a02SAndroid Build Coastguard Worker ComputationResults results, absl::Duration plan_duration, 426*14675a02SAndroid Build Coastguard Worker std::optional<std::string> aggregation_session_id) final { 427*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostReportCompletedNetworkStats; 428*14675a02SAndroid Build Coastguard Worker retry_window_ = GetPostReportCompletedRetryWindow(); 429*14675a02SAndroid Build Coastguard Worker return MockReportCompleted(std::move(results), plan_duration, 430*14675a02SAndroid Build Coastguard Worker aggregation_session_id); 431*14675a02SAndroid Build Coastguard Worker }; 432*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, MockReportCompleted, 433*14675a02SAndroid Build Coastguard Worker (ComputationResults results, absl::Duration plan_duration, 434*14675a02SAndroid Build Coastguard Worker std::optional<std::string> aggregation_session_id)); 435*14675a02SAndroid Build Coastguard Worker ReportNotCompleted(engine::PhaseOutcome phase_outcome,absl::Duration plan_duration,std::optional<std::string> aggregation_session_id)436*14675a02SAndroid Build Coastguard Worker absl::Status ReportNotCompleted( 437*14675a02SAndroid Build Coastguard Worker engine::PhaseOutcome phase_outcome, absl::Duration plan_duration, 438*14675a02SAndroid Build Coastguard Worker std::optional<std::string> aggregation_session_id) final { 439*14675a02SAndroid Build Coastguard Worker network_stats_ = kPostReportNotCompletedNetworkStats; 440*14675a02SAndroid Build Coastguard Worker retry_window_ = GetPostReportNotCompletedRetryWindow(); 441*14675a02SAndroid Build Coastguard Worker return MockReportNotCompleted(phase_outcome, plan_duration, 442*14675a02SAndroid Build Coastguard Worker aggregation_session_id); 443*14675a02SAndroid Build Coastguard Worker }; 444*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, MockReportNotCompleted, 445*14675a02SAndroid Build Coastguard Worker (engine::PhaseOutcome phase_outcome, absl::Duration plan_duration, 446*14675a02SAndroid Build Coastguard Worker std::optional<std::string> aggregation_session_id)); 447*14675a02SAndroid Build Coastguard Worker GetLatestRetryWindow()448*14675a02SAndroid Build Coastguard Worker ::google::internal::federatedml::v2::RetryWindow GetLatestRetryWindow() 449*14675a02SAndroid Build Coastguard Worker final { 450*14675a02SAndroid Build Coastguard Worker return retry_window_; 451*14675a02SAndroid Build Coastguard Worker } 452*14675a02SAndroid Build Coastguard Worker GetNetworkStats()453*14675a02SAndroid Build Coastguard Worker NetworkStats GetNetworkStats() final { return network_stats_; } 454*14675a02SAndroid Build Coastguard Worker 455*14675a02SAndroid Build Coastguard Worker private: 456*14675a02SAndroid Build Coastguard Worker NetworkStats network_stats_; 457*14675a02SAndroid Build Coastguard Worker ::google::internal::federatedml::v2::RetryWindow retry_window_ = 458*14675a02SAndroid Build Coastguard Worker GetInitialRetryWindow(); 459*14675a02SAndroid Build Coastguard Worker }; 460*14675a02SAndroid Build Coastguard Worker 461*14675a02SAndroid Build Coastguard Worker class MockLogManager : public LogManager { 462*14675a02SAndroid Build Coastguard Worker public: 463*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogDiag, (ProdDiagCode), (override)); 464*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogDiag, (DebugDiagCode), (override)); 465*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogToLongHistogram, 466*14675a02SAndroid Build Coastguard Worker (fcp::client::HistogramCounters, int, int, 467*14675a02SAndroid Build Coastguard Worker fcp::client::engine::DataSourceType, int64_t), 468*14675a02SAndroid Build Coastguard Worker (override)); 469*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, SetModelIdentifier, (const std::string&), (override)); 470*14675a02SAndroid Build Coastguard Worker }; 471*14675a02SAndroid Build Coastguard Worker 472*14675a02SAndroid Build Coastguard Worker class MockOpStatsLogger : public ::fcp::client::opstats::OpStatsLogger { 473*14675a02SAndroid Build Coastguard Worker public: 474*14675a02SAndroid Build Coastguard Worker MOCK_METHOD( 475*14675a02SAndroid Build Coastguard Worker void, AddEventAndSetTaskName, 476*14675a02SAndroid Build Coastguard Worker (const std::string& task_name, 477*14675a02SAndroid Build Coastguard Worker ::fcp::client::opstats::OperationalStats::Event::EventKind event), 478*14675a02SAndroid Build Coastguard Worker (override)); 479*14675a02SAndroid Build Coastguard Worker MOCK_METHOD( 480*14675a02SAndroid Build Coastguard Worker void, AddEvent, 481*14675a02SAndroid Build Coastguard Worker (::fcp::client::opstats::OperationalStats::Event::EventKind event), 482*14675a02SAndroid Build Coastguard Worker (override)); 483*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, AddEventWithErrorMessage, 484*14675a02SAndroid Build Coastguard Worker (::fcp::client::opstats::OperationalStats::Event::EventKind event, 485*14675a02SAndroid Build Coastguard Worker const std::string& error_message), 486*14675a02SAndroid Build Coastguard Worker (override)); 487*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, UpdateDatasetStats, 488*14675a02SAndroid Build Coastguard Worker (const std::string& collection_uri, int additional_example_count, 489*14675a02SAndroid Build Coastguard Worker int64_t additional_example_size_bytes), 490*14675a02SAndroid Build Coastguard Worker (override)); 491*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, SetNetworkStats, (const NetworkStats& network_stats), 492*14675a02SAndroid Build Coastguard Worker (override)); 493*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, SetRetryWindow, 494*14675a02SAndroid Build Coastguard Worker (google::internal::federatedml::v2::RetryWindow retry_window), 495*14675a02SAndroid Build Coastguard Worker (override)); 496*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(::fcp::client::opstats::OpStatsDb*, GetOpStatsDb, (), (override)); 497*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, IsOpStatsEnabled, (), (const override)); 498*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, CommitToStorage, (), (override)); 499*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::string, GetCurrentTaskName, (), (override)); 500*14675a02SAndroid Build Coastguard Worker }; 501*14675a02SAndroid Build Coastguard Worker 502*14675a02SAndroid Build Coastguard Worker class MockSimpleTaskEnvironment : public SimpleTaskEnvironment { 503*14675a02SAndroid Build Coastguard Worker public: 504*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::string, GetBaseDir, (), (override)); 505*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::string, GetCacheDir, (), (override)); 506*14675a02SAndroid Build Coastguard Worker MOCK_METHOD((absl::StatusOr<std::unique_ptr<ExampleIterator>>), 507*14675a02SAndroid Build Coastguard Worker CreateExampleIterator, 508*14675a02SAndroid Build Coastguard Worker (const google::internal::federated::plan::ExampleSelector& 509*14675a02SAndroid Build Coastguard Worker example_selector), 510*14675a02SAndroid Build Coastguard Worker (override)); 511*14675a02SAndroid Build Coastguard Worker MOCK_METHOD((absl::StatusOr<std::unique_ptr<ExampleIterator>>), 512*14675a02SAndroid Build Coastguard Worker CreateExampleIterator, 513*14675a02SAndroid Build Coastguard Worker (const google::internal::federated::plan::ExampleSelector& 514*14675a02SAndroid Build Coastguard Worker example_selector, 515*14675a02SAndroid Build Coastguard Worker const SelectorContext& selector_context), 516*14675a02SAndroid Build Coastguard Worker (override)); 517*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::unique_ptr<fcp::client::http::HttpClient>, CreateHttpClient, 518*14675a02SAndroid Build Coastguard Worker (), (override)); 519*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, TrainingConditionsSatisfied, (), (override)); 520*14675a02SAndroid Build Coastguard Worker }; 521*14675a02SAndroid Build Coastguard Worker 522*14675a02SAndroid Build Coastguard Worker class MockExampleIterator : public ExampleIterator { 523*14675a02SAndroid Build Coastguard Worker public: 524*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<std::string>, Next, (), (override)); 525*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, Close, (), (override)); 526*14675a02SAndroid Build Coastguard Worker }; 527*14675a02SAndroid Build Coastguard Worker 528*14675a02SAndroid Build Coastguard Worker // An iterator that passes through each example in the dataset once. 529*14675a02SAndroid Build Coastguard Worker class SimpleExampleIterator : public ExampleIterator { 530*14675a02SAndroid Build Coastguard Worker public: 531*14675a02SAndroid Build Coastguard Worker // Uses the given bytes as the examples to return. 532*14675a02SAndroid Build Coastguard Worker explicit SimpleExampleIterator(std::vector<const char*> examples); 533*14675a02SAndroid Build Coastguard Worker // Passes through each of the examples in the `Dataset.client_data.example` 534*14675a02SAndroid Build Coastguard Worker // field. 535*14675a02SAndroid Build Coastguard Worker explicit SimpleExampleIterator( 536*14675a02SAndroid Build Coastguard Worker google::internal::federated::plan::Dataset dataset); 537*14675a02SAndroid Build Coastguard Worker // Passes through each of the examples in the 538*14675a02SAndroid Build Coastguard Worker // `Dataset.client_data.selected_example.example` field, whose example 539*14675a02SAndroid Build Coastguard Worker // collection URI matches the provided `collection_uri`. 540*14675a02SAndroid Build Coastguard Worker SimpleExampleIterator(google::internal::federated::plan::Dataset dataset, 541*14675a02SAndroid Build Coastguard Worker absl::string_view collection_uri); 542*14675a02SAndroid Build Coastguard Worker absl::StatusOr<std::string> Next() override; Close()543*14675a02SAndroid Build Coastguard Worker void Close() override {} 544*14675a02SAndroid Build Coastguard Worker 545*14675a02SAndroid Build Coastguard Worker protected: 546*14675a02SAndroid Build Coastguard Worker std::vector<std::string> examples_; 547*14675a02SAndroid Build Coastguard Worker int index_ = 0; 548*14675a02SAndroid Build Coastguard Worker }; 549*14675a02SAndroid Build Coastguard Worker 550*14675a02SAndroid Build Coastguard Worker struct ComputationArtifacts { 551*14675a02SAndroid Build Coastguard Worker // The path to the file containing the plan data. 552*14675a02SAndroid Build Coastguard Worker std::string plan_filepath; 553*14675a02SAndroid Build Coastguard Worker // The already-parsed plan data. 554*14675a02SAndroid Build Coastguard Worker google::internal::federated::plan::ClientOnlyPlan plan; 555*14675a02SAndroid Build Coastguard Worker // The test dataset. 556*14675a02SAndroid Build Coastguard Worker google::internal::federated::plan::Dataset dataset; 557*14675a02SAndroid Build Coastguard Worker // The path to the file containing the initial checkpoint data (not set for 558*14675a02SAndroid Build Coastguard Worker // local compute task artifacts). 559*14675a02SAndroid Build Coastguard Worker std::string checkpoint_filepath; 560*14675a02SAndroid Build Coastguard Worker // The initial checkpoint data, as a string (not set for local compute task 561*14675a02SAndroid Build Coastguard Worker // artifacts). 562*14675a02SAndroid Build Coastguard Worker std::string checkpoint; 563*14675a02SAndroid Build Coastguard Worker // The Federated Select slice data (not set for local compute task artifacts). 564*14675a02SAndroid Build Coastguard Worker google::internal::federated::plan::SlicesTestDataset federated_select_slices; 565*14675a02SAndroid Build Coastguard Worker }; 566*14675a02SAndroid Build Coastguard Worker 567*14675a02SAndroid Build Coastguard Worker absl::StatusOr<ComputationArtifacts> LoadFlArtifacts(); 568*14675a02SAndroid Build Coastguard Worker 569*14675a02SAndroid Build Coastguard Worker class MockFlags : public Flags { 570*14675a02SAndroid Build Coastguard Worker public: 571*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, condition_polling_period_millis, (), (const, override)); 572*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, tf_execution_teardown_grace_period_millis, (), 573*14675a02SAndroid Build Coastguard Worker (const, override)); 574*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, tf_execution_teardown_extended_period_millis, (), 575*14675a02SAndroid Build Coastguard Worker (const, override)); 576*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, grpc_channel_deadline_seconds, (), (const, override)); 577*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, log_tensorflow_error_messages, (), (const, override)); 578*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, enable_opstats, (), (const, override)); 579*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, opstats_ttl_days, (), (const, override)); 580*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, opstats_db_size_limit_bytes, (), (const, override)); 581*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, federated_training_transient_errors_retry_delay_secs, (), 582*14675a02SAndroid Build Coastguard Worker (const, override)); 583*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(float, 584*14675a02SAndroid Build Coastguard Worker federated_training_transient_errors_retry_delay_jitter_percent, 585*14675a02SAndroid Build Coastguard Worker (), (const, override)); 586*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int64_t, federated_training_permanent_errors_retry_delay_secs, (), 587*14675a02SAndroid Build Coastguard Worker (const, override)); 588*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(float, 589*14675a02SAndroid Build Coastguard Worker federated_training_permanent_errors_retry_delay_jitter_percent, 590*14675a02SAndroid Build Coastguard Worker (), (const, override)); 591*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::vector<int32_t>, federated_training_permanent_error_codes, 592*14675a02SAndroid Build Coastguard Worker (), (const, override)); 593*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, use_tflite_training, (), (const, override)); 594*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, enable_grpc_with_http_resource_support, (), 595*14675a02SAndroid Build Coastguard Worker (const, override)); 596*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, enable_grpc_with_eligibility_eval_http_resource_support, (), 597*14675a02SAndroid Build Coastguard Worker (const, override)); 598*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, ensure_dynamic_tensors_are_released, (), (const, override)); 599*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int32_t, large_tensor_threshold_for_dynamic_allocation, (), 600*14675a02SAndroid Build Coastguard Worker (const, override)); 601*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, disable_http_request_body_compression, (), 602*14675a02SAndroid Build Coastguard Worker (const, override)); 603*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, use_http_federated_compute_protocol, (), (const, override)); 604*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, enable_computation_id, (), (const, override)); 605*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int32_t, waiting_period_sec_for_cancellation, (), 606*14675a02SAndroid Build Coastguard Worker (const, override)); 607*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, enable_federated_select, (), (const, override)); 608*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(int32_t, num_threads_for_tflite, (), (const, override)); 609*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, disable_tflite_delegate_clustering, (), (const, override)); 610*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, enable_example_query_plan_engine, (), (const, override)); 611*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, support_constant_tf_inputs, (), (const, override)); 612*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(bool, http_protocol_supports_multiple_task_assignments, (), 613*14675a02SAndroid Build Coastguard Worker (const, override)); 614*14675a02SAndroid Build Coastguard Worker }; 615*14675a02SAndroid Build Coastguard Worker 616*14675a02SAndroid Build Coastguard Worker // Helper methods for extracting opstats fields from TF examples. 617*14675a02SAndroid Build Coastguard Worker std::string ExtractSingleString(const tensorflow::Example& example, 618*14675a02SAndroid Build Coastguard Worker const char key[]); 619*14675a02SAndroid Build Coastguard Worker google::protobuf::RepeatedPtrField<std::string> ExtractRepeatedString( 620*14675a02SAndroid Build Coastguard Worker const tensorflow::Example& example, const char key[]); 621*14675a02SAndroid Build Coastguard Worker int64_t ExtractSingleInt64(const tensorflow::Example& example, 622*14675a02SAndroid Build Coastguard Worker const char key[]); 623*14675a02SAndroid Build Coastguard Worker google::protobuf::RepeatedField<int64_t> ExtractRepeatedInt64( 624*14675a02SAndroid Build Coastguard Worker const tensorflow::Example& example, const char key[]); 625*14675a02SAndroid Build Coastguard Worker 626*14675a02SAndroid Build Coastguard Worker class MockOpStatsDb : public ::fcp::client::opstats::OpStatsDb { 627*14675a02SAndroid Build Coastguard Worker public: 628*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<::fcp::client::opstats::OpStatsSequence>, Read, (), 629*14675a02SAndroid Build Coastguard Worker (override)); 630*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, Transform, 631*14675a02SAndroid Build Coastguard Worker (std::function<void(::fcp::client::opstats::OpStatsSequence&)>), 632*14675a02SAndroid Build Coastguard Worker (override)); 633*14675a02SAndroid Build Coastguard Worker }; 634*14675a02SAndroid Build Coastguard Worker 635*14675a02SAndroid Build Coastguard Worker class MockPhaseLogger : public PhaseLogger { 636*14675a02SAndroid Build Coastguard Worker public: 637*14675a02SAndroid Build Coastguard Worker MOCK_METHOD( 638*14675a02SAndroid Build Coastguard Worker void, UpdateRetryWindowAndNetworkStats, 639*14675a02SAndroid Build Coastguard Worker (const ::google::internal::federatedml::v2::RetryWindow& retry_window, 640*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats), 641*14675a02SAndroid Build Coastguard Worker (override)); 642*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, SetModelIdentifier, (absl::string_view model_identifier), 643*14675a02SAndroid Build Coastguard Worker (override)); 644*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogTaskNotStarted, (absl::string_view error_message), 645*14675a02SAndroid Build Coastguard Worker (override)); 646*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogNonfatalInitializationError, (absl::Status error_status), 647*14675a02SAndroid Build Coastguard Worker (override)); 648*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogFatalInitializationError, (absl::Status error_status), 649*14675a02SAndroid Build Coastguard Worker (override)); 650*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinStarted, (), (override)); 651*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinIOError, 652*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 653*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 654*14675a02SAndroid Build Coastguard Worker (override)); 655*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinInvalidPayloadError, 656*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 657*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 658*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 659*14675a02SAndroid Build Coastguard Worker (override)); 660*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinClientInterrupted, 661*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 662*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 663*14675a02SAndroid Build Coastguard Worker (override)); 664*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinServerAborted, 665*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 666*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 667*14675a02SAndroid Build Coastguard Worker (override)); 668*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalNotConfigured, 669*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 670*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 671*14675a02SAndroid Build Coastguard Worker (override)); 672*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinTurnedAway, 673*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 674*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 675*14675a02SAndroid Build Coastguard Worker (override)); 676*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinPlanUriReceived, 677*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 678*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 679*14675a02SAndroid Build Coastguard Worker (override)); 680*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalCheckinCompleted, 681*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 682*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, 683*14675a02SAndroid Build Coastguard Worker absl::Time time_before_plan_download), 684*14675a02SAndroid Build Coastguard Worker (override)); 685*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalComputationStarted, (), (override)); 686*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalComputationInvalidArgument, 687*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 688*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time), 689*14675a02SAndroid Build Coastguard Worker (override)); 690*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalComputationExampleIteratorError, 691*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 692*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time), 693*14675a02SAndroid Build Coastguard Worker (override)); 694*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalComputationTensorflowError, 695*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 696*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time, absl::Time reference_time), 697*14675a02SAndroid Build Coastguard Worker (override)); 698*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalComputationInterrupted, 699*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 700*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time, absl::Time reference_time), 701*14675a02SAndroid Build Coastguard Worker (override)); 702*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogEligibilityEvalComputationCompleted, 703*14675a02SAndroid Build Coastguard Worker (const ExampleStats& example_stats, 704*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time, absl::Time reference_time), 705*14675a02SAndroid Build Coastguard Worker (override)); 706*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinStarted, (), (override)); 707*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinIOError, 708*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 709*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, absl::Time reference_time), 710*14675a02SAndroid Build Coastguard Worker (override)); 711*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinInvalidPayload, 712*14675a02SAndroid Build Coastguard Worker (absl::string_view error_message, 713*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 714*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, absl::Time reference_time), 715*14675a02SAndroid Build Coastguard Worker (override)); 716*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinClientInterrupted, 717*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 718*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, absl::Time reference_time), 719*14675a02SAndroid Build Coastguard Worker (override)); 720*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinServerAborted, 721*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 722*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, absl::Time reference_time), 723*14675a02SAndroid Build Coastguard Worker (override)); 724*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinTurnedAway, 725*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 726*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, absl::Time reference_time), 727*14675a02SAndroid Build Coastguard Worker (override)); 728*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinPlanUriReceived, 729*14675a02SAndroid Build Coastguard Worker (absl::string_view task_name, const NetworkStats& network_stats, 730*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin), 731*14675a02SAndroid Build Coastguard Worker (override)); 732*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogCheckinCompleted, 733*14675a02SAndroid Build Coastguard Worker (absl::string_view task_name, const NetworkStats& network_stats, 734*14675a02SAndroid Build Coastguard Worker absl::Time time_before_checkin, 735*14675a02SAndroid Build Coastguard Worker absl::Time time_before_plan_download, absl::Time reference_time), 736*14675a02SAndroid Build Coastguard Worker (override)); 737*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationStarted, (), (override)); 738*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationInvalidArgument, 739*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 740*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 741*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time), 742*14675a02SAndroid Build Coastguard Worker (override)); 743*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationExampleIteratorError, 744*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 745*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 746*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time), 747*14675a02SAndroid Build Coastguard Worker (override)); 748*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationIOError, 749*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 750*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 751*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time), 752*14675a02SAndroid Build Coastguard Worker (override)); 753*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationTensorflowError, 754*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 755*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 756*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time, absl::Time reference_time), 757*14675a02SAndroid Build Coastguard Worker (override)); 758*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationInterrupted, 759*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const ExampleStats& example_stats, 760*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 761*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time, absl::Time reference_time), 762*14675a02SAndroid Build Coastguard Worker (override)); 763*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogComputationCompleted, 764*14675a02SAndroid Build Coastguard Worker (const ExampleStats& example_stats, 765*14675a02SAndroid Build Coastguard Worker const NetworkStats& network_stats, 766*14675a02SAndroid Build Coastguard Worker absl::Time run_plan_start_time, absl::Time reference_time), 767*14675a02SAndroid Build Coastguard Worker (override)); 768*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, LogResultUploadStarted, (), (override)); 769*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogResultUploadIOError, 770*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 771*14675a02SAndroid Build Coastguard Worker absl::Time time_before_result_upload, absl::Time reference_time), 772*14675a02SAndroid Build Coastguard Worker (override)); 773*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogResultUploadClientInterrupted, 774*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 775*14675a02SAndroid Build Coastguard Worker absl::Time time_before_result_upload, absl::Time reference_time), 776*14675a02SAndroid Build Coastguard Worker (override)); 777*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogResultUploadServerAborted, 778*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 779*14675a02SAndroid Build Coastguard Worker absl::Time time_before_result_upload, absl::Time reference_time), 780*14675a02SAndroid Build Coastguard Worker (override)); 781*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogResultUploadCompleted, 782*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 783*14675a02SAndroid Build Coastguard Worker absl::Time time_before_result_upload, absl::Time reference_time), 784*14675a02SAndroid Build Coastguard Worker (override)); 785*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, LogFailureUploadStarted, (), (override)); 786*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogFailureUploadIOError, 787*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 788*14675a02SAndroid Build Coastguard Worker absl::Time time_before_failure_upload, 789*14675a02SAndroid Build Coastguard Worker absl::Time reference_time), 790*14675a02SAndroid Build Coastguard Worker (override)); 791*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogFailureUploadClientInterrupted, 792*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 793*14675a02SAndroid Build Coastguard Worker absl::Time time_before_failure_upload, 794*14675a02SAndroid Build Coastguard Worker absl::Time reference_time), 795*14675a02SAndroid Build Coastguard Worker (override)); 796*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogFailureUploadServerAborted, 797*14675a02SAndroid Build Coastguard Worker (absl::Status error_status, const NetworkStats& network_stats, 798*14675a02SAndroid Build Coastguard Worker absl::Time time_before_failure_upload, 799*14675a02SAndroid Build Coastguard Worker absl::Time reference_time), 800*14675a02SAndroid Build Coastguard Worker (override)); 801*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, LogFailureUploadCompleted, 802*14675a02SAndroid Build Coastguard Worker (const NetworkStats& network_stats, 803*14675a02SAndroid Build Coastguard Worker absl::Time time_before_result_upload, absl::Time reference_time), 804*14675a02SAndroid Build Coastguard Worker (override)); 805*14675a02SAndroid Build Coastguard Worker }; 806*14675a02SAndroid Build Coastguard Worker 807*14675a02SAndroid Build Coastguard Worker class MockFederatedSelectManager : public FederatedSelectManager { 808*14675a02SAndroid Build Coastguard Worker public: 809*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::unique_ptr<engine::ExampleIteratorFactory>, 810*14675a02SAndroid Build Coastguard Worker CreateExampleIteratorFactoryForUriTemplate, 811*14675a02SAndroid Build Coastguard Worker (absl::string_view uri_template), (override)); 812*14675a02SAndroid Build Coastguard Worker 813*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(NetworkStats, GetNetworkStats, (), (override)); 814*14675a02SAndroid Build Coastguard Worker }; 815*14675a02SAndroid Build Coastguard Worker 816*14675a02SAndroid Build Coastguard Worker class MockFederatedSelectExampleIteratorFactory 817*14675a02SAndroid Build Coastguard Worker : public FederatedSelectExampleIteratorFactory { 818*14675a02SAndroid Build Coastguard Worker public: 819*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<std::unique_ptr<ExampleIterator>>, 820*14675a02SAndroid Build Coastguard Worker CreateExampleIterator, 821*14675a02SAndroid Build Coastguard Worker (const ::google::internal::federated::plan::ExampleSelector& 822*14675a02SAndroid Build Coastguard Worker example_selector), 823*14675a02SAndroid Build Coastguard Worker (override)); 824*14675a02SAndroid Build Coastguard Worker }; 825*14675a02SAndroid Build Coastguard Worker 826*14675a02SAndroid Build Coastguard Worker class MockSecAggRunnerFactory : public SecAggRunnerFactory { 827*14675a02SAndroid Build Coastguard Worker public: 828*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(std::unique_ptr<SecAggRunner>, CreateSecAggRunner, 829*14675a02SAndroid Build Coastguard Worker (std::unique_ptr<SecAggSendToServerBase> send_to_server_impl, 830*14675a02SAndroid Build Coastguard Worker std::unique_ptr<SecAggProtocolDelegate> protocol_delegate, 831*14675a02SAndroid Build Coastguard Worker SecAggEventPublisher* secagg_event_publisher, 832*14675a02SAndroid Build Coastguard Worker LogManager* log_manager, 833*14675a02SAndroid Build Coastguard Worker InterruptibleRunner* interruptible_runner, 834*14675a02SAndroid Build Coastguard Worker int64_t expected_number_of_clients, 835*14675a02SAndroid Build Coastguard Worker int64_t minimum_surviving_clients_for_reconstruction), 836*14675a02SAndroid Build Coastguard Worker (override)); 837*14675a02SAndroid Build Coastguard Worker }; 838*14675a02SAndroid Build Coastguard Worker 839*14675a02SAndroid Build Coastguard Worker class MockSecAggRunner : public SecAggRunner { 840*14675a02SAndroid Build Coastguard Worker public: 841*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::Status, Run, (ComputationResults results), (override)); 842*14675a02SAndroid Build Coastguard Worker }; 843*14675a02SAndroid Build Coastguard Worker 844*14675a02SAndroid Build Coastguard Worker class MockSecAggSendToServerBase : public SecAggSendToServerBase { 845*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, Send, (secagg::ClientToServerWrapperMessage * message), 846*14675a02SAndroid Build Coastguard Worker (override)); 847*14675a02SAndroid Build Coastguard Worker }; 848*14675a02SAndroid Build Coastguard Worker 849*14675a02SAndroid Build Coastguard Worker class MockSecAggProtocolDelegate : public SecAggProtocolDelegate { 850*14675a02SAndroid Build Coastguard Worker public: 851*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<uint64_t>, GetModulus, (const std::string& key), 852*14675a02SAndroid Build Coastguard Worker (override)); 853*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(absl::StatusOr<secagg::ServerToClientWrapperMessage>, 854*14675a02SAndroid Build Coastguard Worker ReceiveServerMessage, (), (override)); 855*14675a02SAndroid Build Coastguard Worker MOCK_METHOD(void, Abort, (), (override)); 856*14675a02SAndroid Build Coastguard Worker }; 857*14675a02SAndroid Build Coastguard Worker 858*14675a02SAndroid Build Coastguard Worker } // namespace client 859*14675a02SAndroid Build Coastguard Worker } // namespace fcp 860*14675a02SAndroid Build Coastguard Worker 861*14675a02SAndroid Build Coastguard Worker #endif // FCP_CLIENT_TEST_HELPERS_H_ 862