Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions test/upgrade/prober/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,27 @@ var eventTypes = []string{"step", "finished"}

// Config represents a configuration for prober.
type Config struct {
Wathola WatholaConfig
Wathola
Namespace string
Interval time.Duration
FinishedSleep time.Duration
Serving ServingConfig
FailOnErrors bool
}

// WatholaConfig represents options related strictly to wathola testing tool.
type WatholaConfig struct {
Config ConfigMapConfig
// Wathola represents options related strictly to wathola testing tool.
type Wathola struct {
ConfigMap
EventsTypePrefix string
HealthEndpoint string
BrokerName string
}

// ConfigMapConfig represents options of wathola config toml file.
type ConfigMapConfig struct {
Name string
MountPoint string
Filename string
// ConfigMap represents options of wathola config toml file.
type ConfigMap struct {
ConfigMapName string
ConfigMountPoint string
ConfigFilename string
}

// ServingConfig represents a options for serving test component (wathola-forwarder).
Expand All @@ -91,11 +91,11 @@ func NewConfig(namespace string) *Config {
Use: false,
ScaleToZero: true,
},
Wathola: WatholaConfig{
Config: ConfigMapConfig{
Name: defaultConfigName,
MountPoint: fmt.Sprintf("%s/%s", defaultHomedir, defaultConfigHomedirPath),
Filename: defaultConfigFilename,
Wathola: Wathola{
ConfigMap: ConfigMap{
ConfigMapName: defaultConfigName,
ConfigMountPoint: fmt.Sprintf("%s/%s", defaultHomedir, defaultConfigHomedirPath),
ConfigFilename: defaultConfigFilename,
},
EventsTypePrefix: defaultWatholaEventsPrefix,
HealthEndpoint: defaultHealthEndpoint,
Expand All @@ -119,53 +119,53 @@ func (p *prober) deployConfiguration() {
}

func (p *prober) deployBroker() {
p.client.CreateBrokerV1Beta1OrFail(p.config.Wathola.BrokerName)
p.client.CreateBrokerV1Beta1OrFail(p.config.BrokerName)
}

func (p *prober) fetchBrokerURL() (*apis.URL, error) {
namespace := p.config.Namespace
p.log.Debugf("Fetching %s broker URL for ns %s",
p.config.Wathola.BrokerName, namespace)
p.config.BrokerName, namespace)
meta := resources.NewMetaResource(
p.config.Wathola.BrokerName, p.config.Namespace, testlib.BrokerTypeMeta,
p.config.BrokerName, p.config.Namespace, testlib.BrokerTypeMeta,
)
err := duck.WaitForResourceReady(p.client.Dynamic, meta)
if err != nil {
return nil, err
}
broker, err := p.client.Eventing.EventingV1beta1().Brokers(namespace).Get(
p.config.Wathola.BrokerName, metav1.GetOptions{},
p.config.BrokerName, metav1.GetOptions{},
)
if err != nil {
return nil, err
}
url := broker.Status.Address.URL
p.log.Debugf("%s broker URL for ns %s is %v",
p.config.Wathola.BrokerName, namespace, url)
p.config.BrokerName, namespace, url)
return url, nil
}

func (p *prober) deployConfigMap() {
name := p.config.Wathola.Config.Name
name := p.config.ConfigMapName
p.log.Infof("Deploying config map: \"%s/%s\"", p.config.Namespace, name)
brokerURL, err := p.fetchBrokerURL()
ensure.NoError(err)
configData := p.compileTemplate(p.config.Wathola.Config.Filename, brokerURL)
configData := p.compileTemplate(p.config.ConfigFilename, brokerURL)
p.client.CreateConfigMapOrFail(name, p.config.Namespace, map[string]string{
p.config.Wathola.Config.Filename: configData,
p.config.ConfigFilename: configData,
})
}

func (p *prober) deployTriggers() {
for _, eventType := range eventTypes {
name := fmt.Sprintf("wathola-trigger-%v", eventType)
fullType := fmt.Sprintf("%v.%v", p.config.Wathola.EventsTypePrefix, eventType)
fullType := fmt.Sprintf("%v.%v", p.config.EventsTypePrefix, eventType)
subscriberOption := resources.WithSubscriberServiceRefForTriggerV1Beta1(receiverName)
if p.config.Serving.Use {
subscriberOption = resources.WithSubscriberKServiceRefForTrigger(forwarderName)
}
p.client.CreateTriggerOrFailV1Beta1(name,
resources.WithBrokerV1Beta1(p.config.Wathola.BrokerName),
resources.WithBrokerV1Beta1(p.config.BrokerName),
resources.WithAttributesTriggerFilterV1Beta1(
eventingv1beta1.TriggerAnyFilter,
fullType,
Expand Down
10 changes: 5 additions & 5 deletions test/upgrade/prober/forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,20 @@ func (p *prober) forwarderKService(name, namespace string) *unstructured.Unstruc
"name": "forwarder",
"image": pkgTest.ImagePath(forwarderName),
"volumeMounts": []map[string]interface{}{{
"name": p.config.Wathola.Config.Name,
"mountPath": p.config.Wathola.Config.MountPoint,
"name": p.config.ConfigMapName,
"mountPath": p.config.ConfigMountPoint,
"readOnly": true,
}},
"readinessProbe": map[string]interface{}{
"httpGet": map[string]interface{}{
"path": p.config.Wathola.HealthEndpoint,
"path": p.config.HealthEndpoint,
},
},
}},
"volumes": []map[string]interface{}{{
"name": p.config.Wathola.Config.Name,
"name": p.config.ConfigMapName,
"configMap": map[string]interface{}{
"name": p.config.Wathola.Config.Name,
"name": p.config.ConfigMapName,
},
}},
},
Expand Down
4 changes: 2 additions & 2 deletions test/upgrade/prober/prober_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
const (
defaultConfigFilename = "config.toml"
servingEnvName = "E2E_UPGRADE_TESTS_SERVING_USE"
configFilenameEnvName = "E2E_UPGRADE_TESTS_WATHOLA_CONFIG_FILENAME"
configFilenameEnvName = "E2E_UPGRADE_TESTS_CONFIGFILENAME"
)

func TestNewConfig(t *testing.T) {
Expand Down Expand Up @@ -57,7 +57,7 @@ func TestNewConfig(t *testing.T) {

assert.Equal(t, s.servingUse, config.Serving.Use)
assert.True(t, config.Serving.ScaleToZero)
assert.Equal(t, s.configFilename, config.Wathola.Config.Filename)
assert.Equal(t, s.configFilename, config.ConfigFilename)
})
}
}
Expand Down
10 changes: 5 additions & 5 deletions test/upgrade/prober/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ func (p *prober) deployReceiverPod() {
Spec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
Name: p.config.Wathola.Config.Name,
Name: p.config.ConfigMapName,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: p.config.Wathola.Config.Name,
Name: p.config.ConfigMapName,
},
},
},
Expand All @@ -66,15 +66,15 @@ func (p *prober) deployReceiverPod() {
Image: pkgTest.ImagePath(receiverName),
VolumeMounts: []corev1.VolumeMount{
{
Name: p.config.Wathola.Config.Name,
Name: p.config.ConfigMapName,
ReadOnly: true,
MountPath: p.config.Wathola.Config.MountPoint,
MountPath: p.config.ConfigMountPoint,
},
},
ReadinessProbe: &corev1.Probe{
Handler: corev1.Handler{
HTTPGet: &corev1.HTTPGetAction{
Path: p.config.Wathola.HealthEndpoint,
Path: p.config.HealthEndpoint,
Port: intstr.FromInt(watholaconfig.DefaultReceiverPort),
},
},
Expand Down
8 changes: 4 additions & 4 deletions test/upgrade/prober/sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ func (p *prober) deploySender() {
Spec: corev1.PodSpec{
Volumes: []corev1.Volume{
{
Name: p.config.Wathola.Config.Name,
Name: p.config.ConfigMapName,
VolumeSource: corev1.VolumeSource{
ConfigMap: &corev1.ConfigMapVolumeSource{
LocalObjectReference: corev1.LocalObjectReference{
Name: p.config.Wathola.Config.Name,
Name: p.config.ConfigMapName,
},
},
},
Expand All @@ -53,9 +53,9 @@ func (p *prober) deploySender() {
Image: pkgTest.ImagePath(senderName),
VolumeMounts: []corev1.VolumeMount{
{
Name: p.config.Wathola.Config.Name,
Name: p.config.ConfigMapName,
ReadOnly: true,
MountPath: p.config.Wathola.Config.MountPoint,
MountPath: p.config.ConfigMountPoint,
},
},
},
Expand Down