Add method and subpath flags to timetrigger object for triggering a function (#3017)
* Update timetrigger crd and add method and subpath fields in spec. Update fission-cli to accept user input for method and subpath fields. Update publisher package to utilize these fields for triggering a function. Update timer controller to use method and subpath fields for publishing a request. Add a new test TestPublisherSubpath in pulisher package. Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Use kubebuilder default annotation. Update test for fission-cli timetrigger create, update command to support method and subpath flags. Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> --------- Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
This commit is contained in:
@@ -29,6 +29,28 @@ func TestPublisher(t *testing.T) {
|
||||
}
|
||||
|
||||
wp := MakeWebhookPublisher(logger, s.URL)
|
||||
wp.Publish(ctx, "", map[string]string{"X-Fission-Test": "aaa"}, fnName)
|
||||
wp.Publish(ctx, "", map[string]string{"X-Fission-Test": "aaa"}, http.MethodPost, fnName)
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
func TestPublisherSubpath(t *testing.T) {
|
||||
subpath := "/api/v1/read"
|
||||
fnName := "test-fn-subpath"
|
||||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
assert.Equal(t, "/"+fnName+subpath, r.URL.Path)
|
||||
assert.Equal(t, "aaa", r.Header.Get("X-Fission-Test"))
|
||||
assert.Contains(t, r.Header, "Traceparent")
|
||||
}))
|
||||
|
||||
ctx := context.Background()
|
||||
logger := loggerfactory.GetLogger()
|
||||
shutdown, err := otelUtils.InitProvider(ctx, logger, fnName)
|
||||
assert.NoError(t, err)
|
||||
if shutdown != nil {
|
||||
defer shutdown(ctx)
|
||||
}
|
||||
|
||||
wp := MakeWebhookPublisher(logger, s.URL)
|
||||
wp.Publish(ctx, "", map[string]string{"X-Fission-Test": "aaa"}, http.MethodGet, fnName+subpath)
|
||||
time.Sleep(time.Second * 1)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user