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

Update CLI json printing to use new writer interface for testability #6412

Merged

Conversation

taylanisikdemir
Copy link
Member

What changed?

  • Exposing a new WithIOHandler option so that tests can override default output writer which is stdout.
  • Refactored prettyPrintJSONObject usages to use the app's IOHandler. This way all those corresponding commands can validate the output.

Why?
Improve testability.

How did you test it?

go run cmd/tools/cli/main.go admin cluster d
{
  "supportedClientVersions": {
    "goSdk": "1.7.0",
    "javaSdk": "1.5.0"
  },
  "membershipInfo": {
    "currentHost": {
      "Identity": "172.19.0.6:7933"
    },
    "reachableMembers": [
      "172.19.0.6:7933",
      "172.19.0.6:7934",
      "172.19.0.6:7935",
      "172.19.0.6:7939"
    ],
    "rings": [
      {
        "role": "cadence-frontend",
        "memberCount": 1,
        "members": [
          {
            "Identity": "172.19.0.6:7933"
          }
        ]
      },
      {
        "role": "cadence-history",
        "memberCount": 1,
        "members": [
          {
            "Identity": "172.19.0.6:7934"
          }
        ]
      },
      {
        "role": "cadence-matching",
        "memberCount": 1,
        "members": [
          {
            "Identity": "172.19.0.6:7935"
          }
        ]
      },
      {
        "role": "cadence-worker",
        "memberCount": 1,
        "members": [
          {
            "Identity": "172.19.0.6:7939"
          }
        ]
      }
    ]
  },
  "persistenceInfo": {
    "historyStore": {
      "backend": "shardedNosql"
    },
    "visibilityStore": {
      "backend": "cassandra",
      "features": [
        {
          "key": "advancedVisibilityEnabled",
          "enabled": false
        }
      ]
    }
  }
}

@taylanisikdemir taylanisikdemir enabled auto-merge (squash) October 24, 2024 22:38
@taylanisikdemir taylanisikdemir merged commit 85b5426 into cadence-workflow:master Oct 24, 2024
18 checks passed
@taylanisikdemir taylanisikdemir deleted the taylan/cli_output_opt branch October 24, 2024 23:03
Copy link

codecov bot commented Oct 24, 2024

Codecov Report

Attention: Patch coverage is 44.00000% with 28 lines in your changes missing coverage. Please review.

Project coverage is 76.11%. Comparing base (8b4366f) to head (87f7188).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
tools/cli/app.go 55.55% 6 Missing and 2 partials ⚠️
tools/cli/admin_commands.go 28.57% 5 Missing ⚠️
tools/cli/workflow_batch_commands.go 0.00% 4 Missing ⚠️
tools/cli/admin_config_store_commands.go 0.00% 3 Missing ⚠️
tools/cli/isolation-groups.go 57.14% 3 Missing ⚠️
tools/cli/workflow_commands.go 40.00% 3 Missing ⚠️
tools/cli/admin_async_queue_commands.go 0.00% 1 Missing ⚠️
tools/cli/admin_failover_commands.go 0.00% 1 Missing ⚠️
Additional details and impacted files
Files with missing lines Coverage Δ
tools/cli/admin_cluster_commands.go 76.08% <100.00%> (ø)
tools/cli/utils.go 55.52% <100.00%> (ø)
tools/cli/admin_async_queue_commands.go 0.00% <0.00%> (ø)
tools/cli/admin_failover_commands.go 27.85% <0.00%> (ø)
tools/cli/admin_config_store_commands.go 0.00% <0.00%> (ø)
tools/cli/isolation-groups.go 49.74% <57.14%> (ø)
tools/cli/workflow_commands.go 66.92% <40.00%> (ø)
tools/cli/workflow_batch_commands.go 0.00% <0.00%> (ø)
tools/cli/admin_commands.go 6.25% <28.57%> (ø)
tools/cli/app.go 93.71% <55.55%> (-1.65%) ⬇️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8b4366f...87f7188. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants