Skip to content

Commit ae4c46f

Browse files
committed
Merge functionaltests-7to8
1 parent a5ddecf commit ae4c46f

25 files changed

+828
-210
lines changed

.github/workflows/functional-tests.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
- '8.17'
3333
- '8.18'
3434
- '8.19'
35+
- '8.x' # Latest 8 version
3536
- '9.0'
3637
- '9.1'
3738
steps:
@@ -59,7 +60,7 @@ jobs:
5960
export TF_VAR_CREATED_DATE=$(date +%s)
6061
VERSION="${{ matrix.active-version }}"
6162
VERSION="${VERSION//./_}"
62-
go test -run="_to_${VERSION}" -v -timeout=30m -cleanup-on-failure=false -target="${{ matrix.environment }}" ./
63+
go test -run="(_to_${VERSION}$|_to_${VERSION}__)" -v -timeout=40m -target="${{ matrix.environment }}" ./
6364
6465
# notify:
6566
# if: always()

functionaltests/8_16_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,6 @@ package functionaltests
1919

2020
import (
2121
"testing"
22-
23-
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
2422
)
2523

2624
// In 8.15, the data stream management was migrated from ILM to DSL.
@@ -31,13 +29,13 @@ import (
3129
// reverted back to ILM in 8.17. Therefore, data streams created in 8.15 and
3230
// 8.16 are managed by DSL instead of ILM.
3331

34-
func TestUpgrade_8_15_to_8_16_Snapshot(t *testing.T) {
32+
func TestUpgrade_8_15_to_8_16__Snapshot(t *testing.T) {
3533
t.Parallel()
3634

3735
scenarios := basicUpgradeLazyRolloverDSLTestScenarios(
3836
getLatestSnapshot(t, "8.15"),
3937
getLatestSnapshot(t, "8.16"),
40-
[]types.Query{
38+
apmErrorLogs{
4139
tlsHandshakeError,
4240
esReturnedUnknown503,
4341
preconditionFailed,
@@ -56,13 +54,13 @@ func TestUpgrade_8_15_to_8_16_Snapshot(t *testing.T) {
5654
}
5755
}
5856

59-
func TestUpgrade_8_15_to_8_16_BC(t *testing.T) {
57+
func TestUpgrade_8_15_to_8_16__BC(t *testing.T) {
6058
t.Parallel()
6159

6260
scenarios := basicUpgradeLazyRolloverDSLTestScenarios(
6361
getLatestVersionOrSkip(t, "8.15"),
6462
getLatestBCOrSkip(t, "8.16"),
65-
[]types.Query{
63+
apmErrorLogs{
6664
tlsHandshakeError,
6765
esReturnedUnknown503,
6866
preconditionFailed,

functionaltests/8_17_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ package functionaltests
2020
import (
2121
"testing"
2222

23-
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
24-
2523
"github.com/elastic/apm-server/functionaltests/internal/asserts"
2624
)
2725

@@ -33,7 +31,7 @@ import (
3331
// reverted back to ILM in 8.17. Therefore, data streams created in 8.15 and
3432
// 8.16 are managed by DSL instead of ILM.
3533

36-
func TestUpgrade_8_16_to_8_17_Snapshot(t *testing.T) {
34+
func TestUpgrade_8_16_to_8_17__Snapshot(t *testing.T) {
3735
t.Parallel()
3836

3937
scenarios := allBasicUpgradeScenarios(
@@ -64,7 +62,7 @@ func TestUpgrade_8_16_to_8_17_Snapshot(t *testing.T) {
6462
IndicesPerDS: 2,
6563
IndicesManagedBy: []string{managedByDSL, managedByILM},
6664
},
67-
[]types.Query{
65+
apmErrorLogs{
6866
tlsHandshakeError,
6967
esReturnedUnknown503,
7068
refreshCache503,
@@ -80,7 +78,7 @@ func TestUpgrade_8_16_to_8_17_Snapshot(t *testing.T) {
8078
}
8179
}
8280

83-
func TestUpgrade_8_16_to_8_17_BC(t *testing.T) {
81+
func TestUpgrade_8_16_to_8_17__BC(t *testing.T) {
8482
t.Parallel()
8583

8684
scenarios := allBasicUpgradeScenarios(
@@ -111,7 +109,7 @@ func TestUpgrade_8_16_to_8_17_BC(t *testing.T) {
111109
IndicesPerDS: 2,
112110
IndicesManagedBy: []string{managedByDSL, managedByILM},
113111
},
114-
[]types.Query{
112+
apmErrorLogs{
115113
tlsHandshakeError,
116114
esReturnedUnknown503,
117115
refreshCache503,

functionaltests/8_18_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@ package functionaltests
1919

2020
import (
2121
"testing"
22-
23-
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
2422
)
2523

26-
func TestUpgrade_8_17_to_8_18_Snapshot(t *testing.T) {
24+
func TestUpgrade_8_17_to_8_18__Snapshot(t *testing.T) {
2725
t.Parallel()
2826

2927
scenarios := basicUpgradeILMTestScenarios(
3028
getLatestSnapshot(t, "8.17"),
3129
getLatestSnapshot(t, "8.18"),
32-
[]types.Query{
30+
apmErrorLogs{
3331
tlsHandshakeError,
3432
esReturnedUnknown503,
3533
refreshCache503,
@@ -44,13 +42,13 @@ func TestUpgrade_8_17_to_8_18_Snapshot(t *testing.T) {
4442
}
4543
}
4644

47-
func TestUpgrade_8_17_to_8_18_BC(t *testing.T) {
45+
func TestUpgrade_8_17_to_8_18__BC(t *testing.T) {
4846
t.Parallel()
4947

5048
scenarios := basicUpgradeILMTestScenarios(
5149
getLatestVersionOrSkip(t, "8.17"),
5250
getLatestBCOrSkip(t, "8.18"),
53-
[]types.Query{
51+
apmErrorLogs{
5452
tlsHandshakeError,
5553
esReturnedUnknown503,
5654
refreshCache503,

functionaltests/8_19_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,20 @@ package functionaltests
1919

2020
import (
2121
"testing"
22-
23-
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
2422
)
2523

2624
// Data streams get marked for lazy rollover by ES when something
2725
// changed in the underlying template(s), which in this case is
2826
// the apm-data plugin update for 8.19 and 9.1:
2927
// https://github.com/elastic/elasticsearch/pull/119995.
3028

31-
func TestUpgrade_8_18_to_8_19_Snapshot(t *testing.T) {
29+
func TestUpgrade_8_18_to_8_19__Snapshot(t *testing.T) {
3230
t.Parallel()
3331

3432
scenarios := basicUpgradeLazyRolloverILMTestScenarios(
3533
getLatestSnapshot(t, "8.18"),
3634
getLatestSnapshot(t, "8.19"),
37-
[]types.Query{
35+
apmErrorLogs{
3836
tlsHandshakeError,
3937
esReturnedUnknown503,
4038
refreshCache503,
@@ -49,13 +47,13 @@ func TestUpgrade_8_18_to_8_19_Snapshot(t *testing.T) {
4947
}
5048
}
5149

52-
func TestUpgrade_8_18_to_8_19_BC(t *testing.T) {
50+
func TestUpgrade_8_18_to_8_19__BC(t *testing.T) {
5351
t.Parallel()
5452

5553
scenarios := basicUpgradeLazyRolloverILMTestScenarios(
5654
getLatestVersionOrSkip(t, "8.18"),
5755
getLatestBCOrSkip(t, "8.19"),
58-
[]types.Query{
56+
apmErrorLogs{
5957
tlsHandshakeError,
6058
esReturnedUnknown503,
6159
refreshCache503,

functionaltests/8_x_test.go

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
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/apm-server/functionaltests/internal/asserts"
24+
"github.com/elastic/apm-server/functionaltests/internal/ecclient"
25+
)
26+
27+
func TestUpgrade_7_17_to_8_x__Snapshot_Standalone_to_Managed(t *testing.T) {
28+
fromVersion := getLatestSnapshot(t, "7.17")
29+
toVersion := getLatestSnapshot(t, "8")
30+
31+
t.Run("UpgradeFirst", func(t *testing.T) {
32+
t.Parallel()
33+
runner := upgradeThenManaged78Runner(fromVersion, toVersion)
34+
runner.Run(t)
35+
})
36+
37+
t.Run("ManagedFirst", func(t *testing.T) {
38+
t.Parallel()
39+
runner := managedThenUpgrade78Runner(fromVersion, toVersion)
40+
runner.Run(t)
41+
})
42+
}
43+
44+
func TestUpgrade_7_17_to_8_x__BC_Standalone_to_Managed(t *testing.T) {
45+
fromVersion := getLatestVersionOrSkip(t, "7.17")
46+
toVersion := getLatestBCOrSkip(t, "8")
47+
48+
t.Run("UpgradeFirst", func(t *testing.T) {
49+
t.Parallel()
50+
runner := upgradeThenManaged78Runner(fromVersion, toVersion)
51+
runner.Run(t)
52+
})
53+
54+
t.Run("ManagedFirst", func(t *testing.T) {
55+
t.Parallel()
56+
runner := managedThenUpgrade78Runner(fromVersion, toVersion)
57+
runner.Run(t)
58+
})
59+
}
60+
61+
func upgradeThenManaged78Runner(fromVersion, toVersion ecclient.StackVersion) testStepsRunner {
62+
// Data streams in 8.x should be all ILM if upgraded to a stack < 8.15 and > 8.16.
63+
checkILM := asserts.CheckDataStreamsWant{
64+
Quantity: 8,
65+
PreferIlm: true,
66+
DSManagedBy: managedByILM,
67+
IndicesPerDS: 1,
68+
IndicesManagedBy: []string{managedByILM},
69+
}
70+
71+
return testStepsRunner{
72+
Steps: []testStep{
73+
createStep{
74+
DeployVersion: fromVersion,
75+
APMDeploymentMode: apmStandalone,
76+
},
77+
ingestLegacyStep{},
78+
upgradeLegacyStep{NewVersion: toVersion},
79+
ingestStep{CheckDataStream: checkILM},
80+
migrateManagedStep{},
81+
ingestStep{CheckDataStream: checkILM},
82+
checkErrorLogsStep{
83+
ESErrorLogsIgnored: esErrorLogs{
84+
eventLoopShutdown,
85+
},
86+
APMErrorLogsIgnored: apmErrorLogs{
87+
tlsHandshakeError,
88+
esReturnedUnknown503,
89+
refreshCache503,
90+
// TODO: remove once fixed
91+
populateSourcemapFetcher403,
92+
},
93+
},
94+
},
95+
}
96+
}
97+
98+
func managedThenUpgrade78Runner(fromVersion, toVersion ecclient.StackVersion) testStepsRunner {
99+
checkILM := asserts.CheckDataStreamIndividualWant{
100+
PreferIlm: true,
101+
DSManagedBy: managedByILM,
102+
IndicesManagedBy: []string{managedByILM},
103+
}
104+
checkILMRollover := asserts.CheckDataStreamIndividualWant{
105+
PreferIlm: true,
106+
DSManagedBy: managedByILM,
107+
IndicesManagedBy: []string{managedByILM, managedByILM},
108+
}
109+
110+
check := map[string]asserts.CheckDataStreamIndividualWant{
111+
// These data streams are created in 7.x as well, so when we ingest again
112+
// in 8.x, they will be rolled-over.
113+
"traces-apm-%s": checkILMRollover,
114+
"metrics-apm.app.opbeans_python-%s": checkILMRollover,
115+
"metrics-apm.internal-%s": checkILMRollover,
116+
"logs-apm.error-%s": checkILMRollover,
117+
// These data streams are only created in 8.x, so they will only have 1 index.
118+
"metrics-apm.service_destination.1m-%s": checkILM,
119+
"metrics-apm.service_transaction.1m-%s": checkILM,
120+
"metrics-apm.service_summary.1m-%s": checkILM,
121+
"metrics-apm.transaction.1m-%s": checkILM,
122+
}
123+
124+
// These data streams are created in 7.x, but not used in 8.x,
125+
// so we ignore them to avoid wrong assertions.
126+
ignoredDataStreams := []string{
127+
"metrics-apm.app.opbeans_node-%s",
128+
"metrics-apm.app.opbeans_ruby-%s",
129+
"metrics-apm.app.opbeans_go-%s",
130+
}
131+
132+
return testStepsRunner{
133+
Steps: []testStep{
134+
createStep{
135+
DeployVersion: fromVersion,
136+
APMDeploymentMode: apmStandalone,
137+
},
138+
ingestLegacyStep{},
139+
migrateManagedStep{},
140+
ingestLegacyStep{},
141+
upgradeLegacyStep{NewVersion: toVersion},
142+
ingestStep{
143+
IgnoreDataStreams: ignoredDataStreams,
144+
CheckIndividualDataStream: check,
145+
},
146+
checkErrorLogsStep{
147+
ESErrorLogsIgnored: esErrorLogs{
148+
eventLoopShutdown,
149+
addIndexTemplateTracesError,
150+
},
151+
APMErrorLogsIgnored: apmErrorLogs{
152+
tlsHandshakeError,
153+
esReturnedUnknown503,
154+
refreshCache503,
155+
preconditionClusterInfoCtxCanceled,
156+
waitServerReadyCtxCanceled,
157+
grpcServerStopped,
158+
// TODO: remove once fixed
159+
populateSourcemapFetcher403,
160+
},
161+
},
162+
},
163+
}
164+
}

functionaltests/9_0_test.go

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,15 @@ package functionaltests
1919

2020
import (
2121
"testing"
22-
23-
"github.com/elastic/go-elasticsearch/v8/typedapi/types"
2422
)
2523

26-
func TestUpgrade_8_18_to_9_0_Snapshot(t *testing.T) {
24+
func TestUpgrade_8_18_to_9_0__Snapshot(t *testing.T) {
2725
t.Parallel()
2826

2927
scenarios := basicUpgradeILMTestScenarios(
3028
getLatestSnapshot(t, "8.18"),
3129
getLatestSnapshot(t, "9.0"),
32-
[]types.Query{
30+
apmErrorLogs{
3331
tlsHandshakeError,
3432
esReturnedUnknown503,
3533
refreshCache503,
@@ -45,13 +43,13 @@ func TestUpgrade_8_18_to_9_0_Snapshot(t *testing.T) {
4543
}
4644
}
4745

48-
func TestUpgrade_8_18_to_9_0_BC(t *testing.T) {
46+
func TestUpgrade_8_18_to_9_0__BC(t *testing.T) {
4947
t.Parallel()
5048

5149
scenarios := basicUpgradeILMTestScenarios(
5250
getLatestVersionOrSkip(t, "8.18"),
5351
getLatestBCOrSkip(t, "9.0"),
54-
[]types.Query{
52+
apmErrorLogs{
5553
tlsHandshakeError,
5654
esReturnedUnknown503,
5755
refreshCache503,

0 commit comments

Comments
 (0)