Ruby on rails Rspec模型测试失败是由于Google Compute VM上的ENOMEM,而不是物理机器上的ENOMEM

Ruby on rails Rspec模型测试失败是由于Google Compute VM上的ENOMEM,而不是物理机器上的ENOMEM,ruby-on-rails,linux,rspec,google-compute-engine,kvm,Ruby On Rails,Linux,Rspec,Google Compute Engine,Kvm,在我的Google Compute服务器上用3.75 GB的RAM运行rspec模型测试时,我经常遇到内存分配错误,而在正常机器上用2 GB的RAM运行相同的测试时,我没有得到这些错误。我使用的命令是“rspec spec/models”,以便运行所有测试。当我运行任何其他类型的rspec测试时,都不会发生这种情况 在我的普通机器上,584个测试中只有2个失败(目前这是预期的行为)。但是,当我使用Google Compute server时,有148个故障发生,这是我从顶部获得的输出的一个示例:

在我的Google Compute服务器上用3.75 GB的RAM运行rspec模型测试时,我经常遇到内存分配错误,而在正常机器上用2 GB的RAM运行相同的测试时,我没有得到这些错误。我使用的命令是“rspec spec/models”,以便运行所有测试。当我运行任何其他类型的rspec测试时,都不会发生这种情况

在我的普通机器上,584个测试中只有2个失败(目前这是预期的行为)。但是,当我使用Google Compute server时,有148个故障发生,这是我从顶部获得的输出的一个示例:

Run options: include {:focus=>true}

All examples were filtered out; ignoring {:focus=>true}
....................F.FF.......................................................................................................................FFF.FF.F.............................................................................................................................F..F.F.F..FF.F...F.FF..F..F..F....F.FFF..FF.F.FF.FFFF.F.FFFFF.FF..F.FF.FFF...F.FFF...FFFF.FFFF.F.F.FF...............................................FF..F.F.FF.FF.FF.F...F.F.F..F.F.F.F......F.F...F.F.F.FF..FF.F.FFF..FF.FF.F..F..........FFFFFFFFFFFFFFFFFFFF
An error occurred in an after(:all) hook.
  Errno::ENOMEM: Cannot allocate memory - rm -rf /home/patrick/terrabase/imperial/files/test
  occurred at /home/patrick/.rvm/gems/ruby-1.9.3-p194@imperialhorizons/gems/activesupport-3.2.22/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'

.
An error occurred in an after(:all) hook.
  Errno::ENOMEM: Cannot allocate memory - rm -rf /home/patrick/terrabase/imperial/files/test
  occurred at /home/patrick/.rvm/gems/ruby-1.9.3-p194@imperialhorizons/gems/activesupport-3.2.22/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'

....
An error occurred in an after(:all) hook.
  Errno::ENOMEM: Cannot allocate memory - rm -rf /home/patrick/terrabase/imperial/files/test
  occurred at /home/patrick/.rvm/gems/ruby-1.9.3-p194@imperialhorizons/gems/activesupport-3.2.22/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'

.
An error occurred in an after(:all) hook.
  Errno::ENOMEM: Cannot allocate memory - rm -rf /home/patrick/terrabase/imperial/files/test
  occurred at /home/patrick/.rvm/gems/ruby-1.9.3-p194@imperialhorizons/gems/activesupport-3.2.22/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``'

.
…这种情况一直持续到底部的“失败”部分:

142) LibraryBarcodeImport#process_row update existing student if the cid matches should set the imported count to 1
     Failure/Error: let(:library_barcode_import) { FactoryGirl.build(:library_barcode_import, log_text: "", imported_count: 0) }
     Errno::ENOMEM:
       Cannot allocate memory - file -b --mime '/home/patrick/terrabase/imperial/spec/testfiles/barcodes.xlsx'
     # ./spec/models/library_barcode_import_spec.rb:57:in `block (3 levels) in <top (required)>'
     # ./spec/models/library_barcode_import_spec.rb:103:in `block (4 levels) in <top (required)>'
…第103行在“before”语句中:

before do
    library_barcode_import.process_row(spreadsheet_row, 1, checking )
end
软件:

  • Ruby 1.9.3-p194
  • 轨道3.2.22
  • Rspec 2.13.1
虚拟机规格:

  • n1-standard-1(1个vCPU,3.75 GB内存)
  • CPU平台:英特尔桑迪桥
  • 操作系统:Ubuntu 14.04 64位,内核:3.19.0-43-generic
  • 硬盘:10GB
物理机器规格:

  • 东芝卫星专业A300
  • CPU:英特尔奔腾双CPU T2390@1.86 GHz
  • 操作系统:Linux Mint 17.3 64位
从“free-m”的输出可以看出,VM上不缺少可用的RAM:

             total       used       free     shared    buffers     cached
Mem:          3700        947       2753         14         80        531
-/+ buffers/cache:        336       3364
Swap:            0          0          0
“dmesg | grep-i virtual”的输出显示服务器依赖于KVM:

[    0.000000] Booting paravirtualized kernel on KVM
在谷歌上搜索时,我没有发现任何对处理这个问题有帮助的方法。有人知道这可能是什么原因吗

[    0.000000] Booting paravirtualized kernel on KVM