Skip to content

Commit a748078

Browse files
authored
upgrade: add test for version 0.110.0 (#3365)
Signed-off-by: Benedikt Bongartz <[email protected]>
1 parent eeaa19e commit a748078

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed
+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
// Copyright The OpenTelemetry Authors
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package upgrade_test
16+
17+
import (
18+
"context"
19+
"testing"
20+
21+
"github.com/stretchr/testify/assert"
22+
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23+
"k8s.io/client-go/tools/record"
24+
25+
"github.com/open-telemetry/opentelemetry-operator/apis/v1beta1"
26+
"github.com/open-telemetry/opentelemetry-operator/pkg/collector/upgrade"
27+
)
28+
29+
func Test0_110_0Upgrade(t *testing.T) {
30+
collectorInstance := v1beta1.OpenTelemetryCollector{
31+
TypeMeta: metav1.TypeMeta{
32+
Kind: "OpenTelemetryCollector",
33+
APIVersion: "v1beta1",
34+
},
35+
ObjectMeta: metav1.ObjectMeta{
36+
Name: "otel-my-instance",
37+
Namespace: "somewhere",
38+
},
39+
Status: v1beta1.OpenTelemetryCollectorStatus{
40+
Version: "0.104.0",
41+
},
42+
Spec: v1beta1.OpenTelemetryCollectorSpec{
43+
OpenTelemetryCommonFields: v1beta1.OpenTelemetryCommonFields{
44+
Args: map[string]string{
45+
"foo": "bar",
46+
"feature-gates": "+baz,-component.UseLocalHostAsDefaultHost",
47+
},
48+
},
49+
Config: v1beta1.Config{},
50+
},
51+
}
52+
53+
versionUpgrade := &upgrade.VersionUpgrade{
54+
Log: logger,
55+
Version: makeVersion("0.110.0"),
56+
Client: k8sClient,
57+
Recorder: record.NewFakeRecorder(upgrade.RecordBufferSize),
58+
}
59+
60+
col, err := versionUpgrade.ManagedInstance(context.Background(), collectorInstance)
61+
if err != nil {
62+
t.Errorf("expect err: nil but got: %v", err)
63+
}
64+
assert.EqualValues(t,
65+
map[string]string{"foo": "bar", "feature-gates": "+baz"}, col.Spec.Args)
66+
}

0 commit comments

Comments
 (0)