gfe-relnote: (n/a) In QUIC BBR(v1 and v2) tests, construct the simulator with the test random generator. Test only. PiperOrigin-RevId: 286014228 Change-Id: I44f098781971054fe456b975b1ac2b380ab4b106
diff --git a/quic/core/congestion_control/bbr2_simulator_test.cc b/quic/core/congestion_control/bbr2_simulator_test.cc index 19d68b2..9c34c0b 100644 --- a/quic/core/congestion_control/bbr2_simulator_test.cc +++ b/quic/core/congestion_control/bbr2_simulator_test.cc
@@ -118,7 +118,7 @@ class Bbr2SimulatorTest : public QuicTest { protected: - Bbr2SimulatorTest() { + Bbr2SimulatorTest() : simulator_(&random_) { // Disable Ack Decimation by default, because it can significantly increase // srtt. Individual test can enable it via QuicConnectionPeer::SetAckMode(). SetQuicReloadableFlag(quic_enable_ack_decimation, false); @@ -151,9 +151,9 @@ QuicTime SimulatedNow() const { return simulator_.GetClock()->Now(); } - simulator::Simulator simulator_; uint64_t random_seed_; SimpleRandom random_; + simulator::Simulator simulator_; }; class Bbr2DefaultTopologyTest : public Bbr2SimulatorTest { @@ -170,8 +170,6 @@ Perspective::IS_SERVER, TestConnectionId(42)) { sender_ = SetupBbr2Sender(&sender_endpoint_); - - simulator_.set_random_generator(&random_); } ~Bbr2DefaultTopologyTest() { @@ -819,8 +817,6 @@ std::make_unique<simulator::QuicEndpointMultiplexer>( "Receiver multiplexer", receiver_endpoint_pointers); sender_1_ = SetupBbr2Sender(sender_endpoints_[0].get()); - - simulator_.set_random_generator(&random_); } ~Bbr2MultiSenderTest() {
diff --git a/quic/core/congestion_control/bbr_sender_test.cc b/quic/core/congestion_control/bbr_sender_test.cc index 1f45089..d34d15b 100644 --- a/quic/core/congestion_control/bbr_sender_test.cc +++ b/quic/core/congestion_control/bbr_sender_test.cc
@@ -83,7 +83,7 @@ class BbrSenderTest : public QuicTest { protected: BbrSenderTest() - : simulator_(), + : simulator_(&random_), bbr_sender_(&simulator_, "BBR sender", "Receiver", @@ -110,7 +110,6 @@ sender_ = SetupBbrSender(&bbr_sender_); clock_ = simulator_.GetClock(); - simulator_.set_random_generator(&random_); } void SetUp() override { @@ -137,6 +136,8 @@ } } + uint64_t random_seed_; + SimpleRandom random_; simulator::Simulator simulator_; simulator::QuicEndpoint bbr_sender_; simulator::QuicEndpoint competing_sender_; @@ -148,9 +149,6 @@ std::unique_ptr<simulator::SymmetricLink> competing_sender_link_; std::unique_ptr<simulator::SymmetricLink> receiver_link_; - uint64_t random_seed_; - SimpleRandom random_; - // Owned by different components of the connection. const QuicClock* clock_; const RttStats* rtt_stats_;
diff --git a/quic/test_tools/simulator/simulator.cc b/quic/test_tools/simulator/simulator.cc index fdb59db..61ae9a3 100644 --- a/quic/test_tools/simulator/simulator.cc +++ b/quic/test_tools/simulator/simulator.cc
@@ -10,8 +10,10 @@ namespace quic { namespace simulator { -Simulator::Simulator() - : random_generator_(nullptr), +Simulator::Simulator() : Simulator(nullptr) {} + +Simulator::Simulator(QuicRandom* random_generator) + : random_generator_(random_generator), alarm_factory_(this, "Default Alarm Manager"), run_for_should_stop_(false), enable_random_delays_(false) {
diff --git a/quic/test_tools/simulator/simulator.h b/quic/test_tools/simulator/simulator.h index e21dd50..46f8077 100644 --- a/quic/test_tools/simulator/simulator.h +++ b/quic/test_tools/simulator/simulator.h
@@ -22,6 +22,7 @@ class Simulator : public QuicConnectionHelperInterface { public: Simulator(); + explicit Simulator(QuicRandom* random_generator); Simulator(const Simulator&) = delete; Simulator& operator=(const Simulator&) = delete; ~Simulator() override;