From 668bad467f24ead9150778d376b9e14eac23904a Mon Sep 17 00:00:00 2001 From: Panchajanya Mysarla <106101699+mpanchajanya@users.noreply.github.com> Date: Fri, 7 Apr 2023 13:10:27 -0500 Subject: [PATCH] Add documentation for test plugin command (#193) --- docs/full/cli-architecture.md | 2 ++ docs/plugindev/README.md | 38 ++++++++++++++++++++++++++++++++++- 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/docs/full/cli-architecture.md b/docs/full/cli-architecture.md index 045e02c93..05378c2c8 100644 --- a/docs/full/cli-architecture.md +++ b/docs/full/cli-architecture.md @@ -253,6 +253,8 @@ Execute the test plugin: tanzu test plugin ``` +For more details go to [Plugin Development Guide](../plugindev/README.md). + ## Docs Every plugin requires a README.md file at the top level of its directory which is enforced by the compiler. This file should serve as a guide for how the plugin is to be used. diff --git a/docs/plugindev/README.md b/docs/plugindev/README.md index 065ad12a3..142d28154 100644 --- a/docs/plugindev/README.md +++ b/docs/plugindev/README.md @@ -96,7 +96,7 @@ newly created `main` package to implement the functionality of your new plugin. You will notice in the generated `main.go` file, that CLI plugins have to instantiate a [Plugin Descriptor](https://github.com/vmware-tanzu/tanzu-plugin-runtime/blob/main/plugin/types.go#L60) -```go +``` go import ( "github.com/vmware-tanzu/tanzu-plugin-runtime/plugin/buildinfo" "github.com/vmware-tanzu/tanzu-plugin-runtime/plugin" @@ -259,6 +259,42 @@ Note: as the configuration variable implies, the plugin development and testing only. The use of this setting in the production setting is not supported. +### Testing the plugins + +Plugin tests can be run by installing the admin `test` plugin. +Currently, we only support testing plugins built locally. + +**Note:** The `test` admin functionality has been deprecated and no future enhancements are planned for this plugin. + +Steps to test plugin :- + +1. Bootstrap a new plugin +2. Build a plugin binary +3. Run below command + +``` go +tanzu test fetch -l ~/${PLUGIN_NAME}/artifacts/plugins/${HOSTOS}/${HOSTARCH} +tanzu test plugin PLUGIN_NAME +``` + +Example: `helloworld` plugin + +``` go +tanzu test fetch -l ~/helloworld/artifacts/plugins/darwin/amd64 + +[i] Installing plugin 'helloworld:v0.0.1' with target 'global' +[i] Installing test plugin for 'helloworld:v0.0.1' + +❯ tanzu test plugin helloworld +--- +[i] testing helloworld + + +[i] cleaning up + +[ok] ok: successfully tested helloworld +``` + ------------------------------ ## CLI command best practices