-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #890 from jhadvig/CONSOLE-3943
CONSOLE-3943: Default telemetry values
- Loading branch information
Showing
6 changed files
with
137 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
namespace: openshift-console-operator | ||
name: telemetry-config | ||
annotations: | ||
include.release.openshift.io/hypershift: "true" | ||
include.release.openshift.io/ibm-cloud-managed: "true" | ||
include.release.openshift.io/self-managed-high-availability: "true" | ||
include.release.openshift.io/single-node-developer: "true" | ||
capability.openshift.io/name: Console | ||
data: | ||
SEGMENT_API_HOST: console.redhat.com/connections/api/v1 | ||
SEGMENT_JS_HOST: console.redhat.com/connections/cdn | ||
SEGMENT_PUBLIC_API_KEY: BnuS1RP39EmLQjP21ko67oDjhbl9zpNU |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
operatorsv1 "github.com/openshift/api/operator/v1" | ||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||
"k8s.io/apimachinery/pkg/types" | ||
"k8s.io/apimachinery/pkg/util/wait" | ||
|
||
"github.com/openshift/console-operator/pkg/api" | ||
"github.com/openshift/console-operator/pkg/console/telemetry" | ||
"github.com/openshift/console-operator/test/e2e/framework" | ||
) | ||
|
||
const ( | ||
SEGMENT_API_HOST = "SEGMENT_API_HOST" | ||
) | ||
|
||
func setupTelemetryConfigTestCase(t *testing.T) (*framework.ClientSet, *operatorsv1.Console) { | ||
return framework.StandardSetup(t) | ||
} | ||
|
||
func cleanupTelemetryConfigTestCase(t *testing.T, client *framework.ClientSet) { | ||
framework.StandardCleanup(t, client) | ||
} | ||
|
||
func TestTelemetryConfig(t *testing.T) { | ||
client, _ := setupDownloadsTestCase(t) | ||
defer cleanupDownloadsTestCase(t, client) | ||
telemetryConfigMap, err := client.Core.ConfigMaps(api.OpenShiftConsoleOperatorNamespace).Get(context.TODO(), telemetry.TelemetryConfigMapName, v1.GetOptions{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if len(telemetryConfigMap.Data) == 0 { | ||
t.Fatal("telemetry-config configmap is empty") | ||
} | ||
|
||
// check default value for SEGMENT_API_HOST key | ||
value, ok := telemetryConfigMap.Data[SEGMENT_API_HOST] | ||
if !ok { | ||
t.Fatalf("telemetry-config configmap does not contain SEGMENT_JS_HOST data key. Instead contains: %v", telemetryConfigMap.Data) | ||
} | ||
if value != "console.redhat.com/connections/api/v1" { | ||
t.Fatalf("telemetry-config configmap does not contain SEGMENT_API_HOST key with value 'console.redhat.com/connections/api/v1'. Instead contains: %q", value) | ||
} | ||
|
||
// update the defaul value for SEGMENT_API_HOST key | ||
_, err = client.Core.ConfigMaps(api.OpenShiftConsoleOperatorNamespace).Patch(context.TODO(), telemetry.TelemetryConfigMapName, types.MergePatchType, []byte(`{"data": {"SEGMENT_API_HOST": "test"}}`), metav1.PatchOptions{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
err = wait.Poll(1*time.Second, framework.AsyncOperationTimeout, func() (stop bool, err error) { | ||
telemetryConfigMap, err := client.Core.ConfigMaps(api.OpenShiftConsoleOperatorNamespace).Get(context.TODO(), telemetry.TelemetryConfigMapName, v1.GetOptions{}) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
value, ok := telemetryConfigMap.Data[SEGMENT_API_HOST] | ||
if !ok { | ||
return false, fmt.Errorf("updated telemetry-config configmap does not contain SEGMENT_JS_HOST data key. Instead contains: %v", telemetryConfigMap.Data) | ||
} | ||
if value != "test" { | ||
return false, fmt.Errorf("update telemetry-config configmap does not contain SEGMENT_API_HOST key with value 'console.redhat.com/connections/api/v1'. Instead contains: %q", value) | ||
} | ||
|
||
return true, nil | ||
}) | ||
|
||
} |