Skip to content

Commit

Permalink
fix UT
Browse files Browse the repository at this point in the history
Signed-off-by: Jared Tan <[email protected]>
  • Loading branch information
JaredTan95 committed Aug 8, 2024
1 parent f7efa32 commit 9f49a23
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 48 deletions.
36 changes: 18 additions & 18 deletions cmd/es-rollover/app/init/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type Config struct {

// AddFlags adds flags for TLS to the FlagSet.
func (*Config) AddFlags(flags *flag.FlagSet) {
flags.Int64(cfg.GetNumShardSpanFlag(), 5, "Number of span index shards")
flags.Int64(cfg.GetNumShardServiceFlag(), 5, "Number of service index shards")
flags.Int64(cfg.NumShardSpanFlag(), 5, "Number of span index shards")
flags.Int64(cfg.NumShardServiceFlag(), 5, "Number of service index shards")
flags.Int64(cfg.NumShardDependenciesFlag(), 5, "Number of dependencies index shards")
flags.Int64(cfg.NumShardSamplingFlag(), 5, "Number of sampling index shards")

Expand All @@ -41,24 +41,24 @@ func (*Config) AddFlags(flags *flag.FlagSet) {
flags.Int64(cfg.NumReplicaDependenciesFlag(), 1, "Number of dependencies index replicas")
flags.Int64(cfg.NumReplicaSamplingFlag(), 1, "Number of sampling index replicas")

flags.Int64(cfg.PrioritySpanTemplate(), 0, "Priority of jaeger-span index template (ESv8 only)")
flags.Int64(cfg.PriorityServiceTemplate(), 0, "Priority of jaeger-service index template (ESv8 only)")
flags.Int64(cfg.PriorityDependenciesTemplate(), 0, "Priority of jaeger-dependencies index template (ESv8 only)")
flags.Int64(cfg.PrioritySamplingTemplate(), 0, "Priority of jaeger-sampling index template (ESv8 only)")
flags.Int64(cfg.PrioritySpanTemplateFlag(), 0, "Priority of jaeger-span index template (ESv8 only)")
flags.Int64(cfg.PriorityServiceTemplateFlag(), 0, "Priority of jaeger-service index template (ESv8 only)")
flags.Int64(cfg.PriorityDependenciesTemplateFlag(), 0, "Priority of jaeger-dependencies index template (ESv8 only)")
flags.Int64(cfg.PrioritySamplingTemplateFlag(), 0, "Priority of jaeger-sampling index template (ESv8 only)")
}

// InitFromViper initializes config from viper.Viper.
func (c *Config) InitFromViper(v *viper.Viper) {
c.Indices.Spans.TemplateNumShards = v.GetInt(cfg.GetNumShardSpanFlag())
c.Indices.Spans.TemplateNumReplicas = v.GetInt(cfg.NumReplicaSpanFlag())
c.Indices.Services.TemplateNumShards = v.GetInt(cfg.GetNumShardServiceFlag())
c.Indices.Services.TemplateNumReplicas = v.GetInt(cfg.NumReplicaServiceFlag())
c.Indices.Dependencies.TemplateNumShards = v.GetInt(cfg.NumShardDependenciesFlag())
c.Indices.Dependencies.TemplateNumReplicas = v.GetInt(cfg.NumReplicaDependenciesFlag())
c.Indices.Sampling.TemplateNumShards = v.GetInt(cfg.NumShardSamplingFlag())
c.Indices.Sampling.TemplateNumReplicas = v.GetInt(cfg.NumShardSamplingFlag())
c.Indices.Spans.TemplatePriority = v.GetInt(cfg.PrioritySpanTemplate())
c.Indices.Services.TemplatePriority = v.GetInt(cfg.PriorityServiceTemplate())
c.Indices.Dependencies.TemplatePriority = v.GetInt(cfg.PriorityDependenciesTemplate())
c.Indices.Sampling.TemplatePriority = v.GetInt(cfg.PrioritySamplingTemplate())
c.Indices.Spans.TemplateNumShards = v.GetInt64(cfg.NumShardSpanFlag())
c.Indices.Spans.TemplateNumReplicas = v.GetInt64(cfg.NumReplicaSpanFlag())
c.Indices.Services.TemplateNumShards = v.GetInt64(cfg.NumShardServiceFlag())
c.Indices.Services.TemplateNumReplicas = v.GetInt64(cfg.NumReplicaServiceFlag())
c.Indices.Dependencies.TemplateNumShards = v.GetInt64(cfg.NumShardDependenciesFlag())
c.Indices.Dependencies.TemplateNumReplicas = v.GetInt64(cfg.NumReplicaDependenciesFlag())
c.Indices.Sampling.TemplateNumShards = v.GetInt64(cfg.NumShardSamplingFlag())
c.Indices.Sampling.TemplateNumReplicas = v.GetInt64(cfg.NumShardSamplingFlag())
c.Indices.Spans.TemplatePriority = v.GetInt64(cfg.PrioritySpanTemplateFlag())
c.Indices.Services.TemplatePriority = v.GetInt64(cfg.PriorityServiceTemplateFlag())
c.Indices.Dependencies.TemplatePriority = v.GetInt64(cfg.PriorityDependenciesTemplateFlag())
c.Indices.Sampling.TemplatePriority = v.GetInt64(cfg.PrioritySamplingTemplateFlag())
}
20 changes: 10 additions & 10 deletions cmd/es-rollover/app/init/flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,20 @@ func TestBindFlags(t *testing.T) {
v.BindPFlags(command.PersistentFlags())

err := command.ParseFlags([]string{
"--shards-span=8",
"--replicas-span=16",
"--priority-span-template=300",
"--priority-service-template=301",
"--num-shards-spans=8",
"--num-replicas-spans=16",
"--priority-spans-template=300",
"--priority-services-template=301",
"--priority-dependencies-template=302",
"--priority-sampling-template=303",
})
require.NoError(t, err)

c.InitFromViper(v)
assert.Equal(t, 8, c.Indices.Spans.TemplateOptions.NumShards)
assert.Equal(t, 16, c.Indices.Spans.TemplateOptions.NumReplicas)
assert.Equal(t, 300, c.Indices.Spans.TemplateOptions.Priority)
assert.Equal(t, 301, c.Indices.Services.TemplateOptions.Priority)
assert.Equal(t, 302, c.Indices.Dependencies.TemplateOptions.Priority)
assert.Equal(t, 303, c.Indices.Sampling.TemplateOptions.Priority)
assert.Equal(t, int64(8), c.Indices.Spans.TemplateNumShards)
assert.Equal(t, int64(16), c.Indices.Spans.TemplateNumReplicas)
assert.Equal(t, int64(300), c.Indices.Spans.TemplatePriority)
assert.Equal(t, int64(301), c.Indices.Services.TemplatePriority)
assert.Equal(t, int64(302), c.Indices.Dependencies.TemplatePriority)
assert.Equal(t, int64(303), c.Indices.Sampling.TemplatePriority)
}
8 changes: 4 additions & 4 deletions plugin/storage/es/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -420,10 +420,10 @@ func initFromViper(cfg *namespaceConfig, v *viper.Viper) {
cfg.RemoteReadClusters = strings.Split(remoteReadClusters, ",")
}

cfg.Indices.Spans.DateLayout = strings.ToLower(v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencySpanFlag()))
cfg.Indices.Services.DateLayout = strings.ToLower(v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencyServiceFlag()))
cfg.Indices.Sampling.DateLayout = strings.ToLower(v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencySamplingFlag()))
cfg.Indices.Dependencies.DateLayout = strings.ToLower(v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencyDependenciesFlag()))
cfg.Indices.Spans.RolloverFrequency = v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencySpanFlag())
cfg.Indices.Services.RolloverFrequency = v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencyServiceFlag())
cfg.Indices.Dependencies.RolloverFrequency = v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencyDependenciesFlag())
cfg.Indices.Sampling.RolloverFrequency = v.GetString(cfg.namespace + suffix + config.IndexRolloverFrequencySamplingFlag())

