Skip to content
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
7 changes: 7 additions & 0 deletions test/e2e/fixture/fixture.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const (
ArgoCDNamespace = "argocd-e2e"
ArgoCDAppNamespace = "argocd-e2e-external"

// notifications controller, metrics server port
defaultNotificationServer = "localhost:9001"

// ensure all repos are in one directory tree, so we can easily clean them up
TmpDir = "/tmp/argo-e2e"
repoDir = "testdata.git"
Expand Down Expand Up @@ -1020,6 +1023,10 @@ func GetApiServerAddress() string {
return apiServerAddress
}

func GetNotificationServerAddress() string {
return defaultNotificationServer
}

func GetToken() string {
return token
}
10 changes: 7 additions & 3 deletions test/e2e/fixture/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,17 @@ import (
)

// DoHttpRequest executes a http request against the Argo CD API server
func DoHttpRequest(method string, path string, data ...byte) (*http.Response, error) {
func DoHttpRequest(method string, path string, host string, data ...byte) (*http.Response, error) {
reqUrl, err := url.Parse(path)
if err != nil {
return nil, err
}
reqUrl.Scheme = "http"
reqUrl.Host = apiServerAddress
if host != "" {
reqUrl.Host = host
} else {
reqUrl.Host = apiServerAddress
}
var body io.Reader
if data != nil {
body = bytes.NewReader(data)
Expand All @@ -41,7 +45,7 @@ func DoHttpRequest(method string, path string, data ...byte) (*http.Response, er

// DoHttpJsonRequest executes a http request against the Argo CD API server and unmarshals the response body as JSON
func DoHttpJsonRequest(method string, path string, result interface{}, data ...byte) error {
resp, err := DoHttpRequest(method, path, data...)
resp, err := DoHttpRequest(method, path, "", data...)
if err != nil {
return err
}
Expand Down
11 changes: 11 additions & 0 deletions test/e2e/fixture/notification/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
// using the Then()
type Actions struct {
context *Context

healthy bool
}

func (a *Actions) SetParamInNotificationConfigMap(key, value string) *Actions {
Expand All @@ -25,3 +27,12 @@ func (a *Actions) Then() *Consequences {
time.Sleep(1 * time.Second)
return &Consequences{a.context, a}
}

func (a *Actions) Healthcheck() *Actions {
a.context.t.Helper()
_, err := fixture.DoHttpRequest("GET",
"/metrics",
fixture.GetNotificationServerAddress())
a.healthy = err == nil
return a
}
6 changes: 6 additions & 0 deletions test/e2e/fixture/notification/consequences.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ func (c *Consequences) Services(block func(services *notification.ServiceList, e
return c
}

func (c *Consequences) Healthy(block func(healthy bool)) *Consequences {
c.context.t.Helper()
block(c.actions.healthy)
return c
}

func (c *Consequences) Triggers(block func(services *notification.TriggerList, err error)) *Consequences {
c.context.t.Helper()
block(c.listTriggers())
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/notification_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,13 @@ func TestNotificationsListTriggers(t *testing.T) {
assert.Equal(t, []*notification.Trigger{{Name: ptr.To("on-created")}}, triggers.Items)
})
}

func TestNotificationsHealthcheck(t *testing.T) {
ctx := notifFixture.Given(t)
ctx.When().
Healthcheck().
Then().
Healthy(func(healthy bool) {
assert.True(t, healthy)
})
}