mirror of https://github.com/knative/func.git
fix(e2e): parse only port from 'Function running on' output
Signed-off-by: RayyanSeliya <rayyanseliya786@gmail.com>
This commit is contained in:
parent
c7af0e2a24
commit
65b9754aad
|
@ -67,9 +67,18 @@ func TestFunctionExtendedFlow(t *testing.T) {
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
funcPort = findPort("Running on host port (.*)", stdout.String())
|
|
||||||
if funcPort == "" {
|
address := findPort(`Function running on (.*)`, stdout.String())
|
||||||
funcPort = findPort("Function started on port (.*)", stdout.String())
|
if address != "" {
|
||||||
|
_, port, err := net.SplitHostPort(address)
|
||||||
|
if err == nil {
|
||||||
|
funcPort = port
|
||||||
|
} else {
|
||||||
|
funcPort = address
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// legacy fallback
|
||||||
|
funcPort = findPort("Running on host port (.*)", stdout.String())
|
||||||
}
|
}
|
||||||
attempts++
|
attempts++
|
||||||
if funcPort == "" {
|
if funcPort == "" {
|
||||||
|
|
|
@ -44,12 +44,18 @@ func TestFunctionRunWithoutContainer(t *testing.T) {
|
||||||
for funcPort == "" && attempts < 30 { // 15 secs
|
for funcPort == "" && attempts < 30 { // 15 secs
|
||||||
t.Logf("----Function Output:\n%v", stdout.String())
|
t.Logf("----Function Output:\n%v", stdout.String())
|
||||||
matches := regexp.MustCompile("Function running on (.*)").FindStringSubmatch(stdout.String())
|
matches := regexp.MustCompile("Function running on (.*)").FindStringSubmatch(stdout.String())
|
||||||
attempts++
|
|
||||||
if len(matches) > 1 {
|
if len(matches) > 1 {
|
||||||
funcPort = matches[1]
|
hostPort := matches[1]
|
||||||
|
_, port, err := net.SplitHostPort(hostPort)
|
||||||
|
if err == nil {
|
||||||
|
funcPort = port
|
||||||
|
} else {
|
||||||
|
funcPort = hostPort
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
time.Sleep(500 * time.Millisecond)
|
time.Sleep(500 * time.Millisecond)
|
||||||
}
|
}
|
||||||
|
attempts++
|
||||||
}
|
}
|
||||||
// can proceed
|
// can proceed
|
||||||
portChannel <- funcPort
|
portChannel <- funcPort
|
||||||
|
|
Loading…
Reference in New Issue