-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Thinkit] Instantiate configure_mirror_testbed_test in PINS. (#988)
* Adding gnmi port breakout tests * Instantiate configure_mirror_testbed_test in PINS --------- Co-authored-by: Srikishen Pondicherry Shanmugam <[email protected]>
- Loading branch information
1 parent
db76ab0
commit 42c433d
Showing
3 changed files
with
103 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2025 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 | ||
// | ||
// https://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 "tests/forwarding/configure_mirror_testbed_test.h" | ||
|
||
#include "absl/log/log.h" | ||
#include "gmock/gmock.h" | ||
#include "gtest/gtest.h" | ||
#include "gutil/status_matchers.h" | ||
#include "tests/lib/switch_test_setup_helpers.h" | ||
|
||
namespace pins { | ||
namespace { | ||
|
||
TEST_P(ConfigureMirrorTestbedTestFixture, ConfigureMirrorTestbedTest) { | ||
LOG(INFO) << "Pushing P4Info/gNMI to the control switch"; | ||
ASSERT_OK(pins_test::ConfigureSwitchAndReturnP4RuntimeSession( | ||
GetParam().mirror_testbed->GetMirrorTestbed().ControlSwitch(), | ||
GetParam().control_switch_gnmi_config, | ||
GetParam().control_switch_p4info) | ||
.status()); | ||
|
||
LOG(INFO) << "Pushing P4Info/gNMI to the SUT"; | ||
ASSERT_OK(pins_test::ConfigureSwitchAndReturnP4RuntimeSession( | ||
GetParam().mirror_testbed->GetMirrorTestbed().Sut(), | ||
GetParam().sut_gnmi_config, GetParam().sut_p4info) | ||
.status()); | ||
} | ||
|
||
} // namespace | ||
} // namespace pins |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright 2025 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 | ||
// | ||
// https://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 PINS_TESTS_FORWARDING_CONFIGURE_MIRROR_TESTBED_TEST_H_ | ||
#define PINS_TESTS_FORWARDING_CONFIGURE_MIRROR_TESTBED_TEST_H_ | ||
|
||
#include <string> | ||
|
||
#include "p4/config/v1/p4info.pb.h" | ||
#include "thinkit/mirror_testbed_fixture.h" | ||
|
||
namespace pins { | ||
|
||
struct ConfigureMirrorTestbedTestParams { | ||
std::shared_ptr<thinkit::MirrorTestbedInterface> mirror_testbed; | ||
// The test assumes that the switches are pre-configured if no gNMI or P4Info | ||
// is given (default), or otherwise pushes the given configs. | ||
std::optional<std::string> sut_gnmi_config; | ||
std::optional<std::string> control_switch_gnmi_config; | ||
std::optional<p4::config::v1::P4Info> sut_p4info; | ||
std::optional<p4::config::v1::P4Info> control_switch_p4info; | ||
}; | ||
|
||
// Optionally pushes P4Info or gNMI to SUT and/or control switch. | ||
// TODO: Remove when installation_test also pushes P4Info. | ||
class ConfigureMirrorTestbedTestFixture | ||
: public testing::TestWithParam<ConfigureMirrorTestbedTestParams> { | ||
protected: | ||
void SetUp() override { GetParam().mirror_testbed->SetUp(); } | ||
void TearDown() override { GetParam().mirror_testbed->TearDown(); } | ||
}; | ||
|
||
} // namespace pins | ||
|
||
#endif // PINS_TESTS_FORWARDING_CONFIGURE_MIRROR_TESTBED_TEST_H_ |