Skip to content

Commit 6d2592e

Browse files
committed
Adding gnoi test operations files
1 parent cc419f3 commit 6d2592e

File tree

3 files changed

+210
-0
lines changed

3 files changed

+210
-0
lines changed

test/BUILD.bazel

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
2+
load("@rules_proto//proto:defs.bzl", "proto_library")
3+
load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library")
24

35
go_library(
46
name = "test",
@@ -19,3 +21,45 @@ go_test(
1921
"@com_github_golang_protobuf//proto:go_default_library",
2022
],
2123
)
24+
25+
# BlackBoxTest.
26+
proto_library(
27+
name = "blackbox_test_proto",
28+
srcs = ["blackbox_test.proto"],
29+
deps = ["//types:types_proto",
30+
"@go_googleapis//google/rpc:status_proto",
31+
],
32+
)
33+
34+
go_proto_library(
35+
name = "blackbox_test_go_proto",
36+
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
37+
proto = ":blackbox_test_proto",
38+
importpath = "github.com/openconfig/gnoi/test",
39+
deps = ["//types:types_go_proto",
40+
"@go_googleapis//google/rpc:status_go_proto"],
41+
)
42+
43+
cc_proto_library(
44+
name = "blackbox_test_cc_proto",
45+
deps = [":blackbox_test_proto"],
46+
)
47+
48+
# WhiteBoxTest.
49+
proto_library(
50+
name = "whitebox_test_proto",
51+
srcs = ["whitebox_test.proto"],
52+
)
53+
54+
go_proto_library(
55+
name = "whitebox_test_go_proto",
56+
compilers = ["@io_bazel_rules_go//proto:go_grpc"],
57+
proto = ":whitebox_test_proto",
58+
importpath = "github.com/openconfig/gnoi/test",
59+
deps = ["//types:types_go_proto"],
60+
)
61+
62+
cc_proto_library(
63+
name = "whitebox_test_cc_proto",
64+
deps = [":whitebox_test_proto"],
65+
)

