From 8f41298b8b49a207652b2b0e64cf1803368d1f7b Mon Sep 17 00:00:00 2001 From: FlamingSaint Date: Mon, 13 May 2024 23:46:36 +0530 Subject: [PATCH 1/2] Remove elasticsearch v5/v6 from tests Signed-off-by: FlamingSaint --- .../app/renderer/render_test.go | 8 ---- .../es/dependencystore/storage_test.go | 4 -- .../storage/integration/elasticsearch_test.go | 2 +- .../integration/es_index_rollover_test.go | 37 +++++-------------- 4 files changed, 11 insertions(+), 40 deletions(-) diff --git a/cmd/esmapping-generator/app/renderer/render_test.go b/cmd/esmapping-generator/app/renderer/render_test.go index b971d800d87..e8245b24696 100644 --- a/cmd/esmapping-generator/app/renderer/render_test.go +++ b/cmd/esmapping-generator/app/renderer/render_test.go @@ -56,14 +56,6 @@ func Test_getMappingAsString(t *testing.T) { name: "ES version 7", args: app.Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: 1, IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"}, want: "ES version 7", }, - { - name: "ES version 6", args: app.Options{Mapping: "jaeger-span", EsVersion: 6, Shards: 5, Replicas: 1, IndexPrefix: "test", UseILM: "false", ILMPolicyName: "jaeger-test-policy"}, - want: "ES version 6", - }, - { - name: "Parse Error version 6", args: app.Options{Mapping: "jaeger-span", EsVersion: 6, Shards: 5, Replicas: 1, IndexPrefix: "test", UseILM: "false", ILMPolicyName: "jaeger-test-policy"}, - wantErr: errors.New("parse error"), - }, { name: "Parse Error version 7", args: app.Options{Mapping: "jaeger-span", EsVersion: 7, Shards: 5, Replicas: 1, IndexPrefix: "test", UseILM: "true", ILMPolicyName: "jaeger-test-policy"}, wantErr: errors.New("parse error"), diff --git a/plugin/storage/es/dependencystore/storage_test.go b/plugin/storage/es/dependencystore/storage_test.go index 91d3e152186..a147535bbbf 100644 --- a/plugin/storage/es/dependencystore/storage_test.go +++ b/plugin/storage/es/dependencystore/storage_test.go @@ -97,10 +97,6 @@ func TestWriteDependencies(t *testing.T) { expectedError string esVersion uint }{ - { - expectedError: "", - esVersion: 6, - }, { expectedError: "", esVersion: 7, diff --git a/plugin/storage/integration/elasticsearch_test.go b/plugin/storage/integration/elasticsearch_test.go index b78391754b0..c1d71e3f1b3 100644 --- a/plugin/storage/integration/elasticsearch_test.go +++ b/plugin/storage/integration/elasticsearch_test.go @@ -201,7 +201,7 @@ func TestElasticsearchStorage_IndexTemplates(t *testing.T) { esVersion, err := s.getVersion() require.NoError(t, err) // TODO abstract this into pkg/es/client.IndexManagementLifecycleAPI - if esVersion <= 7 { + if esVersion == 7 { serviceTemplateExists, err := s.client.IndexTemplateExists(indexPrefix + "-jaeger-service").Do(context.Background()) require.NoError(t, err) assert.True(t, serviceTemplateExists) diff --git a/plugin/storage/integration/es_index_rollover_test.go b/plugin/storage/integration/es_index_rollover_test.go index 45d874c4475..8428846ee9c 100644 --- a/plugin/storage/integration/es_index_rollover_test.go +++ b/plugin/storage/integration/es_index_rollover_test.go @@ -33,11 +33,7 @@ func TestIndexRollover_FailIfILMNotPresent(t *testing.T) { SkipUnlessEnv(t, "elasticsearch", "opensearch") client, err := createESClient() require.NoError(t, err) - esVersion, err := getVersion(client) require.NoError(t, err) - if esVersion < 7 { - t.Skip("Integration test - " + t.Name() + " against ElasticSearch skipped for ES version " + fmt.Sprint(esVersion)) - } // make sure ES is clean cleanES(t, client, defaultILMPolicyName) envVars := []string{"ES_USE_ILM=true"} @@ -65,8 +61,6 @@ func TestIndexRollover_CreateIndicesWithILM(t *testing.T) { func runCreateIndicesWithILM(t *testing.T, ilmPolicyName string) { client, err := createESClient() require.NoError(t, err) - - esVersion, err := getVersion(client) require.NoError(t, err) envVars := []string{ @@ -77,27 +71,16 @@ func runCreateIndicesWithILM(t *testing.T, ilmPolicyName string) { envVars = append(envVars, "ES_ILM_POLICY_NAME="+ilmPolicyName) } - if esVersion < 7 { - cleanES(t, client, "") - // Run the ES rollover test with adaptive sampling disabled (set to false). - err := runEsRollover("init", envVars, false) - require.EqualError(t, err, "exit status 1") - indices, err1 := client.IndexNames() - require.NoError(t, err1) - assert.Empty(t, indices) - - } else { - expectedIndices := []string{"jaeger-span-000001", "jaeger-service-000001", "jaeger-dependencies-000001"} - t.Run("NoPrefix", func(t *testing.T) { - runIndexRolloverWithILMTest(t, client, "", expectedIndices, envVars, ilmPolicyName, false) - }) - t.Run("WithPrefix", func(t *testing.T) { - runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, false) - }) - t.Run("WithAdaptiveSampling", func(t *testing.T) { - runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, true) - }) - } + expectedIndices := []string{"jaeger-span-000001", "jaeger-service-000001", "jaeger-dependencies-000001"} + t.Run("NoPrefix", func(t *testing.T) { + runIndexRolloverWithILMTest(t, client, "", expectedIndices, envVars, ilmPolicyName, false) + }) + t.Run("WithPrefix", func(t *testing.T) { + runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, false) + }) + t.Run("WithAdaptiveSampling", func(t *testing.T) { + runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, true) + }) } func runIndexRolloverWithILMTest(t *testing.T, client *elastic.Client, prefix string, expectedIndices, envVars []string, ilmPolicyName string, adaptiveSampling bool) { From 627da08bb75b9a1190b74bfcfacd4134e3a6be79 Mon Sep 17 00:00:00 2001 From: FlamingSaint Date: Tue, 14 May 2024 11:49:25 +0530 Subject: [PATCH 2/2] fix errors in CIT OpenSearch Signed-off-by: FlamingSaint --- .../integration/es_index_rollover_test.go | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/plugin/storage/integration/es_index_rollover_test.go b/plugin/storage/integration/es_index_rollover_test.go index 8428846ee9c..4effa952363 100644 --- a/plugin/storage/integration/es_index_rollover_test.go +++ b/plugin/storage/integration/es_index_rollover_test.go @@ -61,6 +61,7 @@ func TestIndexRollover_CreateIndicesWithILM(t *testing.T) { func runCreateIndicesWithILM(t *testing.T, ilmPolicyName string) { client, err := createESClient() require.NoError(t, err) + esVersion, err := getVersion(client) require.NoError(t, err) envVars := []string{ @@ -71,16 +72,18 @@ func runCreateIndicesWithILM(t *testing.T, ilmPolicyName string) { envVars = append(envVars, "ES_ILM_POLICY_NAME="+ilmPolicyName) } - expectedIndices := []string{"jaeger-span-000001", "jaeger-service-000001", "jaeger-dependencies-000001"} - t.Run("NoPrefix", func(t *testing.T) { - runIndexRolloverWithILMTest(t, client, "", expectedIndices, envVars, ilmPolicyName, false) - }) - t.Run("WithPrefix", func(t *testing.T) { - runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, false) - }) - t.Run("WithAdaptiveSampling", func(t *testing.T) { - runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, true) - }) + if esVersion >= 7 { + expectedIndices := []string{"jaeger-span-000001", "jaeger-service-000001", "jaeger-dependencies-000001"} + t.Run("NoPrefix", func(t *testing.T) { + runIndexRolloverWithILMTest(t, client, "", expectedIndices, envVars, ilmPolicyName, false) + }) + t.Run("WithPrefix", func(t *testing.T) { + runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, false) + }) + t.Run("WithAdaptiveSampling", func(t *testing.T) { + runIndexRolloverWithILMTest(t, client, indexPrefix, expectedIndices, append(envVars, "INDEX_PREFIX="+indexPrefix), ilmPolicyName, true) + }) + } } func runIndexRolloverWithILMTest(t *testing.T, client *elastic.Client, prefix string, expectedIndices, envVars []string, ilmPolicyName string, adaptiveSampling bool) {