Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add trace and timeout support for the timer (#2750)
* feat: add trace and timeout support for the timer Co-authored-by: gw123 <iamakillerforyou@gmail.com> Signed-off-by: saltbo <saltbo@foxmail.com> * fix: add error check for the lint Signed-off-by: saltbo <saltbo@foxmail.com> --------- Signed-off-by: saltbo <saltbo@foxmail.com> Co-authored-by: gw123 <iamakillerforyou@gmail.com>
- Loading branch information
Showing
5 changed files
with
61 additions
and
7 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
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,34 @@ | ||
package publisher | ||
|
||
import ( | ||
"context" | ||
"net/http" | ||
"net/http/httptest" | ||
"testing" | ||
"time" | ||
|
||
"github.com/fission/fission/pkg/utils/loggerfactory" | ||
otelUtils "github.com/fission/fission/pkg/utils/otel" | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestPublisher(t *testing.T) { | ||
fnName := "test-fn" | ||
s := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
assert.Equal(t, "/"+fnName, 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"}, fnName) | ||
time.Sleep(time.Second * 1) | ||
} |
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