News KrakenD Enterprise v2.6 released with OpenTelemetry, FIPS-140, gRPC server and more

Community Documentation

Recent changes

Test plugins after compiling them

Document updated on Aug 22, 2022

Plugins are essential extensions to the KrakenD gateway, enhancing functionality without modifying the core codebase. Due to their reliance on specific versions of KrakenD, libraries, or system architecture, plugins can face compatibility issues following updates or modifications. So, when you have written a new plugin, and compiled it you still need to see that is loadable into KrakenD.

Recompile plugins when you upgrade KrakenD
When you upgrade KrakenD to another version you must recompile your plugins using the builder matching the version.

Even if a plugin compiles and passes initial tests on its own, it might fail when loaded into KrakenD. This could be due to various reasons such as compilation on a different architecture, mismatches in Go version, or discrepancies in library versions used by both the plugin and KrakenD.

The test-plugin command offers a real-scenario opportunity to test a compiled binary (usually a .so file) and verify if KrakenD can successfully load it.

Testing a compiled plugin before it goes live

The test-plugin command requires you to pass the type of plugin you would like to test, and the path to the compiled binary.

The command accepts the following options:

Usage of test-plugin 
$krakend test-plugin -h
╓▄█                          ▄▄▌                               ╓██████▄µ
▐███  ▄███╨▐███▄██H╗██████▄  ║██▌ ,▄███╨ ▄██████▄  ▓██▌█████▄  ███▀╙╙▀▀███╕
▐███▄███▀  ▐█████▀"╙▀▀"╙▀███ ║███▄███┘  ███▀""▀███ ████▀╙▀███H ███     ╙███
▐██████▌   ▐███⌐  ,▄████████M║██████▄  ║██████████M███▌   ███H ███     ,███
▐███╨▀███µ ▐███   ███▌  ,███M║███╙▀███  ███▄```▄▄` ███▌   ███H ███,,,╓▄███▀
▐███  ╙███▄▐███   ╙█████████M║██▌  ╙███▄`▀███████╨ ███▌   ███H █████████▀
                     ``                     `'`

Version: 2.6.2

Tests that one or more plugins are loadable into KrakenD.

Usage:
  krakend test-plugin [flags] [artifacts]

Examples:
krakend test-plugin -scm ./plugins/my_plugin.so ./plugins/my_other_plugin.so

Flags:
  -c, --client     The artifact should contain a Client Plugin.
  -h, --help       help for test-plugin
  -m, --modifier   The artifact should contain a Req/Resp Modifier Plugin.
  -s, --server     The artifact should contain a Server Plugin.

You can pass as many arguments as plugins you want to check at once. For instance, if you want to test that plugin1.so and plugin2.so are loadable as server plugins, you could execute krakend test-plugin -s plugin1.so plugin2.so.

You should provide at least on of the flags -c (client plugins), -m (req/resp modifiers), or -s (server plugins).

Here’s an output example:

Checking a failing plugin example 
$krakend test-plugin -smc plugin1.so plugin2.so
[KO] SERVER	    plugin1.so: The plugin does not contain a HandlerRegisterer.
[KO] MODIFIER   plugin1.so: The plugin does not contain a ModifierRegisterer.
[OK] CLIENT     plugin1.so
[OK] CLIENT     plugin2.so
[OK] SERVER     plugin2.so
[OK] MODIFIER   plugin2.so
[KO] 2 tested plugin(s) in 13.498341ms.
1 plugin(s) failed.

The command will exit with a status code 1 when it fails, so if you integrate it in a CI/CD pipeline it will stop.

When you find issues, use the check-plugin tool in development

The command exits with a code of 1 upon failure, allowing for integration into CI/CD pipelines to halt progress.

If you encounter issues, consider using the check-plugin tool during development to diagnose and resolve problems effectively.

Scarf

Unresolved issues?

The documentation is only a piece of the help you can get! Whether you are looking for Open Source or Enterprise support, see more support channels that can help you.