From 0b12139f1a1911c80dc7b8dfebdfb98591d44713 Mon Sep 17 00:00:00 2001 From: davidtai Date: Thu, 5 Feb 2015 14:02:19 -0600 Subject: [PATCH 1/7] Update context.go Appengine instance starts with strongly consistent db --- context.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/context.go b/context.go index 14eb9ff..df950f1 100644 --- a/context.go +++ b/context.go @@ -383,6 +383,7 @@ func (c *Context) startChild() error { python, devAppserver, "--clear_datastore=true", + "--datastore_consistency_policy=consistent", "--skip_sdk_update_check=true", fmt.Sprintf("--storage_path=%s/data.datastore", c.fakeAppDir), fmt.Sprintf("--log_level=%s", appLog), @@ -399,6 +400,7 @@ func (c *Context) startChild() error { python, append([]string{devAppserver, "--clear_datastore=true", + "--datastore_consistency_policy=consistent", "--skip_sdk_update_check=true", fmt.Sprintf("--storage_path=%s/data.datastore", c.fakeAppDir), fmt.Sprintf("--log_level=%s", appLog), From 82716ebab688fc42946749f98ae6b89600b5f8bb Mon Sep 17 00:00:00 2001 From: zeekay Date: Sat, 21 Feb 2015 05:32:49 -0600 Subject: [PATCH 2/7] Changes for ginkgo compatibility. --- context.go | 20 ++++++++++++-------- testingt.go | 20 ++++++++++++++++++++ 2 files changed, 32 insertions(+), 8 deletions(-) create mode 100644 testingt.go diff --git a/context.go b/context.go index df950f1..667ca77 100644 --- a/context.go +++ b/context.go @@ -12,7 +12,6 @@ import ( "bufio" "bytes" "errors" - "flag" "fmt" "hash/crc32" "io" @@ -26,7 +25,6 @@ import ( "runtime" "strconv" "syscall" - "testing" "time" "code.google.com/p/goprotobuf/proto" @@ -52,10 +50,16 @@ const AppServerFileName = "dev_appserver.py" const aeFakeName = "appenginetestingfake" // Using -loglevel on the command line temporarily overrides the options in NewContext -var overrideLogLevel = flag.String("loglevel", "", "[appenginetesting] forces all tests to have LogLevel of one of the following: child,debug,info,warning,error,critical") +var overrideLogLevel string func init() { - flag.Parse() + // TODO: Verify this works? + // Check for override loglevel + for i, a := range os.Args { + if a == "-loglevel" { + overrideLogLevel = os.Args[i+1] + } + } } // Context implements appengine.Context by running a dev_appserver.py @@ -69,7 +73,7 @@ type Context struct { fakeAppDir string // temp dir for application files queues []string // list of queues to support debug LogLevel // send the output of the application to console - testing *testing.T + testing TestingT wroteToLog bool // used in TestLogging modules []ModuleConfig // list of the modules that should start up on each test } @@ -252,7 +256,7 @@ type Options struct { AppId string // Required if using any Modules TaskQueues []string Debug LogLevel - Testing *testing.T + Testing TestingT Modules []ModuleConfig } @@ -511,7 +515,7 @@ func NewContext(opts *Options) (*Context, error) { debug: opts.debug(), } - switch *overrideLogLevel { + switch overrideLogLevel { case "": // do nothing, no value set case "child": c.debug = LogChild @@ -526,7 +530,7 @@ func NewContext(opts *Options) (*Context, error) { case "critical": c.debug = LogCritical default: - log.Fatalf("[appenginetesting] loglevel given %s, not a valid option, use one of child, debug, info, warning, error, or critical.", *overrideLogLevel) + log.Fatalf("[appenginetesting] loglevel given %s, not a valid option, use one of child, debug, info, warning, error, or critical.", overrideLogLevel) } if opts != nil { diff --git a/testingt.go b/testingt.go new file mode 100644 index 0000000..53b245e --- /dev/null +++ b/testingt.go @@ -0,0 +1,20 @@ +package appenginetesting + +//The interface returned by GinkgoT(). This covers most of the methods +//in the testing package's T. +type TestingT interface { + Fail() + Error(args ...interface{}) + Errorf(format string, args ...interface{}) + FailNow() + Fatal(args ...interface{}) + Fatalf(format string, args ...interface{}) + Log(args ...interface{}) + Logf(format string, args ...interface{}) + Failed() bool + Parallel() + Skip(args ...interface{}) + Skipf(format string, args ...interface{}) + SkipNow() + Skipped() bool +} From 48f6a722f2971d579db22a8413e8f8fd1e09286e Mon Sep 17 00:00:00 2001 From: zeekay Date: Sun, 22 Feb 2015 18:57:33 -0600 Subject: [PATCH 3/7] Make output less verbose. --- context.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/context.go b/context.go index 667ca77..109f39f 100644 --- a/context.go +++ b/context.go @@ -35,6 +35,9 @@ import ( basepb "appengine_internal/base" ) +// Trim out extraneous noise from logs +var logTrimRegexp = regexp.MustCompile(` \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}`) + // Statically verify that Context implements appengine.Context. var _ appengine.Context = (*Context)(nil) @@ -91,7 +94,8 @@ func (c *Context) logf(level LogLevel, format string, args ...interface{}) { if c.debug > level { return } - s := fmt.Sprintf("%s\t%s", level, fmt.Sprintf(format, args...)) + s := fmt.Sprintf("%s\t%s\n", level, fmt.Sprintf(format, args...)) + s = logTrimRegexp.ReplaceAllLiteralString(s, " ") if c.testing == nil { log.Println(s) } else { From 091d0ba9fa10b221502292bc0871ef16a352f842 Mon Sep 17 00:00:00 2001 From: zeekay Date: Thu, 30 Apr 2015 15:37:16 -0500 Subject: [PATCH 4/7] Use new repo for protobuf. --- context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context.go b/context.go index 109f39f..7c781bf 100644 --- a/context.go +++ b/context.go @@ -27,7 +27,7 @@ import ( "syscall" "time" - "code.google.com/p/goprotobuf/proto" + "github.com/golang/protobuf/proto" "appengine" "appengine/user" From f85360b592683cada91a63acc83a5cfecb0d6d40 Mon Sep 17 00:00:00 2001 From: Marvel Mathew Date: Wed, 6 Jan 2016 15:36:37 -0600 Subject: [PATCH 5/7] Use new appengine packages --- context.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/context.go b/context.go index 7c781bf..fbe83f0 100644 --- a/context.go +++ b/context.go @@ -29,17 +29,17 @@ import ( "github.com/golang/protobuf/proto" - "appengine" - "appengine/user" - "appengine_internal" - basepb "appengine_internal/base" + "golang.org/x/net/context" + "google.golang.org/appengine/user" + "google.golang.org/appengine_internal" + basepb "google.golang.org/appengine/internal/base" ) // Trim out extraneous noise from logs var logTrimRegexp = regexp.MustCompile(` \d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2},\d{3}`) // Statically verify that Context implements appengine.Context. -var _ appengine.Context = (*Context)(nil) +var _ context.Context = (*Context)(nil) // httpClient is used to communicate with the helper child process's // webserver. We can't use http.DefaultClient anymore, as it's now @@ -86,6 +86,10 @@ type ModuleConfig struct { Path string // can be relative to the current working directory and should include the yaml file } +func (c *Context) Deadline() (time.Time, bool) { + return nil, false +} + func (c *Context) AppID() string { return c.appid } From 60123bc980a1c2edad1a823a0e326641c64dcf5f Mon Sep 17 00:00:00 2001 From: Marvel Mathew Date: Wed, 6 Jan 2016 15:38:34 -0600 Subject: [PATCH 6/7] Fix typo --- context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context.go b/context.go index fbe83f0..0ba9751 100644 --- a/context.go +++ b/context.go @@ -31,7 +31,7 @@ import ( "golang.org/x/net/context" "google.golang.org/appengine/user" - "google.golang.org/appengine_internal" + "google.golang.org/appengine/internal" basepb "google.golang.org/appengine/internal/base" ) From 42ddde0706fe33e6335868b83697badf860c8eb2 Mon Sep 17 00:00:00 2001 From: Marvel Mathew Date: Wed, 6 Jan 2016 15:40:46 -0600 Subject: [PATCH 7/7] s/appengine_internal/internal --- context.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/context.go b/context.go index 0ba9751..60b4c83 100644 --- a/context.go +++ b/context.go @@ -189,7 +189,7 @@ func (c *Context) Logout() { c.req.Header.Del("X-AppEngine-User-Federated-Provider") } -func (c *Context) Call(service, method string, in, out appengine_internal.ProtoMessage, opts *appengine_internal.CallOptions) error { +func (c *Context) Call(service, method string, in, out internal.ProtoMessage, opts *internal.CallOptions) error { if service == "__go__" { if method == "GetNamespace" { out.(*basepb.StringProto).Value = proto.String(c.req.Header.Get("X-AppEngine-Current-Namespace")) @@ -202,7 +202,7 @@ func (c *Context) Call(service, method string, in, out appengine_internal.ProtoM } cn := c.GetCurrentNamespace() if cn != "" { - if mod, ok := appengine_internal.NamespaceMods[service]; ok { + if mod, ok := internal.NamespaceMods[service]; ok { mod(in, cn) } }