mirror of
https://github.com/openfaas/faas.git
synced 2025-06-21 00:06:38 +00:00
Re-vendor queue-worker publisher for reconnect
- re-vendor queue-worker for publisher via 0.6.0 - bump queue-worker version to 0.6.0 in docker-compose.yml for AMD64 - use new naming for NATS of nats -> NATS in variables where required - add default reconnect of 60 times, 2 seconds apart. Signed-off-by: Alex Ellis (VMware) <alexellis2@gmail.com>
This commit is contained in:
committed by
Alex Ellis
parent
e63150ef70
commit
b4a550327d
96
gateway/vendor/github.com/openfaas/nats-queue-worker/readconfig_test.go
generated
vendored
Normal file
96
gateway/vendor/github.com/openfaas/nats-queue-worker/readconfig_test.go
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func Test_ReadConfig(t *testing.T) {
|
||||
|
||||
readConfig := ReadConfig{}
|
||||
|
||||
os.Setenv("faas_nats_address", "test_nats")
|
||||
os.Setenv("faas_gateway_address", "test_gatewayaddr")
|
||||
os.Setenv("faas_function_suffix", "test_suffix")
|
||||
os.Setenv("faas_print_body", "true")
|
||||
os.Setenv("write_debug", "true")
|
||||
os.Setenv("max_inflight", "10")
|
||||
os.Setenv("ack_wait", "10ms")
|
||||
|
||||
config := readConfig.Read()
|
||||
|
||||
expected := "test_nats"
|
||||
if config.NatsAddress != expected {
|
||||
t.Logf("Expected NatsAddress `%s` actual `%s`\n", expected, config.NatsAddress)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
expected = "test_gatewayaddr"
|
||||
if config.GatewayAddress != expected {
|
||||
t.Logf("Expected GatewayAddress `%s` actual `%s`\n", expected, config.GatewayAddress)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
expected = "test_suffix"
|
||||
if config.FunctionSuffix != expected {
|
||||
t.Logf("Expected FunctionSuffix `%s` actual `%s`\n", expected, config.FunctionSuffix)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if config.DebugPrintBody != true {
|
||||
t.Logf("Expected DebugPrintBody `%v` actual `%v`\n", true, config.DebugPrintBody)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
if config.WriteDebug != true {
|
||||
t.Logf("Expected WriteDebug `%v` actual `%v`\n", true, config.WriteDebug)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
expectedMaxInflight := 10
|
||||
if config.MaxInflight != expectedMaxInflight {
|
||||
t.Logf("Expected maxInflight `%v` actual `%v`\n", expectedMaxInflight, config.MaxInflight)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
expectedAckWait := time.Millisecond * 10
|
||||
if config.AckWait != expectedAckWait {
|
||||
t.Logf("Expected maxInflight `%v` actual `%v`\n", expectedAckWait, config.AckWait)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
os.Unsetenv("max_inflight")
|
||||
os.Unsetenv("ack_wait")
|
||||
|
||||
config = readConfig.Read()
|
||||
|
||||
expectedMaxInflight = 1
|
||||
if config.MaxInflight != expectedMaxInflight {
|
||||
t.Logf("Expected maxInflight `%v` actual `%v`\n", expectedMaxInflight, config.MaxInflight)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
expectedAckWait = time.Second * 30
|
||||
if config.AckWait != expectedAckWait {
|
||||
t.Logf("Expected maxInflight `%v` actual `%v`\n", expectedAckWait, config.AckWait)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
os.Setenv("max_inflight", "10.00")
|
||||
os.Setenv("ack_wait", "10")
|
||||
|
||||
config = readConfig.Read()
|
||||
|
||||
expectedMaxInflight = 1
|
||||
if config.MaxInflight != expectedMaxInflight {
|
||||
t.Logf("Expected maxInflight `%v` actual `%v`\n", expectedMaxInflight, config.MaxInflight)
|
||||
t.Fail()
|
||||
}
|
||||
|
||||
expectedAckWait = time.Second * 30
|
||||
if config.AckWait != expectedAckWait {
|
||||
t.Logf("Expected ackWait `%v` actual `%v`\n", expectedAckWait, config.AckWait)
|
||||
t.Fail()
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user