Skip to content

Commit

Permalink
Addressed review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya Kaushik committed Aug 28, 2024
1 parent 537860a commit 8ac8866
Show file tree
Hide file tree
Showing 109 changed files with 136 additions and 261 deletions.
3 changes: 2 additions & 1 deletion cmd/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package cluster
import (
"github.com/spf13/cobra"
"github.com/yugabyte/ybm-cli/cmd/cluster/cert"
"github.com/yugabyte/ybm-cli/cmd/util"
encryption "github.com/yugabyte/ybm-cli/cmd/cluster/encryption"
"github.com/yugabyte/ybm-cli/cmd/cluster/namespace"
"github.com/yugabyte/ybm-cli/cmd/cluster/network"
Expand Down Expand Up @@ -64,7 +65,7 @@ func init() {
pitrconfig.PitrConfigCmd.PersistentFlags().StringVarP(&pitrconfig.ClusterName, "cluster-name", "c", "", "[REQUIRED] The name of the cluster.")
pitrconfig.PitrConfigCmd.MarkPersistentFlagRequired("cluster-name")

ClusterCmd.AddCommand(connectionpooling.ConnectionPoolingCmd)
util.AddCommandIfFeatureFlag(ClusterCmd, connectionpooling.ConnectionPoolingCmd, util.CONNECTION_POOLING)
connectionpooling.ConnectionPoolingCmd.PersistentFlags().StringVarP(&connectionpooling.ClusterName, "cluster-name", "c", "", "[REQUIRED] The name of the cluster.")
connectionpooling.ConnectionPoolingCmd.MarkPersistentFlagRequired("cluster-name")
}
4 changes: 0 additions & 4 deletions cmd/cluster/connection-pooling/connection_pooling.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,6 @@ var disableConnectionPoolingCmd = &cobra.Command{

func init() {
util.AddCommandIfFeatureFlag(ConnectionPoolingCmd, enableConnectionPoolingCmd, util.CONNECTION_POOLING)
enableConnectionPoolingCmd.Flags().String("cluster-name", "", "[REQUIRED] The name of the cluster to get details.")
enableConnectionPoolingCmd.MarkFlagRequired("cluster-name")

util.AddCommandIfFeatureFlag(ConnectionPoolingCmd, disableConnectionPoolingCmd, util.CONNECTION_POOLING)
disableConnectionPoolingCmd.Flags().String("cluster-name", "", "[REQUIRED] The name of the cluster to get details.")
disableConnectionPoolingCmd.MarkFlagRequired("cluster-name")
}
98 changes: 98 additions & 0 deletions cmd/connection_pooling_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// Licensed to Yugabyte, Inc. under one or more contributor license
// agreements. See the NOTICE file distributed with this work for
// additional information regarding copyright ownership. Yugabyte
// licenses this file to you under the Apache License, Version 2.0
// (the "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.

package cmd_test

import (
"fmt"
"net/http"
"os"
"os/exec"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"github.com/onsi/gomega/gbytes"
"github.com/onsi/gomega/gexec"
"github.com/onsi/gomega/ghttp"
openapi "github.com/yugabyte/yugabytedb-managed-go-client-internal"
)

var _ = Describe("Connection Pooling", func() {

var (
server *ghttp.Server
statusCode int
responseAccount openapi.AccountListResponse
responseProject openapi.AccountListResponse
responseListClusters openapi.ClusterListResponse
)

BeforeEach(func() {
var err error
server, err = newGhttpServer(responseAccount, responseProject)
Expect(err).ToNot(HaveOccurred())
os.Setenv("YBM_HOST", fmt.Sprintf("http://%s", server.Addr()))
os.Setenv("YBM_APIKEY", "test-token")
os.Setenv("YBM_FF_CONNECTION_POOLING", "true")
statusCode = 200
err = loadJson("./test/fixtures/list-clusters.json", &responseListClusters)
Expect(err).ToNot(HaveOccurred())
server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodGet, "/api/public/v1/accounts/340af43a-8a7c-4659-9258-4876fd6a207b/projects/78d4459c-0f45-47a5-899a-45ddf43eba6e/clusters"),
ghttp.RespondWithJSONEncodedPtr(&statusCode, responseListClusters),
),
)
})

Context("When enabling connection pooling", func() {
It("should return ", func() {
statusCode = 200

server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPut, "/api/public/v1/accounts/340af43a-8a7c-4659-9258-4876fd6a207b/projects/78d4459c-0f45-47a5-899a-45ddf43eba6e/clusters/5f80730f-ba3f-4f7e-8c01-f8fa4c90dad8/connection-pooling"),
ghttp.RespondWithJSONEncodedPtr(&statusCode, "Successfully submitted cluster connection pooling operation request"),
),
)

cmd := exec.Command(compiledCLIPath, "cluster", "connection-pooling", "enable", "--cluster-name", "stunning-sole")
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
Expect(err).NotTo(HaveOccurred())
session.Wait(2)
Expect(session.Out).Should(gbytes.Say("Connection Pooling for cluster stunning-sole is being enabled"))
session.Kill()
})
It("should return required field name and type when not set", func() {
statusCode = 200

server.AppendHandlers(
ghttp.CombineHandlers(
ghttp.VerifyRequest(http.MethodPut, "/api/public/v1/accounts/340af43a-8a7c-4659-9258-4876fd6a207b/projects/78d4459c-0f45-47a5-899a-45ddf43eba6e/clusters/5f80730f-ba3f-4f7e-8c01-f8fa4c90dad8/connection-pooling"),
ghttp.RespondWithJSONEncodedPtr(&statusCode, "Successfully submitted cluster connection pooling operation request"),
),
)

cmd := exec.Command(compiledCLIPath, "cluster", "connection-pooling", "disable", "--cluster-name", "stunning-sole")
session, err := gexec.Start(cmd, GinkgoWriter, GinkgoWriter)
exec.Command(compiledCLIPath, "y")
Expect(err).NotTo(HaveOccurred())
session.Wait(2)
Expect(session.Out).Should(gbytes.Say("Connection Pooling for cluster stunning-sole is being disabled"))
session.Kill()
})

})
})
1 change: 0 additions & 1 deletion docs/ybm.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ ybm [flags]
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
-h, --help help for ybm
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_api-key.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ybm api-key [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_api-key_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ybm api-key create [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_api-key_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ybm api-key list [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_api-key_revoke.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ybm api-key revoke [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_auth.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ybm auth [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ybm backup [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_create.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ ybm backup create [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_delete.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ybm backup delete [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_describe.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ybm backup describe [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ybm backup list [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_policy.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ybm backup policy [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_policy_disable.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ybm backup policy disable [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_policy_enable.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ybm backup policy enable [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_policy_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ ybm backup policy list [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_policy_update.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ ybm backup policy update [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_backup_restore.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ybm backup restore [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_cluster.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ybm cluster [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_cluster_cert.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ ybm cluster cert [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
1 change: 0 additions & 1 deletion docs/ybm_cluster_cert_download.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ybm cluster cert download [flags]
-a, --apiKey string YugabyteDB Aeon account API key
--config string config file (default is $HOME/.ybm-cli.yaml)
--debug Use debug mode, same as --logLevel debug
--host string YugabyteDB Aeon Api hostname
-l, --logLevel string Select the desired log level format(info). Default to info
--no-color Disable colors in output , default to false
-o, --output string Select the desired output format (table, json, pretty). Default to table
Expand Down
39 changes: 0 additions & 39 deletions docs/ybm_cluster_connection-pooling.md

This file was deleted.

38 changes: 0 additions & 38 deletions docs/ybm_cluster_connection-pooling_disable.md

This file was deleted.

Loading

0 comments on commit 8ac8866

Please sign in to comment.