Skip to content

Commit

Permalink
Update test to always enable injection. Add delay after test.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nghia Tran committed Jun 26, 2018
1 parent 192fb3e commit fd89f7b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 2 additions & 0 deletions test/e2e-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ function dump_stack_info() {
function run_e2e_tests() {
header "Running tests in $1"
kubectl create namespace $2
kubectl label namespace $2 istio-injection=enabled --overwrite

report_go_test -v -tags=e2e ./test/$1 -dockerrepo gcr.io/elafros-e2e-tests/$3
local result=$?
[[ ${result} -ne 0 ]] && dump_stack_info
Expand Down
12 changes: 11 additions & 1 deletion test/e2e/e2e.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ package e2e

import (
"testing"
"go.uber.org/zap"
"time"

"github.com/knative/serving/test"
"go.uber.org/zap"
// Mysteriously required to support GCP auth (required by k8s libs).
// Apparently just importing it is enough. @_@ side effects @_@.
// https://github.com/kubernetes/client-go/issues/242
Expand Down Expand Up @@ -35,6 +37,14 @@ func TearDown(clients *test.Clients, names test.ResourceNames) {
if clients != nil {
clients.Delete([]string{names.Route}, []string{names.Config})
}

// There seems to be an Istio bug where if we delete / create
// VirtualServices too quickly we will hit pro-longed "No health
// upstream" causing timeouts. Adding this small sleep to
// sidestep the issue.
//
// TODO(nghia): Fix this when upstream is fixed.
time.Sleep(20 * time.Second)
}

// CreateRouteAndConfig will create Route and Config objects using clients.
Expand Down
10 changes: 9 additions & 1 deletion test/e2e/helloworld_shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
"strings"
"testing"
"time"

"github.com/knative/serving/test"
)

Expand All @@ -48,6 +49,13 @@ func noStderrShell(name string, arg ...string) string {
func cleanup(yamlFilename string) {
exec.Command("kubectl", "delete", "-f", yamlFilename).Run()
os.Remove(yamlFilename)
// There seems to be an Istio bug where if we delete / create
// VirtualServices too quickly we will hit pro-longed "No health
// upstream" causing timeouts. Adding this small sleep to
// sidestep the issue.
//
// TODO(nghia): Fix this when upstream is fixed.
time.Sleep(20 * time.Second)
}

func TestHelloWorldFromShell(t *testing.T) {
Expand All @@ -67,7 +75,7 @@ func TestHelloWorldFromShell(t *testing.T) {
}
newYamlFilename := newYaml.Name()
defer cleanup(newYamlFilename)
test.CleanupOnInterrupt(func() { cleanup(newYamlFilename) },logger)
test.CleanupOnInterrupt(func() { cleanup(newYamlFilename) }, logger)

// Populate manifets file with the real path to the container
content, err := ioutil.ReadFile(sampleYaml)
Expand Down
5 changes: 3 additions & 2 deletions test/e2e/helloworld_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,13 @@ limitations under the License.
package e2e

import (
"strings"
"testing"

"github.com/knative/serving/pkg/apis/serving/v1alpha1"
"github.com/knative/serving/test"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"strings"
"testing"
)

const (
Expand Down

0 comments on commit fd89f7b

Please sign in to comment.