Skip to content

Commit

Permalink
Add bird in Autotest.
Browse files Browse the repository at this point in the history
  • Loading branch information
Markuu-s committed Dec 28, 2024
1 parent 8581dc1 commit ff09e07
Show file tree
Hide file tree
Showing 5 changed files with 159 additions and 0 deletions.
46 changes: 46 additions & 0 deletions autotest/autotest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,16 @@ void tAutotest::mainThread()

result = step_dumpPackets(yamlStep["dumpPackets"], configFilePath);
}
else if (yamlStep["bird"])
{
YANET_LOG_DEBUG("step: bird\n");

result = step_bird(yamlStep["bird"], configFilePath);
}
else if (yamlStep["birdc"])
{
YANET_LOG_DEBUG("step: birdc\n");
}
else
{
YANET_LOG_ERROR("unknown step\n");
Expand Down Expand Up @@ -2006,6 +2016,42 @@ bool tAutotest::step_dumpPackets(const YAML::Node& yamlStep,
return true;
}

bool tAutotest::step_bird(const YAML::Node& yamlStep,
const std::string& path)
{
std::string confPath;
for (const auto& yamlIter : yamlStep)
{
confPath = yamlIter.as<std::string>();
}

if (!confPath.empty())
{
const std::string execCommand = "bird -c " + path + confPath;

std::string resExec = exec(execCommand.c_str());

printf("%s", resExec.data());

return true;
}
return false;
}

bool tAutotest::step_birdc(const YAML::Node& yamlStep)
{
std::string command = "birdc ";
for (const auto& yamlIter : yamlStep)
{
command += yamlIter.as<std::string>() + " ";
}

auto res_birdc = exec(command.c_str());

printf("birdc:\n %s\n", res_birdc.data());
return true;
}

void tAutotest::fflushSharedMemory()
{
size_t size = std::get<0>(rawShmInfo);
Expand Down
2 changes: 2 additions & 0 deletions autotest/autotest.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ class tAutotest
bool step_reload_async(const YAML::Node& yamlStep);
bool step_echo(const YAML::Node& yamlStep);
bool step_dumpPackets(const YAML::Node& yamlStep, const std::string& path);
bool step_bird(const YAML::Node& yamlStep, const std::string& path);
bool step_birdc(const YAML::Node& yamlStep);

eResult initSockets();
eResult initSharedMemory();
Expand Down
8 changes: 8 additions & 0 deletions autotest/units/001_one_port/077_bird/autotest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
steps:
- bird:
- bird/bird.conf
- birdc:
- show route
- sleep: 20
- cli:
- rib prefixes
61 changes: 61 additions & 0 deletions autotest/units/001_one_port/077_bird/bird/bird.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* This is a simple example configuration file with no aim for completeness.
* See documentation for full description.
*/

# Router ID in IPv4 format
router id 62.168.0.1;

# Load device information from kernel.
protocol device {}

# Generate direct routes for interfaces. Useful on BSD.
protocol direct {
ipv4;
disabled;
}

protocol direct {
ipv6;
disabled;
}

# Feed routes to kernel FIB
protocol kernel {
ipv4 { export all; import all; };
learn; # Learn all routes from the kernel
# scan time 10; # Scan kernel tables every 10 seconds
}

protocol kernel {
ipv6 { import all; };
learn;
}

# Static route feed
protocol static {
ipv4 { export all; };
route 10.0.0.0/24 via 192.168.1.32;
route 10.10.0.0/16 blackhole;
route 10.20.0.0/20 via 192.168.1.22;
route 10.30.50.0/28 prohibit;
}

protocol static {
ipv6 { export all; };
route 2001:db8:1::/48 via 5555::6666;
route 2001:db8:2::/48 blackhole;
route 2001:db8:3::/48 prohibit;
route 2001:db8:4::/48 unreachable;
}

protocol export {
table master4;
socket "/var/tmp/bird-master4.sock";
}

protocol export {
table master6;
socket "/var/tmp/bird-master6.sock";
}

42 changes: 42 additions & 0 deletions autotest/units/001_one_port/077_bird/controlplane.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"modules": {
"lp0.100": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "100",
"macAddress": "00:11:22:33:44:55",
"nextModule": "vrf0"
},
"lp0.200": {
"type": "logicalPort",
"physicalPort": "kni0",
"vlanId": "200",
"macAddress": "00:11:22:33:44:55",
"nextModule": "vrf0"
},
"vrf0": {
"type": "route",
"interfaces": {
"kni0.100": {
"nextModule": "lp0.100"
},
"kni0.200": {
"ipv4Prefix": "200.0.0.2/24",
"neighborIPv4Address": "200.0.0.1",
"neighborMacAddress": "00:00:00:11:11:11",
"nextModule": "lp0.200"
}
},
"birdImport": [
{
"socket": "/var/tmp/bird-master4.sock",
"vrf": "master4"
},
{
"socket": "/var/tmp/bird-master6.sock",
"vrf": "master6"
}
]
}
}
}

0 comments on commit ff09e07

Please sign in to comment.