1
- // Copyright 2024 Google LLC
1
+ // Copyright 2025 Google LLC
2
2
//
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
14
14
15
15
#include " tests/gnoi/factory_reset_test.h"
16
16
17
- #include < cstdint>
18
- #include < cstdlib>
19
- #include < map>
20
17
#include < memory>
21
18
#include < string>
22
- #include < utility>
23
- #include < valarray>
24
19
25
- #include " absl/container/flat_hash_set.h"
20
+ #include " absl/status/status.h"
21
+ #include " absl/status/statusor.h"
26
22
#include " absl/strings/numbers.h"
27
- #include " absl/strings/str_cat.h"
28
- #include " absl/strings/string_view.h"
29
23
#include " absl/time/clock.h"
30
24
#include " absl/time/time.h"
25
+ #include " absl/types/span.h"
26
+ #include " factory_reset/factory_reset.pb.h"
31
27
#include " glog/logging.h"
32
28
#include " gmock/gmock.h"
29
+ #include " grpcpp/client_context.h"
30
+ #include " grpcpp/support/status.h"
33
31
#include " gtest/gtest.h"
32
+ #include " gutil/status.h"
34
33
#include " gutil/status_matchers.h"
35
- #include " lib/gnmi/gnmi_helper.h"
36
34
#include " lib/validator/validator_lib.h"
35
+ #include " thinkit/ssh_client.h"
36
+ #include " thinkit/switch.h"
37
37
38
38
namespace factory_reset {
39
+ namespace {
39
40
40
41
// TODO: investigate why shutdown time is increasing and revert
41
42
// to 60s if possible.
@@ -49,7 +50,7 @@ constexpr absl::Duration kSshSessionTimeout = absl::Seconds(5);
49
50
void IssueGnoiFactoryResetAndValidateStatus (
50
51
thinkit::Switch& sut, const gnoi::factory_reset::StartRequest& request,
51
52
gnoi::factory_reset::StartResponse* response,
52
- grpc::Status expected_status) {
53
+ grpc::Status expected_status = {} ) {
53
54
LOG (INFO) << " Issuing factory reset with parameters: "
54
55
<< request.DebugString ();
55
56
ASSERT_OK_AND_ASSIGN (auto sut_gnoi_factory_reset_stub,
@@ -104,6 +105,8 @@ void ValidateStackState(thinkit::Switch& sut,
104
105
<< " System did not come up in " << kFactoryResetWaitForUpTime ;
105
106
}
106
107
108
+ } // namespace
109
+
107
110
void TestFactoryResetSuccess (thinkit::Switch& sut,
108
111
thinkit::SSHClient& ssh_client,
109
112
absl::Span<const std::string> interfaces) {
@@ -142,14 +145,15 @@ void TestGnoiFactoryResetGnoiServerUnreachableFail(
142
145
while (consecutive_unreachable_count < kConsecutivePingsRequired ) {
143
146
if (pins_test::Pingable (sut, kPingTimeout ).ok ()) {
144
147
consecutive_unreachable_count = 0 ;
148
+ LOG (INFO) << " System still reachable" ;
149
+ if (absl::Now () - start > kFactoryResetWaitForDownTime ) {
150
+ FAIL () << " System did not go down in " << kFactoryResetWaitForDownTime ;
151
+ }
145
152
} else {
146
153
consecutive_unreachable_count++;
154
+ LOG (INFO) << " System unreachable for " << consecutive_unreachable_count
155
+ << " consecutive pings" ;
147
156
}
148
- if (absl::Now () - start > kFactoryResetWaitForDownTime ) {
149
- FAIL () << " System did not go down in " << kFactoryResetWaitForDownTime ;
150
- }
151
- LOG (INFO) << " System unreachable for " << consecutive_unreachable_count
152
- << " consecutive pings" ;
153
157
absl::SleepFor (kPingReachabilityInterval );
154
158
}
155
159
LOG (INFO) << " Device became unreachable after: " << absl::Now () - start;
0 commit comments