mirror of
https://github.com/temporalio/temporal.git
synced 2026-08-30 18:41:49 -07:00
## What changed?
- Revive and update original PR #2977 for Elasticsearch CLI tool
Replaces manual curl invocations with a proper CLI tool that leverages
Temporal's built-in Elasticsearch auth providers and provides better
error handling and logging.
## How did you test it?
- [x] built
- [x] run locally and tested manually
- [ ] covered by existing tests
- [ ] added new unit test(s)
- [ ] added new functional test(s)
## Potential risks
None, net new.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Introduces `temporal-elasticsearch-tool` for ES schema/index
management and ping, extends ES client APIs, embeds ES schema, and
updates Makefile to use the tool.
>
> - **Tools**:
> - New `temporal-elasticsearch-tool` CLI with commands: `setup-schema`,
`update-schema`, `create-index`, `drop-index`, `ping`; supports AWS auth
and uses embedded schema files.
> - Adds entrypoint `cmd/tools/elasticsearch`, README, and basic tests.
> - **Elasticsearch Client**:
> - Extends `CLIClient` with `ClusterPutSettings`, `IndexPutTemplate`,
`IndexPutMapping`, `Ping` and implements them (v7) using raw requests
where needed; allows custom HTTP client from config (e.g., AWS-signed).
> - **Schema**:
> - Embeds ES v7 cluster settings and index template
(`schema.Embedded...` accessors).
> - **Build/Makefile**:
> - Adds build target and binary cleanup for
`temporal-elasticsearch-tool`; updates `install-schema-es` and
`install-schema-xdc` to use the CLI instead of curl.
> - Includes binary in `.goreleaser.yml`; excludes it in
`.dockerignore`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
b37864809a. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package elasticsearch
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
"github.com/stretchr/testify/suite"
|
|
)
|
|
|
|
type (
|
|
MainTestSuite struct {
|
|
*require.Assertions
|
|
suite.Suite
|
|
}
|
|
)
|
|
|
|
func TestMainTestSuite(t *testing.T) {
|
|
suite.Run(t, new(MainTestSuite))
|
|
}
|
|
|
|
func (s *MainTestSuite) SetupTest() {
|
|
s.Assertions = require.New(s.T())
|
|
}
|
|
|
|
// Test CLI error scenarios similar to cassandra tests
|
|
func (s *MainTestSuite) TestSetupSchemaError() {
|
|
// fake exit function to avoid exiting the application
|
|
back := osExit
|
|
defer func() { osExit = back }()
|
|
osExit = func(i int) {
|
|
s.Equal(1, i)
|
|
}
|
|
args := []string{"./tool", "setup-schema"}
|
|
app := BuildCLIOptions()
|
|
err := app.Run(args)
|
|
s.Nil(err)
|
|
}
|
|
|
|
func (s *MainTestSuite) TestPingError() {
|
|
// fake exit function to avoid exiting the application
|
|
back := osExit
|
|
defer func() { osExit = back }()
|
|
osExit = func(i int) {
|
|
s.Equal(1, i)
|
|
}
|
|
args := []string{"./tool", "--endpoint", "http://nonexistent:9200", "ping"}
|
|
app := BuildCLIOptions()
|
|
err := app.Run(args)
|
|
s.Nil(err)
|
|
}
|