test/blackbox_test.proto

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
// BlackBoxTest represents a list of test APIs that facilitates testing the
2+
// switch/network (injecting events, mutating switch state etc.)
3+
4+
syntax = "proto3";
5+
6+
package gnoi.test;
7+
8+
//import "enums/enums.proto";
9+
import "types/types.proto";
10+
import "google/rpc/status.proto";
11+
12+
service BlackBoxTest {
13+
// This RPC allows the state of a transceiver (for both optical, and copper
14+
// cable) to be set on the switch. The goal is to simulate the
15+
// insertion/removal of a transceiver and verify that the switch initializes
16+
// the transceiver correctly. This RPC maps to the `fake` removal of a
17+
// physical module, and un-doing the `fake` removal (i.e., insert). This does
18+
// not implement any fake insertion of a non-present module. The switch
19+
// remembers the state of a transceiver based on this RPC (until reboot).
20+
rpc SetTransceiverState(SetTransceiverStateRequest)
21+
returns (SetTransceiverStateResponse) {}
22+
23+
// This RPC changes the state of the link connected to the specified port(s).
24+
// The goal is to simulate a link going up/down due to factors external to the
25+
// switch: copper cable/fiber removed, cable/fiber gone bad, etc.
26+
rpc SetHardwareLinkState(SetHardwareLinkStateRequest)
27+
returns (SetHardwareLinkStateResponse) {}
28+
29+
// This RPC sets the Alarm state in the switch. The caller is able to set the
30+
// id, resource, description, alarm severity, and type. One goal is to put the
31+
// switch into a critical state to verify that the switch prevents write
32+
// operations to the switch over P4RT/gNMI/gNOI and that the switch continues
33+
// to forward packets and export telemetry.
34+
rpc SetAlarm(SetAlarmRequest) returns (SetAlarmResponse) {}
35+
36+
// Switch performs an internal consistency check. It verifies if the hardware
37+
// contents match with the corresponding software contents. If no component is
38+
// specified, verification runs for all valid components. It performs
39+
// verification on the supplied components otherwise. RPC fails for any
40+
// invalid component.
41+
rpc VerifyState(VerifyStateRequest) returns (VerifyStateResponse);
42+
}
43+
44+
message SetTransceiverStateRequest {
45+
message TransceiverStateRequest {
46+
enum TransceiverState {
47+
STATE_UNSPECIFIED = 0;
48+
REMOVE = 1; // Remove a module.
49+
UNDO_REMOVE = 2; // Undo removal (i.e., insertion) of a module.
50+
}
51+
52+
// Path to the transceiver component.
53+
.gnoi.types.Path transceiver = 1;
54+
TransceiverState state = 2;
55+
}
56+
57+
repeated TransceiverStateRequest transceiver_requests = 1;
58+
}
59+
60+
message SetTransceiverStateResponse {
61+
message TransceiverStateResponse {
62+
// Path to the transceiver component.
63+
.gnoi.types.Path transceiver = 1;
64+
// Status of the operation. In case of failures, canonical error code and
65+
// message show the details.
66+
google.rpc.Status status = 2;
67+
}
68+
69+
repeated TransceiverStateResponse transceiver_responses = 1;
70+
}
71+
72+
message SetHardwareLinkStateRequest {
73+
message HardwareLinkStateInfo {
74+
// Path to the interface.
75+
.gnoi.types.Path interface = 1;
76+
bool enabled = 2;
77+
}
78+
79+
repeated HardwareLinkStateInfo link_requests = 1;
80+
}
81+
82+
message SetHardwareLinkStateResponse {
83+
message SetHardwareLinkStateStatus {
84+
// Path to the interface.
85+
.gnoi.types.Path interface = 1;
86+
// Status of the operation. In case of failures, canonical error code and
87+
// message show the details.
88+
google.rpc.Status status = 2;
89+
}
90+
91+
repeated SetHardwareLinkStateStatus link_responses = 1;
92+
}
93+
94+
message SetAlarmRequest {
95+
// ID associated with the alarm.
96+
string id = 1;
97+
// Resource that raises the alarm. Must be a valid component ID.
98+
string resource = 2;
99+
// Description of the alarm.
100+
string description = 3;
101+
// OPENCONFIG_ALARM_SEVERITY from the OpenConfig system model.
102+
// openconfig.enums.OpenconfigAlarmTypesOPENCONFIGALARMSEVERITY severity = 4;
103+
// OPENCONFIG_ALARM_TYPE_ID from the OpenConfig system model.
104+
// openconfig.enums.OpenconfigAlarmTypesOPENCONFIGALARMTYPEID type = 5;
105+
}
106+
107+
message SetAlarmResponse {}
108+
109+
message VerifyStateRequest {
110+
// Resources that verify states. Must be valid component IDs.
111+
repeated string components = 1;
112+
}
113+
114+
message VerifyStateResponse {
115+
message VerifyStateResult {
116+
string component = 1;
117+
// Status of the operation. In case of failures, canonical error code
118+
// and message show the details.
119+
google.rpc.Status status = 2;
120+
}
121+
122+
// Overall (aggregated) test result. Overall result succeeds if and only
123+
// if the test passes for all components. If it fails for any component,
124+
// the overall result is a failure.
125+
bool success = 1;
126+
repeated VerifyStateResult results = 2;
127+
}

test/whitebox_test.proto

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// WhiteBoxTest represents a list of test APIs that facilitates testing the
2+
// switch/controller (injecting events, mutating switch state etc.)
3+
4+
syntax = "proto3";
5+
6+
package gnoi.gnoi;
7+
8+
service WhiteBoxTest {
9+
// This RPC blocks or permits GNMI and P4RT connections from controller either
10+
// on in band or out of band or on both channels.
11+
// The goal is to simulate controller connection loss in various tests.
12+
rpc SetControllerConnectionState(SetControllerConnectionStateRequest)
13+
returns (SetControllerConnectionStateResponse) {}
14+
}
15+
16+
message SetControllerConnectionStateRequest {
17+
enum State {
18+
UNKNOWN_STATE = 0;
19+
BLOCK = 1; // Block connections to switch.
20+
REMOVE_BLOCK = 2; // Permit connections to switch.
21+
}
22+
23+
enum ConnectionType {
24+
UNKNOWN_TYPE = 0;
25+
ALL_CONNECTIONS = 1; // Both in band and out of band connecions.
26+
IN_BAND = 2; // only in band connections.
27+
OUT_OF_BAND = 3; // only out of band connections.
28+
}
29+
30+
State state = 1;
31+
ConnectionType type = 2;
32+
// Controller ipv4 addresses in prefix format ex: 10.1.1.1/32.
33+
repeated string ipv4_prefix = 3;
34+
35+
// Controller ipv6 addresses in prefix format ex: 1000::1/128.
36+
repeated string ipv6_prefix = 4;
37+
}
38+
39+
message SetControllerConnectionStateResponse {}

0 commit comments

Comments
 (0)