diff options
Diffstat (limited to 'vendor/google.golang.org/appengine/aetest/instance_vm.go')
-rw-r--r-- | vendor/google.golang.org/appengine/aetest/instance_vm.go | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/vendor/google.golang.org/appengine/aetest/instance_vm.go b/vendor/google.golang.org/appengine/aetest/instance_vm.go index ee81480..dcb87d5 100644 --- a/vendor/google.golang.org/appengine/aetest/instance_vm.go +++ b/vendor/google.golang.org/appengine/aetest/instance_vm.go @@ -27,11 +27,17 @@ import ( // If opts is nil the default values are used. func NewInstance(opts *Options) (Instance, error) { i := &instance{ - opts: opts, - appID: "testapp", + opts: opts, + appID: "testapp", + startupTimeout: 15 * time.Second, } - if opts != nil && opts.AppID != "" { - i.appID = opts.AppID + if opts != nil { + if opts.AppID != "" { + i.appID = opts.AppID + } + if opts.StartupTimeout > 0 { + i.startupTimeout = opts.StartupTimeout + } } if err := i.startChild(); err != nil { return nil, err @@ -47,13 +53,14 @@ func newSessionID() string { // instance implements the Instance interface. type instance struct { - opts *Options - child *exec.Cmd - apiURL *url.URL // base URL of API HTTP server - adminURL string // base URL of admin HTTP server - appDir string - appID string - relFuncs []func() // funcs to release any associated contexts + opts *Options + child *exec.Cmd + apiURL *url.URL // base URL of API HTTP server + adminURL string // base URL of admin HTTP server + appDir string + appID string + startupTimeout time.Duration + relFuncs []func() // funcs to release any associated contexts } // NewRequest returns an *http.Request associated with this instance. @@ -64,7 +71,7 @@ func (i *instance) NewRequest(method, urlStr string, body io.Reader) (*http.Requ } // Associate this request. - release := internal.RegisterTestRequest(req, i.apiURL, func(ctx context.Context) context.Context { + req, release := internal.RegisterTestRequest(req, i.apiURL, func(ctx context.Context) context.Context { ctx = internal.WithAppIDOverride(ctx, "dev~"+i.appID) return ctx }) @@ -79,7 +86,8 @@ func (i *instance) Close() (err error) { rel() } i.relFuncs = nil - if i.child == nil { + child := i.child + if child == nil { return nil } defer func() { @@ -90,10 +98,10 @@ func (i *instance) Close() (err error) { } }() - if p := i.child.Process; p != nil { + if p := child.Process; p != nil { errc := make(chan error, 1) go func() { - errc <- i.child.Wait() + errc <- child.Wait() }() // Call the quit handler on the admin server. @@ -103,7 +111,6 @@ func (i *instance) Close() (err error) { return fmt.Errorf("unable to call /quit handler: %v", err) } res.Body.Close() - select { case <-time.After(15 * time.Second): p.Kill() @@ -205,7 +212,9 @@ func (i *instance) startChild() (err error) { if err != nil { return err } - stderr = io.TeeReader(stderr, os.Stderr) + if !(i.opts != nil && i.opts.SuppressDevAppServerLog) { + stderr = io.TeeReader(stderr, os.Stderr) + } if err = i.child.Start(); err != nil { return err } @@ -234,7 +243,7 @@ func (i *instance) startChild() (err error) { }() select { - case <-time.After(15 * time.Second): + case <-time.After(i.startupTimeout): if p := i.child.Process; p != nil { p.Kill() } @@ -262,7 +271,6 @@ application: %s version: 1 runtime: go api_version: go1 -vm: true handlers: - url: /.* |