Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test CLI-Svc #859

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

marckhouzam
Copy link
Contributor

What this PR does / why we need it

This PR adds a stub test CLI-Svc to allow testing upcoming changes to the CLI.

This test service can be started with make start-test-cli-service.

The service provides three endpoints:

  • localhost:8080/cli/v1/install/
  • localhost:8080/cli/v1/binary/
  • localhost:8080/cli/v1/plugin/discovery/

The "plugin/discovery" endpoint will randomly pick what to recommend between different versions of the plugin group; this allows to simulate a different recommendation that can happen at any time, as if TP had been upgraded.

For more information please refer to the included README.md file.

Which issue(s) this PR fixes

Fixes # N/A

Describe testing done for PR

$ cd tanzu-cli
~tc
$ export TANZU_CLI_PLUGIN_DISCOVERY_HOST_FOR_TANZU_CONTEXT=http://localhost:8080
$ make start-test-cli-service
Stopped docker test cli service
e87b26856b15fe8f5ab736dbc90766a3dee8f30c0b4f6a898a216e506804c16e
Started docker test cli service at 'localhost:8080'

$ curl http://localhost:8080/cli/v1/plugin/discovery/
{
    "pluginGroups": [
        {
            "name": "vmware-tkg/default",
            "recommendedVersion": "v9.9.9"
        }
    ],
    "pluginSources":  [
        {
            "oci": {
                "name": "discovered-from-tpsm",
                "image": "localhost:9876/tanzu-cli/plugins/central:small"
            }
        }
    ]
}

# This endpoint currently lists a couple of fake binaries but can be adapted later
$ curl http://localhost:8080/cli/v1/binary/
<html>
<head><title>Index of /cli/v1/binary/</title></head>
<body>
<h1>Index of /cli/v1/binary/</h1><hr><pre><a href="../">../</a>
<a href="tanzu-v1.5.2">tanzu-v1.5.2</a>                                       27-Feb-2025 21:10                   0
<a href="tanzu-v1.5.3">tanzu-v1.5.3</a>                                       27-Feb-2025 21:10                   0
</pre><hr></body>
</html>

# This endpoint currently provides a fake installation script
$ curl http://localhost:8080/cli/v1/install/
#!sh

echo "Fake installation of the Tanzu CLI"

Release note

Add a test CLI-Svc mock to allow testing future CLI features.

Additional information

Special notes for your reviewer

@marckhouzam marckhouzam requested a review from a team as a code owner February 28, 2025 17:04
This test service can be started with `make start-test-cli-service`.
The service provides three endpoints:
- localhost:8080/cli/v1/install/
- localhost:8080/cli/v1/binary/
- localhost:8080/cli/v1/plugin/discovery/

The "plugin/discovery" endpoint will randomly pick what to recommend
between different versions of the plugin group; this allows to simulate
a different recommendation that can happen at any time, as if TP had
been upgraded.

Signed-off-by: Marc Khouzam <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants