From f480c52a170edc1b03657fa1ca504075a70bdfe5 Mon Sep 17 00:00:00 2001 From: rhalstea Date: Wed, 12 May 2021 15:09:01 -0700 Subject: [PATCH 1/2] Added GenericTestbed and Ixia interface, Add AssociateTestCase to TestEnvironment & Added GetDirectory to SSHClient. --- thinkit/BUILD.bazel | 46 ++++++++++++++++++++++ thinkit/generic_testbed.h | 58 ++++++++++++++++++++++++++++ thinkit/mock_generic_testbed.h | 39 +++++++++++++++++++ thinkit/mock_generic_testbed_test.cc | 25 ++++++++++++ thinkit/mock_ssh_client.h | 11 ++++-- thinkit/mock_test_environment.h | 1 + thinkit/ssh_client.h | 20 ++++++---- thinkit/test_environment.h | 3 ++ 8 files changed, 192 insertions(+), 11 deletions(-) create mode 100644 thinkit/generic_testbed.h create mode 100644 thinkit/mock_generic_testbed.h create mode 100644 thinkit/mock_generic_testbed_test.cc diff --git a/thinkit/BUILD.bazel b/thinkit/BUILD.bazel index 0023c859..8c78279b 100644 --- a/thinkit/BUILD.bazel +++ b/thinkit/BUILD.bazel @@ -27,12 +27,24 @@ package( cc_library( name = "thinkit", deps = [ + ":generic_testbed", ":mirror_testbed", ":switch", ":test_environment", ], ) +cc_library( + name = "thinkit_mocks", + testonly = 1, + deps = [ + ":mock_generic_testbed", + ":mock_mirror_testbed", + ":mock_switch", + ":mock_test_environment", + ], +) + cc_library( name = "switch", hdrs = ["switch.h"], @@ -205,6 +217,40 @@ cc_test( ], ) +cc_library( + name = "generic_testbed", + hdrs = ["generic_testbed.h"], + deps = [ + ":switch", + ":test_environment", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + ], +) + +cc_library( + name = "mock_generic_testbed", + testonly = 1, + hdrs = ["mock_generic_testbed.h"], + deps = [ + ":generic_testbed", + ":switch", + ":test_environment", + "@com_google_absl//absl/status:statusor", + "@com_google_absl//absl/strings", + "@com_google_googletest//:gtest", + ], +) + +cc_test( + name = "mock_generic_testbed_test", + srcs = ["mock_generic_testbed_test.cc"], + deps = [ + ":mock_generic_testbed", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "control_interface", hdrs = ["control_interface.h"], diff --git a/thinkit/generic_testbed.h b/thinkit/generic_testbed.h new file mode 100644 index 00000000..37081bf5 --- /dev/null +++ b/thinkit/generic_testbed.h @@ -0,0 +1,58 @@ +// Copyright (c) 2024, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GOOGLE_THINKIT_GENERIC_TESTBED_H_ +#define GOOGLE_THINKIT_GENERIC_TESTBED_H_ + +#include + +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "thinkit/switch.h" +#include "thinkit/test_environment.h" + +namespace thinkit { + +// HttpResponse represents an HTTP response from an Ixia device. +struct HttpResponse { + int response_code; + std::string response; +}; + +enum class RequestType { + kGet, + kPost, + kPut, + kDelete, +}; + +// The GenericTestbed interface represents a testbed with control interface and +// Ixia interface. +class GenericTestbed { + public: + virtual ~GenericTestbed() {} + + // Returns the switch (aka system) under test. + virtual Switch& Sut() = 0; + + // Returns the test environment in which the test is run. + virtual TestEnvironment& Environment() = 0; + + // Sends a REST request to the Ixia and returns the response. + virtual absl::StatusOr SendRestRequestToIxia( + RequestType type, absl::string_view url, absl::string_view payload) = 0; +}; + +} // namespace thinkit +#endif // GOOGLE_THINKIT_GENERIC_TESTBED_H_ diff --git a/thinkit/mock_generic_testbed.h b/thinkit/mock_generic_testbed.h new file mode 100644 index 00000000..3c3000ae --- /dev/null +++ b/thinkit/mock_generic_testbed.h @@ -0,0 +1,39 @@ +// Copyright (c) 2024, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GOOGLE_THINKIT_MOCK_GENERIC_TESTBED_H_ +#define GOOGLE_THINKIT_MOCK_GENERIC_TESTBED_H_ + +#include "absl/status/statusor.h" +#include "absl/strings/string_view.h" +#include "gmock/gmock.h" +#include "thinkit/generic_testbed.h" +#include "thinkit/switch.h" +#include "thinkit/test_environment.h" + +namespace thinkit { + +class MockGenericTestbed : public GenericTestbed { + public: + MOCK_METHOD(Switch&, Sut, (), (override)); + MOCK_METHOD(TestEnvironment&, Environment, (), (override)); + MOCK_METHOD(absl::StatusOr, SendRestRequestToIxia, + (RequestType type, absl::string_view url, + absl::string_view payload), + (override)); +}; + +} // namespace thinkit + +#endif // GOOGLE_THINKIT_MOCK_GENERIC_TESTBED_H_ diff --git a/thinkit/mock_generic_testbed_test.cc b/thinkit/mock_generic_testbed_test.cc new file mode 100644 index 00000000..d84bdf72 --- /dev/null +++ b/thinkit/mock_generic_testbed_test.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2024, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "thinkit/mock_generic_testbed.h" + +#include "gtest/gtest.h" + +namespace thinkit { +namespace { + +TEST(MockGenericTestbed, TestBuild) { MockGenericTestbed mock; } + +} // namespace +} // namespace thinkit diff --git a/thinkit/mock_ssh_client.h b/thinkit/mock_ssh_client.h index d0ee7b28..0ffd55f8 100644 --- a/thinkit/mock_ssh_client.h +++ b/thinkit/mock_ssh_client.h @@ -32,16 +32,19 @@ class MockSSHClient : public SSHClient { (absl::string_view, absl::string_view, absl::Duration), (override)); MOCK_METHOD(absl::Status, PutFile, - (absl::string_view, const RemoteFile&, absl::Duration), + (absl::string_view, const RemotePath&, absl::Duration), (override)); MOCK_METHOD(absl::Status, PutFileContents, - (absl::string_view, const RemoteFile&, absl::Duration), + (absl::string_view, const RemotePath&, absl::Duration), (override)); MOCK_METHOD(absl::Status, GetFile, - (const RemoteFile&, absl::string_view, absl::Duration), + (const RemotePath&, absl::string_view, absl::Duration), (override)); MOCK_METHOD(absl::StatusOr, GetFileContents, - (const RemoteFile&, absl::Duration), (override)); + (const RemotePath&, absl::Duration), (override)); + MOCK_METHOD(absl::Status, GetDirectory, + (const RemotePath&, absl::string_view, absl::Duration), + (override)); }; } // namespace thinkit diff --git a/thinkit/mock_test_environment.h b/thinkit/mock_test_environment.h index c6d0641a..bbfefdfd 100644 --- a/thinkit/mock_test_environment.h +++ b/thinkit/mock_test_environment.h @@ -31,6 +31,7 @@ class MockTestEnvironment : public TestEnvironment { (absl::string_view filename, absl::string_view contents), (override)); MOCK_METHOD(bool, MaskKnownFailures, (), (override)); + MOCK_METHOD(void, SetTestCaseID, (absl::string_view), (override)); }; } // namespace thinkit diff --git a/thinkit/ssh_client.h b/thinkit/ssh_client.h index 27624e3f..ecc0a85e 100644 --- a/thinkit/ssh_client.h +++ b/thinkit/ssh_client.h @@ -24,9 +24,9 @@ namespace thinkit { -// RemoteFile represents a file on a remote device. It is meant to be used as a -// parameter object with designated initializers. -struct RemoteFile { +// RemoteFile represents a file path on a remote device. It is meant to be used +// as a parameter object with designated initializers. +struct RemotePath { absl::string_view device; absl::string_view file_path; }; @@ -48,24 +48,30 @@ class SSHClient { // Copies a local file's contents to a remote destination file, creating a new // file if needed and replacing any existing contents that was there. virtual absl::Status PutFile(absl::string_view source, - const RemoteFile& destination, + const RemotePath& destination, absl::Duration timeout) = 0; // Puts the provided contents into a remote destination file, creating a new // file if needed and replacing any existing contents that was there. virtual absl::Status PutFileContents(absl::string_view contents, - const RemoteFile& destination, + const RemotePath& destination, absl::Duration timeout) = 0; // Copies a remote file's contents to a local file, creating a new // file if needed and replacing any existing contents that was there. - virtual absl::Status GetFile(const RemoteFile& source, + virtual absl::Status GetFile(const RemotePath& source, absl::string_view destination, absl::Duration timeout) = 0; // Returns the contents of a remote file. virtual absl::StatusOr GetFileContents( - const RemoteFile& source, absl::Duration timeout) = 0; + const RemotePath& source, absl::Duration timeout) = 0; + + // Copies a remote directory to a local directory, creating a new directory if + // needed. + virtual absl::Status GetDirectory(const RemotePath& source, + absl::string_view destination, + absl::Duration timeout) = 0; }; } // namespace thinkit diff --git a/thinkit/test_environment.h b/thinkit/test_environment.h index 548efa18..1f3cba08 100644 --- a/thinkit/test_environment.h +++ b/thinkit/test_environment.h @@ -49,6 +49,9 @@ class TestEnvironment { // Should known failures be masked, or should the test fail instead? virtual bool MaskKnownFailures() = 0; + + // Set the `test_case_id` for use by tracking tools. + virtual void SetTestCaseID(absl::string_view test_case_id) {} }; } // namespace thinkit From 95b34f1eb5f59e617859170dc8d7962dcfaee10e Mon Sep 17 00:00:00 2001 From: rhalstea Date: Wed, 2 Jun 2021 10:53:20 -0700 Subject: [PATCH 2/2] Added GenericTestbed and ControlInterface interfaces. --- thinkit/BUILD.bazel | 39 ++++++++++ thinkit/bazel_test_environment.h | 3 +- thinkit/generic_testbed.h | 18 +++++ thinkit/generic_testbed_fixture.h | 101 +++++++++++++++++++++++++ thinkit/mock_control_interface.h | 44 +++++++++++ thinkit/mock_control_interface_test.cc | 25 ++++++ thinkit/mock_generic_testbed.h | 4 + thinkit/proto/BUILD.bazel | 10 +++ thinkit/proto/generic_testbed.proto | 40 ++++++++++ 9 files changed, 283 insertions(+), 1 deletion(-) create mode 100644 thinkit/generic_testbed_fixture.h create mode 100644 thinkit/mock_control_interface.h create mode 100644 thinkit/mock_control_interface_test.cc create mode 100644 thinkit/proto/generic_testbed.proto diff --git a/thinkit/BUILD.bazel b/thinkit/BUILD.bazel index 8c78279b..651aa239 100644 --- a/thinkit/BUILD.bazel +++ b/thinkit/BUILD.bazel @@ -27,6 +27,7 @@ package( cc_library( name = "thinkit", deps = [ + ":control_interface", ":generic_testbed", ":mirror_testbed", ":switch", @@ -38,6 +39,7 @@ cc_library( name = "thinkit_mocks", testonly = 1, deps = [ + ":mock_control_interface", ":mock_generic_testbed", ":mock_mirror_testbed", ":mock_switch", @@ -221,18 +223,33 @@ cc_library( name = "generic_testbed", hdrs = ["generic_testbed.h"], deps = [ + ":control_interface", ":switch", ":test_environment", + "//thinkit/proto:generic_testbed_cc_proto", + "@com_google_absl//absl/container:flat_hash_map", "@com_google_absl//absl/status:statusor", "@com_google_absl//absl/strings", ], ) +cc_library( + name = "generic_testbed_fixture", + testonly = 1, + hdrs = ["generic_testbed_fixture.h"], + deps = [ + ":generic_testbed", + "@com_google_absl//absl/memory", + "@com_google_googletest//:gtest", + ], +) + cc_library( name = "mock_generic_testbed", testonly = 1, hdrs = ["mock_generic_testbed.h"], deps = [ + ":control_interface", ":generic_testbed", ":switch", ":test_environment", @@ -263,6 +280,28 @@ cc_library( ], ) +cc_library( + name = "mock_control_interface", + testonly = 1, + hdrs = ["mock_control_interface.h"], + deps = [ + ":control_interface", + "@com_github_gnoi//diag:diag_cc_grpc_proto", + "@com_google_absl//absl/container:flat_hash_set", + "@com_google_absl//absl/status:statusor", + "@com_google_googletest//:gtest", + ], +) + +cc_test( + name = "mock_control_interface_test", + srcs = ["mock_control_interface_test.cc"], + deps = [ + ":mock_control_interface", + "@com_google_googletest//:gtest_main", + ], +) + cc_library( name = "packet_generation_finalizer", hdrs = ["packet_generation_finalizer.h"], diff --git a/thinkit/bazel_test_environment.h b/thinkit/bazel_test_environment.h index b50b0bd6..b0b788b7 100644 --- a/thinkit/bazel_test_environment.h +++ b/thinkit/bazel_test_environment.h @@ -32,10 +32,11 @@ class BazelTestEnvironment : public TestEnvironment { absl::Status StoreTestArtifact(absl::string_view filename, absl::string_view contents) override; + using TestEnvironment::StoreTestArtifact; // Inherit protobuf overload. absl::Status AppendToTestArtifact(absl::string_view filename, absl::string_view contents) override; - + using TestEnvironment::AppendToTestArtifact; // Inherit protobuf overload. bool MaskKnownFailures() { return mask_known_failures_; }; diff --git a/thinkit/generic_testbed.h b/thinkit/generic_testbed.h index 37081bf5..4f5f7f3d 100644 --- a/thinkit/generic_testbed.h +++ b/thinkit/generic_testbed.h @@ -17,8 +17,11 @@ #include +#include "absl/container/flat_hash_map.h" #include "absl/status/statusor.h" #include "absl/strings/string_view.h" +#include "thinkit/control_interface.h" +#include "thinkit/proto/generic_testbed.pb.h" #include "thinkit/switch.h" #include "thinkit/test_environment.h" @@ -37,6 +40,13 @@ enum class RequestType { kDelete, }; +// InterfaceInfo represents the mode of an interface and the name of the peer +// interface. +struct InterfaceInfo { + third_party::pins_infra::thinkit::InterfaceMode interface_mode; + std::string peer_interface_name; // Empty if not applicable. +}; + // The GenericTestbed interface represents a testbed with control interface and // Ixia interface. class GenericTestbed { @@ -46,9 +56,17 @@ class GenericTestbed { // Returns the switch (aka system) under test. virtual Switch& Sut() = 0; + // Returns the control interface responsible for packet injection and various + // management operations. + virtual ControlInterface& Interface() = 0; + // Returns the test environment in which the test is run. virtual TestEnvironment& Environment() = 0; + // Returns the information for all SUT interfaces. + virtual absl::flat_hash_map + GetSutInterfaceInfo() = 0; + // Sends a REST request to the Ixia and returns the response. virtual absl::StatusOr SendRestRequestToIxia( RequestType type, absl::string_view url, absl::string_view payload) = 0; diff --git a/thinkit/generic_testbed_fixture.h b/thinkit/generic_testbed_fixture.h new file mode 100644 index 00000000..e28b1d2b --- /dev/null +++ b/thinkit/generic_testbed_fixture.h @@ -0,0 +1,101 @@ +// Copyright (c) 2024, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GOOGLE_THINKIT_GENERIC_TESTBED_TEST_FIXTURE_H_ +#define GOOGLE_THINKIT_GENERIC_TESTBED_TEST_FIXTURE_H_ + +#include + +#include "absl/memory/memory.h" +#include "gtest/gtest.h" +#include "thinkit/generic_testbed.h" + +namespace thinkit { + +// The ThinKit `GenericTestbedInterface` defines an interface every test +// platform should implement. The expectations are such that the GenericTestbed +// should only be accessed after SetUp() is called and before TearDown() is +// called. +class GenericTestbedInterface { + public: + virtual ~GenericTestbedInterface() = default; + + virtual void SetUp() = 0; + virtual void TearDown() = 0; + + virtual GenericTestbed& GetGenericTestbed() = 0; +}; + +// The Thinkit `TestParams` defines test parameters to +// `GenericTestbedFixture` class. +struct TestParams { + // Ownership transferred in GenericTestbedFixture class. + GenericTestbedInterface* generic_testbed; + std::string gnmi_config; + absl::optional> port_ids; +}; + +// The ThinKit `GenericTestbedFixture` class acts as a base test fixture for +// platform independent PINS tests. Any platform specific SetUp or TearDown +// requirements are abstracted through the ThinKit GenericTestbedInterface which +// is passed as a parameter. +// +// New PINS tests should extend this fixture, and if needed can extend the +// SetUp() and/or TearDown() methods: +// class MyPinsTest : public thinkit::GenericTestbedFixture { +// void SetUp() override { +// GenericTestbedFixture::SetUp(); // called first. +// +// // custom setup steps ... +// } +// +// void TearDown() override { +// // custom tear down steps ... +// +// GenericTestbedFixture::TearDown(); // called last. +// } +// }; +// +// Individual tests should use the new suite name: +// TEST_P(MyPinsTest, MyTestName) {} +class GenericTestbedFixture : public testing::TestWithParam { + protected: + // A derived class that needs/wants to do its own setup can override this + // method. However, it should take care to call this base setup first. That + // will ensure the platform is ready, and in a healthy state. + void SetUp() override { generic_testbed_interface_->SetUp(); } + + // A derived class that needs/wants to do its own teardown can override this + // method. However, it should take care to call this base teardown last. Once + // this method is called accessing the platform can result in unexpected + // behaviors. + void TearDown() override { generic_testbed_interface_->TearDown(); } + + // Accessor for the Generic testbed. This is only safe to be called after the + // SetUp has completed. + GenericTestbed& GetGenericTestbed() { + return generic_testbed_interface_->GetGenericTestbed(); + } + + std::string GetGnmiConfig() { return GetParam().gnmi_config; } + + private: + // Takes ownership of the GenericTestbedInterface parameter. + std::unique_ptr generic_testbed_interface_ = + absl::WrapUnique(GetParam().generic_testbed); +}; + +} // namespace thinkit + +#endif // GOOGLE_THINKIT_GENERIC_TESTBED_TEST_FIXTURE_H_ diff --git a/thinkit/mock_control_interface.h b/thinkit/mock_control_interface.h new file mode 100644 index 00000000..ba694c97 --- /dev/null +++ b/thinkit/mock_control_interface.h @@ -0,0 +1,44 @@ +// Copyright (c) 2024, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GOOGLE_THINKIT_MOCK_CONTROL_INTERFACE_H_ +#define GOOGLE_THINKIT_MOCK_CONTROL_INTERFACE_H_ + +#include "absl/container/flat_hash_set.h" +#include "absl/status/statusor.h" +#include "diag/diag.grpc.pb.h" +#include "gmock/gmock.h" +#include "thinkit/control_interface.h" + +namespace thinkit { +class MockControlInterface : public ControlInterface { + public: + MOCK_METHOD(absl::Status, SetAdminLinkState, + (absl::Span sut_ports, LinkState state), + (override)); + MOCK_METHOD(absl::Status, Reboot, (RebootType reboot_Type), (override)); + MOCK_METHOD(absl::StatusOr, StartBERT, + (const gnoi::diag::StartBERTRequest& request), (override)); + MOCK_METHOD(absl::StatusOr, StopBERT, + (const gnoi::diag::StopBERTRequest& request), (override)); + MOCK_METHOD(absl::StatusOr, GetBERTResult, + (const gnoi::diag::GetBERTResultRequest& request)); + MOCK_METHOD(absl::StatusOr>, GetUpLinks, + (absl::Span sut_ports), (override)); + MOCK_METHOD(absl::Status, CheckUp, (), (override)); +}; + +} // namespace thinkit + +#endif // GOOGLE_THINKIT_MOCK_CONTROL_INTERFACE_H_ diff --git a/thinkit/mock_control_interface_test.cc b/thinkit/mock_control_interface_test.cc new file mode 100644 index 00000000..a2540d6e --- /dev/null +++ b/thinkit/mock_control_interface_test.cc @@ -0,0 +1,25 @@ +// Copyright (c) 2024, Google Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include "thinkit/mock_control_interface.h" + +#include "gtest/gtest.h" + +namespace thinkit { +namespace { + +TEST(MockControlInterface, TestBuild) { MockControlInterface mock; } + +} // namespace +} // namespace thinkit diff --git a/thinkit/mock_generic_testbed.h b/thinkit/mock_generic_testbed.h index 3c3000ae..ee3ffb47 100644 --- a/thinkit/mock_generic_testbed.h +++ b/thinkit/mock_generic_testbed.h @@ -18,6 +18,7 @@ #include "absl/status/statusor.h" #include "absl/strings/string_view.h" #include "gmock/gmock.h" +#include "thinkit/control_interface.h" #include "thinkit/generic_testbed.h" #include "thinkit/switch.h" #include "thinkit/test_environment.h" @@ -27,7 +28,10 @@ namespace thinkit { class MockGenericTestbed : public GenericTestbed { public: MOCK_METHOD(Switch&, Sut, (), (override)); + MOCK_METHOD(ControlInterface&, Interface, (), (override)); MOCK_METHOD(TestEnvironment&, Environment, (), (override)); + MOCK_METHOD((absl::flat_hash_map), + GetSutInterfaceInfo, (), (override)); MOCK_METHOD(absl::StatusOr, SendRestRequestToIxia, (RequestType type, absl::string_view url, absl::string_view payload), diff --git a/thinkit/proto/BUILD.bazel b/thinkit/proto/BUILD.bazel index 69a77891..7d983d7d 100644 --- a/thinkit/proto/BUILD.bazel +++ b/thinkit/proto/BUILD.bazel @@ -18,6 +18,16 @@ package( licenses = ["notice"], ) +proto_library( + name = "generic_testbed_proto", + srcs = ["generic_testbed.proto"], +) + +cc_proto_library( + name = "generic_testbed_cc_proto", + deps = [":generic_testbed_proto"], +) + proto_library( name = "metrics_proto", srcs = ["metrics.proto"], diff --git a/thinkit/proto/generic_testbed.proto b/thinkit/proto/generic_testbed.proto new file mode 100644 index 00000000..af0db6b8 --- /dev/null +++ b/thinkit/proto/generic_testbed.proto @@ -0,0 +1,40 @@ +// Copyright 2024 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +syntax = "proto3"; + +package third_party.pins_infra.thinkit; + +option cc_generic_services = false; + +// Mode types for the SUT interfaces are connected.. +enum InterfaceMode { + UNKNOWN_MODE = 0; + DISCONNECTED = 1; + LOOPBACK = 2; + CONTROL_INTERFACE = 3; + TRAFFIC_GENERATOR = 4; +} + +// This message represents the mode of interface(s) and the number of +// which are required. +message InterfaceRequirement { + InterfaceMode interface_mode = 1; + int32 count = 2; +} + +// This message represents interface(s) requirement for a test. +message TestRequirements { + repeated InterfaceRequirement interface_requirements = 1; +}