test_retry: Add test-agnostic scenario based on just reason

There are a lot of vm retry scenarios that are repeated for
many many tests.

BUG=chromium:1082764
TEST=./gen

Change-Id: I1772d82ad862d64e83594bd3d1df8202d5a9a34d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/infra/proto/+/2231181
Tested-by: Dhanya Ganesh <dhanyaganesh@chromium.org>
Auto-Submit: Dhanya Ganesh <dhanyaganesh@chromium.org>
Reviewed-by: David Burger <dburger@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
Commit-Queue: Dhanya Ganesh <dhanyaganesh@chromium.org>
diff --git a/go/testplans/test_retry.pb.go b/go/testplans/test_retry.pb.go
index eab3c05..6313337 100644
--- a/go/testplans/test_retry.pb.go
+++ b/go/testplans/test_retry.pb.go
@@ -26,11 +26,13 @@
 	// Tag defines which suite this config set should apply.
 	TestSuite string `protobuf:"bytes,1,opt,name=test_suite,json=testSuite,proto3" json:"test_suite,omitempty"`
 	// Scenarios to retry for each build_target.
-	SuiteScenarios       []*SuiteRetryCfg_Scenario        `protobuf:"bytes,3,rep,name=suite_scenarios,json=suiteScenarios,proto3" json:"suite_scenarios,omitempty"`
-	BuilderScenarios     []*SuiteRetryCfg_BuilderScenario `protobuf:"bytes,4,rep,name=builder_scenarios,json=builderScenarios,proto3" json:"builder_scenarios,omitempty"`
-	XXX_NoUnkeyedLiteral struct{}                         `json:"-"`
-	XXX_unrecognized     []byte                           `json:"-"`
-	XXX_sizecache        int32                            `json:"-"`
+	SuiteScenarios   []*SuiteRetryCfg_Scenario        `protobuf:"bytes,3,rep,name=suite_scenarios,json=suiteScenarios,proto3" json:"suite_scenarios,omitempty"`
+	BuilderScenarios []*SuiteRetryCfg_BuilderScenario `protobuf:"bytes,4,rep,name=builder_scenarios,json=builderScenarios,proto3" json:"builder_scenarios,omitempty"`
+	// ReasonScenarios to retry for the suite.
+	ReasonScenarios      []*SuiteRetryCfg_ReasonScenario `protobuf:"bytes,5,rep,name=reason_scenarios,json=reasonScenarios,proto3" json:"reason_scenarios,omitempty"`
+	XXX_NoUnkeyedLiteral struct{}                        `json:"-"`
+	XXX_unrecognized     []byte                          `json:"-"`
+	XXX_sizecache        int32                           `json:"-"`
 }
 
 func (m *SuiteRetryCfg) Reset()         { *m = SuiteRetryCfg{} }
@@ -79,6 +81,13 @@
 	return nil
 }
 
+func (m *SuiteRetryCfg) GetReasonScenarios() []*SuiteRetryCfg_ReasonScenario {
+	if m != nil {
+		return m.ReasonScenarios
+	}
+	return nil
+}
+
 // Scenario defines the test failure conditions that trigger retry.
 type SuiteRetryCfg_Scenario struct {
 	// Name of the test.
@@ -196,36 +205,99 @@
 	return nil
 }
 
