summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaul Holzinger <pholzing@redhat.com>2022-11-29 19:06:09 +0100
committerPaul Holzinger <pholzing@redhat.com>2023-04-04 17:58:26 +0200
commitcee4d9f0b79a38f1e8ab9c2bdbf0de6a32d93926 (patch)
treef144b4355ee93ae1b843051cd3466a761784ed20 /test
parentb2ffb90997e7ae21016b61ae7c8bd0cc55f529d6 (diff)
add netavark plugin driver
This contains the core netavark logic to actually execute custom plugins. This adds a new --plugin-directory option which can be set multiple times to give a list of directories that will be searched for the plugin. Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Diffstat (limited to 'test')
-rw-r--r--test/500-plugin.bats64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/500-plugin.bats b/test/500-plugin.bats
new file mode 100644
index 0000000..a9d0d66
--- /dev/null
+++ b/test/500-plugin.bats
@@ -0,0 +1,64 @@
+#!/usr/bin/env bats -*- bats -*-
+#
+# macvlan driver test
+#
+
+load helpers
+
+
+# create config for plugin with the name as first arg
+function get_conf() {
+ cat <<EOF
+{
+ "container_id": "someID",
+ "container_name": "someName",
+ "networks": {
+ "plugin-net": {
+ "interface_name": "eth0"
+ }
+ },
+ "network_info": {
+ "plugin-net": {
+ "name": "plugin-net",
+ "id": "2f259bab93aaaaa2542ba43ef33eb990d0999ee1b9924b557b7be53c0b7a1bb9",
+ "driver": "$1",
+ "network_interface": "dummy0",
+ "ipv6_enabled": false,
+ "internal": false,
+ "dns_enabled": false
+ }
+ }
+}
+EOF
+}
+
+function run_netavark_plugins() {
+ run_netavark --plugin-directory ./targets/release/examples/ "$@"
+}
+
+@test "plugin - test error message" {
+ config=$(get_conf error-plugin)
+
+ expected_rc=1 run_netavark_plugins setup $(get_container_netns_path) <<<"$config"
+ assert '{"error":"plugin \"error-plugin\" failed: exit code 1, message: setup error"}'
+
+ expected_rc=1 run_netavark_plugins teardown $(get_container_netns_path) <<<"$config"
+ assert '{"error":"plugin \"error-plugin\" failed: exit code 1, message: teardown error"}'
+}
+
+@test "plugin - host-device" {
+ config=$(get_conf host-device-plugin)
+
+ run_in_host_netns ip link add dummy0 type dummy
+
+ run_netavark_plugins setup $(get_container_netns_path) <<<"$config"
+ assert "$output" =~ '"interfaces"\:\{"dummy0"\:' "status block with interface name"
+
+ run_in_container_netns ip link show dummy0
+
+ run_netavark_plugins teardown $(get_container_netns_path) <<<"$config"
+ assert '' "no error output"
+
+ # interface should be back in the host ns
+ run_in_host_netns ip link show dummy0
+}