|
| 1 | +// Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +// license agreements. See the NOTICE file distributed with |
| 3 | +// this work for additional information regarding copyright |
| 4 | +// ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +// the Apache License, Version 2.0 (the "License"); you may |
| 6 | +// not use this file except in compliance with the License. |
| 7 | +// You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package functionaltests |
| 19 | + |
| 20 | +import ( |
| 21 | + "testing" |
| 22 | + |
| 23 | + "github.com/elastic/go-elasticsearch/v8/typedapi/types" |
| 24 | + |
| 25 | + "github.com/elastic/apm-server/functionaltests/internal/asserts" |
| 26 | +) |
| 27 | + |
| 28 | +// In 8.15, the data stream management was migrated from ILM to DSL. |
| 29 | +// However, a bug was introduced, causing data streams to be unmanaged. |
| 30 | +// See https://github.com/elastic/apm-server/issues/13898. |
| 31 | +// |
| 32 | +// It was fixed by defaulting data stream management to DSL, and eventually |
| 33 | +// reverted back to ILM in 8.17. Therefore, data streams created in 8.15 and |
| 34 | +// 8.16 are managed by DSL instead of ILM. |
| 35 | + |
| 36 | +func TestUpgrade_8_16_to_8_17_Snapshot(t *testing.T) { |
| 37 | + t.Parallel() |
| 38 | + |
| 39 | + scenarios := allBasicUpgradeScenarios( |
| 40 | + getLatestSnapshot(t, "8.16"), |
| 41 | + getLatestSnapshot(t, "8.17"), |
| 42 | + // Data streams managed by DSL pre-upgrade. |
| 43 | + asserts.CheckDataStreamsWant{ |
| 44 | + Quantity: 8, |
| 45 | + PreferIlm: false, |
| 46 | + DSManagedBy: managedByDSL, |
| 47 | + IndicesPerDS: 1, |
| 48 | + IndicesManagedBy: []string{managedByDSL}, |
| 49 | + }, |
| 50 | + // Data streams managed by ILM post-upgrade. |
| 51 | + // However, the index created before upgrade is still managed by DSL. |
| 52 | + asserts.CheckDataStreamsWant{ |
| 53 | + Quantity: 8, |
| 54 | + PreferIlm: true, |
| 55 | + DSManagedBy: managedByILM, |
| 56 | + IndicesPerDS: 1, |
| 57 | + IndicesManagedBy: []string{managedByDSL}, |
| 58 | + }, |
| 59 | + // Verify lazy rollover happened, i.e. 2 indices. |
| 60 | + asserts.CheckDataStreamsWant{ |
| 61 | + Quantity: 8, |
| 62 | + PreferIlm: true, |
| 63 | + DSManagedBy: managedByILM, |
| 64 | + IndicesPerDS: 2, |
| 65 | + IndicesManagedBy: []string{managedByDSL, managedByILM}, |
| 66 | + }, |
| 67 | + []types.Query{ |
| 68 | + tlsHandshakeError, |
| 69 | + esReturnedUnknown503, |
| 70 | + refreshCache503, |
| 71 | + refreshCacheCtxCanceled, |
| 72 | + populateSourcemapFetcher403, |
| 73 | + }, |
| 74 | + ) |
| 75 | + for _, scenario := range scenarios { |
| 76 | + t.Run(scenario.Name, func(t *testing.T) { |
| 77 | + t.Parallel() |
| 78 | + scenario.Runner.Run(t) |
| 79 | + }) |
| 80 | + } |
| 81 | +} |
| 82 | + |
| 83 | +func TestUpgrade_8_16_to_8_17_BC(t *testing.T) { |
| 84 | + t.Parallel() |
| 85 | + |
| 86 | + scenarios := allBasicUpgradeScenarios( |
| 87 | + getLatestVersionOrSkip(t, "8.16"), |
| 88 | + getLatestBCOrSkip(t, "8.17"), |
| 89 | + // Data streams managed by DSL pre-upgrade. |
| 90 | + asserts.CheckDataStreamsWant{ |
| 91 | + Quantity: 8, |
| 92 | + PreferIlm: false, |
| 93 | + DSManagedBy: managedByDSL, |
| 94 | + IndicesPerDS: 1, |
| 95 | + IndicesManagedBy: []string{managedByDSL}, |
| 96 | + }, |
| 97 | + // Data streams managed by ILM post-upgrade. |
| 98 | + // However, the index created before upgrade is still managed by DSL. |
| 99 | + asserts.CheckDataStreamsWant{ |
| 100 | + Quantity: 8, |
| 101 | + PreferIlm: true, |
| 102 | + DSManagedBy: managedByILM, |
| 103 | + IndicesPerDS: 1, |
| 104 | + IndicesManagedBy: []string{managedByDSL}, |
| 105 | + }, |
| 106 | + // Verify lazy rollover happened, i.e. 2 indices. |
| 107 | + asserts.CheckDataStreamsWant{ |
| 108 | + Quantity: 8, |
| 109 | + PreferIlm: true, |
| 110 | + DSManagedBy: managedByILM, |
| 111 | + IndicesPerDS: 2, |
| 112 | + IndicesManagedBy: []string{managedByDSL, managedByILM}, |
| 113 | + }, |
| 114 | + []types.Query{ |
| 115 | + tlsHandshakeError, |
| 116 | + esReturnedUnknown503, |
| 117 | + refreshCache503, |
| 118 | + refreshCacheCtxCanceled, |
| 119 | + populateSourcemapFetcher403, |
| 120 | + }, |
| 121 | + ) |
| 122 | + for _, scenario := range scenarios { |
| 123 | + t.Run(scenario.Name, func(t *testing.T) { |
| 124 | + t.Parallel() |
| 125 | + scenario.Runner.Run(t) |
| 126 | + }) |
| 127 | + } |
| 128 | +} |
0 commit comments