Skip to content

Add a test CLI-Svc#859

Closed
marckhouzam wants to merge 2 commits intovmware-tanzu:mainfrom
marckhouzam:marck/testCLIService
Closed

Add a test CLI-Svc#859
marckhouzam wants to merge 2 commits intovmware-tanzu:mainfrom
marckhouzam:marck/testCLIService

Conversation

@marckhouzam
Copy link
Copy Markdown
Contributor

@marckhouzam marckhouzam commented Feb 28, 2025

What this PR does / why we need it

This PR adds a mock test CLI-Svc to allow testing upcoming changes to the CLI. The mock is an nginx docker container configured with SSL that serves the different endpoints of the CLI-Svc (the trailing slash is important):

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

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

The cli/v1/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
$ make start-test-cli-service
Stopped docker test cli service
Adding docker test cli service cert to the config file
/Users/kmarc/git/tanzu-cli/bin/tanzu config cert add --host localhost:9443 --ca-cert /Users/kmarc/git/tanzu-cli/hack/central-repo/certs/localhost.crt
[ok] successfully added certificate data for host localhost:9443
Started docker test cli service at 'localhost:9443'

# If run many times, the output will randomly change between a couple of different repos
$ curl https://localhost:9443/cli/v1/plugin/discovery/ --cacert hack/central-repo/certs/localhost.crt
{
    "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 https://localhost:9443/cli/v1/binary/ --cacert hack/central-repo/certs/localhost.crt
<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 https://localhost:9443/cli/v1/install/ --cacert hack/central-repo/certs/localhost.crt
#!sh

# Copyright 2025 VMware, Inc. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

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
@marckhouzam marckhouzam force-pushed the marck/testCLIService branch 3 times, most recently from 309e284 to 77d4cd4 Compare March 3, 2025 13:33
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 <marc.khouzam@broadcom.com>
Signed-off-by: Marc Khouzam <marc.khouzam@broadcom.com>
@marckhouzam marckhouzam force-pushed the marck/testCLIService branch from 77d4cd4 to f080b8a Compare March 3, 2025 15:17
@marckhouzam
Copy link
Copy Markdown
Contributor Author

Won't be needing this

@marckhouzam marckhouzam closed this Mar 6, 2025
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