separator := v.GetString(cfg.namespace + suffixIndexDateSeparator)
cfg.Indices.Spans.DateLayout = initDateLayout(cfg.Indices.Spans.RolloverFrequency, separator)
Expand Down
32 changes: 16 additions & 16 deletions plugin/storage/es/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func TestOptions(t *testing.T) {
assert.Empty(t, primary.PasswordFilePath)
assert.NotEmpty(t, primary.Servers)
assert.Empty(t, primary.RemoteReadClusters)
assert.Equal(t, 5, primary.Indices.Spans.TemplateNumShards)
assert.Equal(t, 5, primary.Indices.Services.TemplateNumShards)
assert.Equal(t, 5, primary.Indices.Sampling.TemplateNumShards)
assert.Equal(t, 5, primary.Indices.Dependencies.TemplateNumShards)
assert.Equal(t, 1, primary.Indices.Spans.TemplateNumReplicas)
assert.Equal(t, 1, primary.Indices.Services.TemplateNumReplicas)
assert.Equal(t, 1, primary.Indices.Sampling.TemplateNumReplicas)
assert.Equal(t, 1, primary.Indices.Dependencies.TemplateNumReplicas)
assert.Equal(t, int64(5), primary.Indices.Spans.TemplateNumShards)
assert.Equal(t, int64(5), primary.Indices.Services.TemplateNumShards)
assert.Equal(t, int64(5), primary.Indices.Sampling.TemplateNumShards)
assert.Equal(t, int64(5), primary.Indices.Dependencies.TemplateNumShards)
assert.Equal(t, int64(1), primary.Indices.Spans.TemplateNumReplicas)
assert.Equal(t, int64(1), primary.Indices.Services.TemplateNumReplicas)
assert.Equal(t, int64(1), primary.Indices.Sampling.TemplateNumReplicas)
assert.Equal(t, int64(1), primary.Indices.Dependencies.TemplateNumReplicas)
assert.Equal(t, 72*time.Hour, primary.MaxSpanAge)
assert.False(t, primary.Sniffer)
assert.False(t, primary.SnifferTLSEnabled)
Expand Down Expand Up @@ -110,14 +110,14 @@ func TestOptionsWithFlags(t *testing.T) {
assert.Equal(t, []string{"3.3.3.3", "4.4.4.4"}, aux.Servers)
assert.Equal(t, "hello", aux.Username)
assert.Equal(t, "world", aux.Password)
assert.Equal(t, 5, aux.Indices.Spans.TemplateNumShards)
assert.Equal(t, 5, aux.Indices.Services.TemplateNumShards)
assert.Equal(t, 5, aux.Indices.Sampling.TemplateNumShards)
assert.Equal(t, 5, aux.Indices.Dependencies.TemplateNumShards)
assert.Equal(t, 10, aux.Indices.Spans.TemplateNumReplicas)
assert.Equal(t, 10, aux.Indices.Services.TemplateNumReplicas)
assert.Equal(t, 10, aux.Indices.Sampling.TemplateNumReplicas)
assert.Equal(t, 10, aux.Indices.Dependencies.TemplateNumReplicas)
assert.Equal(t, int64(5), aux.Indices.Spans.TemplateNumShards)
assert.Equal(t, int64(5), aux.Indices.Services.TemplateNumShards)
assert.Equal(t, int64(5), aux.Indices.Sampling.TemplateNumShards)
assert.Equal(t, int64(5), aux.Indices.Dependencies.TemplateNumShards)
assert.Equal(t, int64(10), aux.Indices.Spans.TemplateNumReplicas)
assert.Equal(t, int64(10), aux.Indices.Services.TemplateNumReplicas)
assert.Equal(t, int64(10), aux.Indices.Sampling.TemplateNumReplicas)
assert.Equal(t, int64(10), aux.Indices.Dependencies.TemplateNumReplicas)
assert.Equal(t, 24*time.Hour, aux.MaxSpanAge)
assert.True(t, aux.Sniffer)
assert.True(t, aux.Tags.AllAsFields)
Expand Down

0 comments on commit 9f49a23

Please sign in to comment.