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

Vec 266 Add a node ls command #9

Merged
merged 21 commits into from
Aug 8, 2024
41 changes: 41 additions & 0 deletions .github/workflows/tests-large.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Large Tests
on:
pull_request:
branches:
- "**"
workflow_call:

jobs:
tests:
runs-on: aerospike_large_runners_8
steps:
- uses: actions/checkout@v3
- name: Get go version from go.mod
run: |
echo "GO_VERSION=$(grep '^go ' go.mod | cut -d " " -f 2)" >> $GITHUB_ENV
- uses: actions/setup-go@v3
with:
go-version: ${{ env.GO_VERSION }}
- name: Write feature keys
env:
FEATURES_CONF : ${{secrets.FEATURES_CONF}}

run: |
echo "$FEATURES_CONF" > docker/vanilla/config/features.conf
echo "$FEATURES_CONF" > docker/tls/config/features.conf
echo "$FEATURES_CONF" > docker/mtls/config/features.conf
echo "$FEATURES_CONF" > docker/auth/config/features.conf
echo "$FEATURES_CONF" > docker/multi-node/config/features.conf
echo "$FEATURES_CONF" > docker/multi-node-LB/config/features.conf
- name: Login to Aerospike Jfrog
run: |
docker login aerospike.jfrog.io --username ${{ secrets.JFROG_USERNAME }} --password ${{ secrets.JFROG_ACCESS_TOKEN }}
- name: Run tests
run: |
make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
files: ./coverage/total.cov
verbose: false
22 changes: 5 additions & 17 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
name: Test
on:
push:
branches:
- '**' # Run on every branch
pull_request:
branches-ignore:
- main
- '**' # Ignore all branches for pull requests
workflow_call:

jobs:
tests:
runs-on: aerospike_large_runners_8
steps:
- name: Maximize build space
uses: easimon/maximize-build-space@master
with:
remove-dotnet: 'true'
remove-android: 'true'
- uses: actions/checkout@v3
- name: Get go version from go.mod
run: |
Expand All @@ -33,16 +31,6 @@ jobs:
- name: Login to Aerospike Jfrog
run: |
docker login aerospike.jfrog.io --username ${{ secrets.JFROG_USERNAME }} --password ${{ secrets.JFROG_ACCESS_TOKEN }}
# - name: Clear Docker Cache
# run: |
# docker system prune --all --force

- name: Run tests
run: |
make coverage
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{secrets.CODECOV_TOKEN}}
files: ./coverage/total.cov
verbose: false
make test
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -502,22 +502,29 @@ macos-pkg-notarize:
.PHONY: test
test: integration unit

.PHONY: test-large
test-large: integration-large unit

.PHONY: integration
integration:
mkdir -p $(COV_INTEGRATION_DIR) || true
COVERAGE_DIR=$(COV_INTEGRATION_DIR) go test -tags=integration -timeout 30m

.PHONY: integration-large
integration-large:
mkdir -p $(COV_INTEGRATION_DIR) || true
COVERAGE_DIR=$(COV_INTEGRATION_DIR) go test -tags=integration_large -timeout 30m

.PHONY: unit
unit:
mkdir -p $(COV_UNIT_DIR) || true
go test -tags=unit -cover ./... -args -test.gocoverdir=$(COV_UNIT_DIR)

.PHONY: coverage
coverage: test
coverage: test-large
go tool covdata textfmt -i="$(COV_INTEGRATION_DIR),$(COV_UNIT_DIR)" -o=$(COVERAGE_DIR)/total.cov
go tool cover -func=$(COVERAGE_DIR)/total.cov


PHONY: view-coverage
view-coverage: $(COVERAGE_DIR)/total.cov
go tool cover -html=$(COVERAGE_DIR)/total.cov
9 changes: 9 additions & 0 deletions cmd/flags/constants.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package flags

import "github.com/spf13/pflag"

const (
LogLevel = "log-level"
NoColor = "no-color"
Seeds = "seeds"
Host = "host"
ListenerName = "listener-name"
Expand All @@ -21,6 +24,7 @@ const (
IndexLabels = "index-labels"
Timeout = "timeout"
Verbose = "verbose"
Format = "format"
Yaml = "yaml"
InputFile = "file"
StorageNamespace = "storage-namespace"
Expand All @@ -47,3 +51,8 @@ const (
TLSKeyFile = "tls-keyfile"
TLSKeyFilePass = "tls-keyfile-password" //nolint:gosec // Not a credential
)

func AddFormatTestFlag(flagSet *pflag.FlagSet, val *int) error {
flagSet.IntVar(val, Format, 0, "For testing only")
return flagSet.MarkHidden(Format)
}
9 changes: 8 additions & 1 deletion cmd/indexList.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ import (
"gopkg.in/yaml.v3"
)

//nolint:govet // Padding not a concern for a CLI
var indexListFlags = &struct {
clientFlags flags.ClientFlags
verbose bool
format int // For testing. Hidden
yaml bool
}{
clientFlags: *flags.NewClientFlags(),
Expand All @@ -29,6 +31,11 @@ func newIndexListFlagSet() *pflag.FlagSet {
flagSet.BoolVar(&indexListFlags.yaml, flags.Yaml, false, "Output indexes in yaml format to later be used with \"asvec index create --file <index-def.yaml>") //nolint:lll // For readability
flagSet.AddFlagSet(indexListFlags.clientFlags.NewClientFlagSet())

err := flags.AddFormatTestFlag(flagSet, &indexListFlags.format)
if err != nil {
panic(err)
}

return flagSet
}

Expand Down Expand Up @@ -131,7 +138,7 @@ asvec index ls

view.Print(string(yamlData))
} else {
view.PrintIndexes(indexList, indexStatusList, indexListFlags.verbose)
view.PrintIndexes(indexList, indexStatusList, indexListFlags.verbose, indexListFlags.format)

if indexListFlags.verbose {
view.Print("Values ending with * can be dynamically configured using the 'asvec index update' command.")
Expand Down
22 changes: 22 additions & 0 deletions cmd/node.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"github.com/spf13/cobra"
)

// clusterCmd represents the create command
var clusterCmd = &cobra.Command{
jdogmcsteezy marked this conversation as resolved.
Show resolved Hide resolved
Use: "node",
Aliases: []string{"nodes"},
Short: "A parent command viewing information about your cluster.",
Long: `A parent command viewing information about your cluster..
jdogmcsteezy marked this conversation as resolved.
Show resolved Hide resolved

For example:

asvec node --help
`,
}

func init() {
rootCmd.AddCommand(clusterCmd)
}
Loading
Loading