How do you test lambda in local env?

blov · · 519 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>For the example mentioned <a href="https://aws.amazon.com/blogs/compute/announcing-go-support-for-aws-lambda/" rel="nofollow">here</a>, how would you test it in your local development environment? I do not mean unit tests, but manual testing. How do I call the lambda service from a web browser or using curl and provide input for manual testing?</p> <hr/>**评论:**<br/><br/>scottjbarr: <pre><p>I like to build my HTTP services so that can run as a &#34;normal&#34; service, or as a Lambda function behind AWS API Gateway. In this case testing is just testing a HTTP server, once you&#39;re comfortable with the wrapper that transforms the Lambda event into a HTTP request for your HTTP service.</p> <p>The other case is where you have a function that is invoke via something like a Kinesis event. I test those as a service that receives an event I can create in unit tests. I know you said not unit testing, but there you go.</p> <p>Once your local testing is solid, why not use Lambda for actual integration testing? It is super cheap and if you&#39;re only testing a limited number of interactions you&#39;re definitely not going to break the bank.</p></pre>02ccar: <pre><p>How about passing all Lambda events to your local machine?</p> <p><a href="https://github.com/mtojek/aws-lambda-go-proxy" rel="nofollow">https://github.com/mtojek/aws-lambda-go-proxy</a> (+star)</p></pre>scottjbarr: <pre><p>Looks like an interesting approach, but if it is just invoking Lambda functions I can invoke &#34;real&#34; functions from the unit tests. The addition of another component (the proxy) bothers me as it isn&#39;t something you have in production. Lambda event are just structs to Go. If you treat Lambda as a transport layer that delivers a message to your service a lot of the difficulties go away. </p></pre>circuitously: <pre><p>You want to look at the SAM - serverless application model</p> <p><a href="http://docs.aws.amazon.com/lambda/latest/dg/test-sam-local.html" rel="nofollow">http://docs.aws.amazon.com/lambda/latest/dg/test-sam-local.html</a></p></pre>thelonelysavior: <pre><p>Um, maybe not quite yet: &#34;SAM Local supports the following AWS runtimes:</p> <p>node.js 4.3 node.js 6.10 python 2.7 python 3.6 java8&#34;</p></pre>thebugswillbite: <pre><p>Go support is being worked on: <a href="https://github.com/awslabs/aws-sam-local/issues/264" rel="nofollow">https://github.com/awslabs/aws-sam-local/issues/264</a></p></pre>cmgriffing: <pre><p>You might consider one of the frameworks built around lambda.</p> <p>Apex has a command for invoking your functions remotely. <a href="http://apex.run/#invoking-functions" rel="nofollow">http://apex.run/#invoking-functions</a></p> <p>Serverless lets you test locally using their emulator: <a href="https://serverless.com/framework/docs/platform/commands/" rel="nofollow">https://serverless.com/framework/docs/platform/commands/</a></p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

519 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传