-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enables publishing to various topics according to annotations on the functions. The function cache is moved up one level so that it can be shared between the scale from zero code and the queue proxy. Unit tests added for new internal methods. Tested e2e with arkade and the newest queue-worker and RC gateway image with two queues and an annotation on one of the functions of com.openfaas.queue. It worked as expected including with multiple namespace support. Signed-off-by: Alex Ellis (OpenFaaS Ltd) <alexellis2@gmail.com>
- Loading branch information
Showing
22 changed files
with
264 additions
and
106 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,74 @@ | ||
// Copyright (c) Alex Ellis 2017. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
package handlers | ||
|
||
import ( | ||
"net/http" | ||
"testing" | ||
) | ||
|
||
func Test_getNameParts(t *testing.T) { | ||
fn, ns := getNameParts("figlet.openfaas-fn") | ||
wantFn := "figlet" | ||
wantNs := "openfaas-fn" | ||
|
||
if fn != wantFn { | ||
t.Fatalf("want %s, got %s", wantFn, fn) | ||
} | ||
if ns != wantNs { | ||
t.Fatalf("want %s, got %s", wantNs, ns) | ||
} | ||
} | ||
|
||
func Test_getNamePartsDualDot(t *testing.T) { | ||
fn, ns := getNameParts("dev.figlet.openfaas-fn") | ||
wantFn := "dev.figlet" | ||
wantNs := "openfaas-fn" | ||
|
||
if fn != wantFn { | ||
t.Fatalf("want %s, got %s", wantFn, fn) | ||
} | ||
if ns != wantNs { | ||
t.Fatalf("want %s, got %s", wantNs, ns) | ||
} | ||
} | ||
|
||
func Test_getNameParts_NoNs(t *testing.T) { | ||
fn, ns := getNameParts("figlet") | ||
wantFn := "figlet" | ||
wantNs := "" | ||
|
||
if fn != wantFn { | ||
t.Fatalf("want %s, got %s", wantFn, fn) | ||
} | ||
if ns != wantNs { | ||
t.Fatalf("want %s, got %s", wantNs, ns) | ||
} | ||
} | ||
|
||
func Test_getCallbackURLHeader(t *testing.T) { | ||
want := "http://localhost:8080" | ||
header := http.Header{} | ||
header.Add("X-Callback-Url", want) | ||
|
||
uri, err := getCallbackURLHeader(header) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
if uri.String() != want { | ||
t.Fatalf("want %s, but got %s", want, uri.String()) | ||
} | ||
} | ||
|
||
func Test_getCallbackURLHeader_ParseFails(t *testing.T) { | ||
want := "ht tp://foo.com" | ||
header := http.Header{} | ||
header.Add("X-Callback-Url", want) | ||
|
||
_, err := getCallbackURLHeader(header) | ||
if err == nil { | ||
t.Fatal("wanted a parsing error.") | ||
} | ||
} |
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
Oops, something went wrong.