+// Reason scenario defines test failure conditions irrespective of which test.
+type SuiteRetryCfg_ReasonScenario struct {
+	// Failures reason.
+	Reason string `protobuf:"bytes,1,opt,name=reason,proto3" json:"reason,omitempty"`
+	// Verdict of the test run.
+	Verdict test_platform.TaskState_Verdict `protobuf:"varint,2,opt,name=verdict,proto3,enum=test_platform.TaskState_Verdict" json:"verdict,omitempty"`
+	// Should the DUT/VM restart before retry?
+	RequiresRestart      bool     `protobuf:"varint,3,opt,name=requires_restart,json=requiresRestart,proto3" json:"requires_restart,omitempty"`
+	XXX_NoUnkeyedLiteral struct{} `json:"-"`
+	XXX_unrecognized     []byte   `json:"-"`
+	XXX_sizecache        int32    `json:"-"`
+}
+
+func (m *SuiteRetryCfg_ReasonScenario) Reset()         { *m = SuiteRetryCfg_ReasonScenario{} }
+func (m *SuiteRetryCfg_ReasonScenario) String() string { return proto.CompactTextString(m) }
+func (*SuiteRetryCfg_ReasonScenario) ProtoMessage()    {}
+func (*SuiteRetryCfg_ReasonScenario) Descriptor() ([]byte, []int) {
+	return fileDescriptor_5e1b8044c4eb67ff, []int{0, 2}
+}
+
+func (m *SuiteRetryCfg_ReasonScenario) XXX_Unmarshal(b []byte) error {
+	return xxx_messageInfo_SuiteRetryCfg_ReasonScenario.Unmarshal(m, b)
+}
+func (m *SuiteRetryCfg_ReasonScenario) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+	return xxx_messageInfo_SuiteRetryCfg_ReasonScenario.Marshal(b, m, deterministic)
+}
+func (m *SuiteRetryCfg_ReasonScenario) XXX_Merge(src proto.Message) {
+	xxx_messageInfo_SuiteRetryCfg_ReasonScenario.Merge(m, src)
+}
+func (m *SuiteRetryCfg_ReasonScenario) XXX_Size() int {
+	return xxx_messageInfo_SuiteRetryCfg_ReasonScenario.Size(m)
+}
+func (m *SuiteRetryCfg_ReasonScenario) XXX_DiscardUnknown() {
+	xxx_messageInfo_SuiteRetryCfg_ReasonScenario.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SuiteRetryCfg_ReasonScenario proto.InternalMessageInfo
+
+func (m *SuiteRetryCfg_ReasonScenario) GetReason() string {
+	if m != nil {
+		return m.Reason
+	}
+	return ""
+}
+
+func (m *SuiteRetryCfg_ReasonScenario) GetVerdict() test_platform.TaskState_Verdict {
+	if m != nil {
+		return m.Verdict
+	}
+	return test_platform.TaskState_VERDICT_UNSPECIFIED
+}
+
+func (m *SuiteRetryCfg_ReasonScenario) GetRequiresRestart() bool {
+	if m != nil {
+		return m.RequiresRestart
+	}
+	return false
+}
+
 func init() {
 	proto.RegisterType((*SuiteRetryCfg)(nil), "testplans.SuiteRetryCfg")
 	proto.RegisterType((*SuiteRetryCfg_Scenario)(nil), "testplans.SuiteRetryCfg.Scenario")
 	proto.RegisterType((*SuiteRetryCfg_BuilderScenario)(nil), "testplans.SuiteRetryCfg.BuilderScenario")
+	proto.RegisterType((*SuiteRetryCfg_ReasonScenario)(nil), "testplans.SuiteRetryCfg.ReasonScenario")
 }
 
 func init() { proto.RegisterFile("testplans/test_retry.proto", fileDescriptor_5e1b8044c4eb67ff) }
 
 var fileDescriptor_5e1b8044c4eb67ff = []byte{
-	// 351 bytes of a gzipped FileDescriptorProto
-	0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x52, 0xc1, 0x4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c, 0xc9, 0x7b,
+	0x00, 0x00, 0x00, 0xff, 0xff, 0x62, 0x14, 0xfe, 0x25, 0x58, 0x03, 0x00, 0x00,
 }
diff --git a/src/testplans/test_retry.proto b/src/testplans/test_retry.proto
index 458e52f..48efaf4 100644
--- a/src/testplans/test_retry.proto
+++ b/src/testplans/test_retry.proto
@@ -42,4 +42,19 @@
     repeated Scenario scenarios = 2;
   }
   repeated BuilderScenario builder_scenarios = 4;
+
+  // Reason scenario defines test failure conditions irrespective of which test.
+  message ReasonScenario {
+    // Failures reason.
+    string reason = 1;
+
+    // Verdict of the test run.
+    test_platform.TaskState.Verdict verdict = 2;
+
+    // Should the DUT/VM restart before retry?
+    bool requires_restart = 3;
+  }
+
+  // ReasonScenarios to retry for the suite.
+  repeated ReasonScenario reason_scenarios = 5;
 }