diff options
author | Jon Bratseth <bratseth@gmail.com> | 2021-08-25 16:55:11 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@gmail.com> | 2021-08-25 16:55:11 +0200 |
commit | 0b3ec0d0b138d55849f0b37704094050b67b736c (patch) | |
tree | 01516e217359712489ee5cf2d382a5125843199e /client | |
parent | 121e456c6073aeb5e370061b9555f20586ad0c13 (diff) |
Use taret names in the status command
Diffstat (limited to 'client')
-rw-r--r-- | client/go/cmd/status.go | 36 | ||||
-rw-r--r-- | client/go/cmd/status_test.go | 57 |
2 files changed, 57 insertions, 36 deletions
diff --git a/client/go/cmd/status.go b/client/go/cmd/status.go index 4425bc44d5b..f1cbc0f9d2d 100644 --- a/client/go/cmd/status.go +++ b/client/go/cmd/status.go @@ -11,36 +11,44 @@ import ( func init() { rootCmd.AddCommand(statusCmd) - statusCmd.AddCommand(statusContainerCmd) - statusCmd.AddCommand(statusConfigServerCmd) + statusCmd.AddCommand(statusQueryCmd) + statusCmd.AddCommand(statusDocumentCmd) + statusCmd.AddCommand(statusDeployCmd) } -// TODO: Use deploy, query and document instead of container and config-server - var statusCmd = &cobra.Command{ Use: "status", - Short: "Verifies that a vespa target is ready to use (container by default)", + Short: "Verifies that a vespa target is ready to use (query by default)", + Long: `TODO`, + Run: func(cmd *cobra.Command, args []string) { + status(queryTarget(), "Query API") + }, +} + +var statusQueryCmd = &cobra.Command{ + Use: "query", + Short: "Verifies that your Vespa query API container endpoint is ready [Default]", Long: `TODO`, Run: func(cmd *cobra.Command, args []string) { - status(queryTarget(), "Container") + status(queryTarget(), "Query API") }, } -var statusContainerCmd = &cobra.Command{ - Use: "container", - Short: "Verifies that your Vespa container endpoint is ready [Default]", +var statusDocumentCmd = &cobra.Command{ + Use: "document", + Short: "Verifies that your Vespa document API container endpoint is ready [Default]", Long: `TODO`, Run: func(cmd *cobra.Command, args []string) { - status(queryTarget(), "Container") + status(documentTarget(), "Document API") }, } -var statusConfigServerCmd = &cobra.Command{ - Use: "config-server", - Short: "Verifies that your Vespa config server endpoint is ready", +var statusDeployCmd = &cobra.Command{ + Use: "deploy", + Short: "Verifies that your Vespa deploy API config server endpoint is ready", Long: `TODO`, Run: func(cmd *cobra.Command, args []string) { - status(deployTarget(), "Config server") + status(deployTarget(), "Deploy API") }, } diff --git a/client/go/cmd/status_test.go b/client/go/cmd/status_test.go index 8e81dd5f566..19bfd2d756b 100644 --- a/client/go/cmd/status_test.go +++ b/client/go/cmd/status_test.go @@ -9,62 +9,75 @@ import ( "testing" ) -func TestStatusConfigServerCommand(t *testing.T) { - assertConfigServerStatus("http://127.0.0.1:19071", []string{}, t) +func TestStatusDeployCommand(t *testing.T) { + assertDeployStatus("http://127.0.0.1:19071", []string{}, t) } -func TestStatusConfigServerCommandWithURLTarget(t *testing.T) { - assertConfigServerStatus("http://mydeploytarget", []string{"-t", "http://mydeploytarget"}, t) +func TestStatusDeployCommandWithURLTarget(t *testing.T) { + assertDeployStatus("http://mydeploytarget", []string{"-t", "http://mydeploytarget"}, t) } -func TestStatusConfigServerCommandWithLocalTarget(t *testing.T) { - assertConfigServerStatus("http://127.0.0.1:19071", []string{"-t", "local"}, t) +func TestStatusDeployCommandWithLocalTarget(t *testing.T) { + assertDeployStatus("http://127.0.0.1:19071", []string{"-t", "local"}, t) } -func TestStatusContainerCommand(t *testing.T) { - assertContainerStatus("http://127.0.0.1:8080", []string{}, t) +func TestStatusQueryCommand(t *testing.T) { + assertQueryStatus("http://127.0.0.1:8080", []string{}, t) } -func TestStatusContainerCommandWithUrlTarget(t *testing.T) { - assertContainerStatus("http://mycontainertarget", []string{"-t", "http://mycontainertarget"}, t) +func TestStatusQueryCommandWithUrlTarget(t *testing.T) { + assertQueryStatus("http://mycontainertarget", []string{"-t", "http://mycontainertarget"}, t) } -func TestStatusContainerCommandWithLocalTarget(t *testing.T) { - assertContainerStatus("http://127.0.0.1:8080", []string{"-t", "local"}, t) +func TestStatusQueryCommandWithLocalTarget(t *testing.T) { + assertQueryStatus("http://127.0.0.1:8080", []string{"-t", "local"}, t) +} + +func TestStatusDocumentCommandWithLocalTarget(t *testing.T) { + assertDocumentStatus("http://127.0.0.1:8080", []string{"-t", "local"}, t) } func TestStatusErrorResponse(t *testing.T) { - assertContainerError("http://127.0.0.1:8080", []string{}, t) + assertQueryStatusError("http://127.0.0.1:8080", []string{}, t) } -func assertConfigServerStatus(target string, args []string, t *testing.T) { +func assertDeployStatus(target string, args []string, t *testing.T) { client := &mockHttpClient{} assert.Equal(t, - "\x1b[32mConfig server at "+target+" is ready\n", - executeCommand(t, client, []string{"status", "config-server"}, args), + "\x1b[32mDeploy API at "+target+" is ready\n", + executeCommand(t, client, []string{"status", "deploy"}, args), "vespa status config-server") assert.Equal(t, target+"/ApplicationStatus", client.lastRequest.URL.String()) } -func assertContainerStatus(target string, args []string, t *testing.T) { +func assertQueryStatus(target string, args []string, t *testing.T) { client := &mockHttpClient{} assert.Equal(t, - "\x1b[32mContainer at "+target+" is ready\n", - executeCommand(t, client, []string{"status", "container"}, args), + "\x1b[32mQuery API at "+target+" is ready\n", + executeCommand(t, client, []string{"status", "query"}, args), "vespa status container") assert.Equal(t, target+"/ApplicationStatus", client.lastRequest.URL.String()) assert.Equal(t, - "\x1b[32mContainer at "+target+" is ready\n", + "\x1b[32mQuery API at "+target+" is ready\n", executeCommand(t, client, []string{"status"}, args), "vespa status (the default)") assert.Equal(t, target+"/ApplicationStatus", client.lastRequest.URL.String()) } -func assertContainerError(target string, args []string, t *testing.T) { +func assertDocumentStatus(target string, args []string, t *testing.T) { + client := &mockHttpClient{} + assert.Equal(t, + "\x1b[32mDocument API at "+target+" is ready\n", + executeCommand(t, client, []string{"status", "document"}, args), + "vespa status container") + assert.Equal(t, target+"/ApplicationStatus", client.lastRequest.URL.String()) +} + +func assertQueryStatusError(target string, args []string, t *testing.T) { client := &mockHttpClient{nextStatus: 500} assert.Equal(t, - "\x1b[31mContainer at "+target+" is not ready\n\x1b[33mStatus 500\n", + "\x1b[31mQuery API at "+target+" is not ready\n\x1b[33mStatus 500\n", executeCommand(t, client, []string{"status", "container"}, args), "vespa status container") } |