douzi1350 2017-05-06 05:59
浏览 58

银杏测试在goapp测试期间挂起

I'm trying to use Gikngo to write some tests for appengine.

My setup for the tests is as follows:

suite_test.go:

BeforeSuite() {
  inst, err = aetest.NewInstance(options)
  if err != nil {
    Fail(fmt.Sprintf("%s", err))
  }
}

var(
  req *http.Request
  ctx context.Context
)
BeforeEach() {
  req = inst.NewRequest()
  ctx = appengine.NewContext(req)

  // Clean up local datastore using the context.
}

validation_test.go

Describe("Some Test", func() {
  It("ValidateFoo", func() {
    // Access ctx here
  })
  ...
  It("ValidateBar", func() {
    // Access ctx here.
  })
})

I see our tests consistently hanging with the error of the type:

Expected success, but got an error:
    <*url.Error | 0xc8210570b0>: {
        Op: "Post",
        URL: "http://localhost:59072",
        Err: {s: "EOF"},
    }
    Post http://localhost:59072: EOF

This seems to indicate that the API server has become inaccessible. However, the test output does not seem to indicate this.

What are the ways in which we can debug a goapp test?

  • 写回答

1条回答 默认 最新

  • doudao8283 2017-05-09 06:01
    关注

    It turns out that Ginkgo or Golang had nothing to do with this. There seems to be some limitation on the number of fields one can read per second from dev_appserver.py. (I suspect that it might be related to SQLite which is the DB that dev_appserver uses internally).

    The following code points out the problem:

    package preorder
    
    import (
        "fmt"
        "testing"
    
        "google.golang.org/appengine"
        "google.golang.org/appengine/aetest"
        "google.golang.org/appengine/datastore"
    )
    
    func TestLoad(t *testing.T) {
        opts := aetest.Options{StronglyConsistentDatastore: true}
        inst, _ := aetest.NewInstance(&opts)
        defer inst.Close()
    
        for i := 0; i < 10000; i++ {
            req, _ := inst.NewRequest("GET", "/", nil)
            ctx := appengine.NewContext(req)
    
            k := datastore.NewKey(ctx, ENTITY_NAME, "", 12345, nil)
            var entity Entity
            datastore.Get(ctx, k, &entity)
            fmt.Println("Iteration Count: ", i)
            ctx.Done()
        }
    }
    

    Any help on figuring out how to work around the limit of 240 operations would be appreciated. One technique I can think of is to artificially inject delays.

    评论

报告相同问题?

悬赏问题

  • ¥15 ogg dd trandata 报错
  • ¥15 高缺失率数据如何选择填充方式
  • ¥50 potsgresql15备份问题
  • ¥15 Mac系统vs code使用phpstudy如何配置debug来调试php
  • ¥15 目前主流的音乐软件,像网易云音乐,QQ音乐他们的前端和后台部分是用的什么技术实现的?求解!
  • ¥60 pb数据库修改与连接
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错