Closed Bug 1432491 Opened 6 years ago Closed 6 years ago

add deploy artifact generation to pigeon repo and add integration test

Categories

(Socorro :: Antenna, task, P3)

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: willkg, Assigned: willkg)

References

Details

Attachments

(1 file)

+++ This bug was initially created as a clone of Bug #1432244 +++

It'd be great to run integration tests on socorro-pigeon using the deploy artifact so as to verify that it's built correctly and that it has all the requirements it needs.

In order to do that, we need to move the code that generates the deploy artifact from the infra repo into this one. It probably makes sense to turn it into a make target.

Then we need to write an integration test that uses that artifact to run the lambda function and verifies it works.

This bug covers that.
First step is to generate the artifact. The infra repo has this ansible code:

"""
  - name: Checkout pigeon
    git:
      repo: git://github.com/mozilla-services/socorro-pigeon.git
      dest: ../lambda/pigeon
  - name: Download deps
    command: pip install -r ../lambda/pigeon/requirements.txt -t ../lambda/pigeon
  - name: Create Cleanup Lambda Package
    shell: zip -q -T -r pigeon.zip .
    args:
      chdir: ../lambda/pigeon
"""

We have the checkout already, so I think we should move the other two bits into a make target then change the infra code to call that.

After we've fixed that, we should write an integration test.

From https://bugzilla.mozilla.org/show_bug.cgi?id=1432244#c4 :

"""
I wrote a basic test harness for running Pigeon in a Lambda-ish environment. It's a pytest fixture. It provides a way to run tests on the lambda handler function. It doesn't test whether the deploy artifact is correct, has all the things it needs, runs with the correct AWS Lambda executor, etc.

I spent some time today looking at localstack and moto.

As near as I can tell, moto has no documentation whatsoever for testing Lambda functions. Seems like you wrap your test with @mock_lambda and then use boto3 to create functions and invoke them. There are examples of this in the tests for mock_lambda:

https://github.com/spulec/moto/blob/master/tests/test_awslambda/test_lambda.py

Seems like we could write some code to generate the deploy artifact and then use that with @mock_lambda to cover questions like "Is our deploy artifact complete?" That seems like it'd be helpful.

As near as I can tell, localstack also has no documentation. However, I think what we'd do is set up CI to run a localstack lambda container, then use boto3 to execute commands against that and get answers back. I think this would effectively give us the same thing we'd get out of moto.

I'm going to try to set this up with localstack and see how far I get.
"""
Making this a P2. Seems like Pigeon is here to stay for the time being, so it's worth doing an update.
Priority: -- → P2
Summary: update pigeon to python 3.6 → add deploy artifact generation to pigeon repo and add integration test
Bumping this down. This is important, but I don't foresee more pigeon work for a while, so it can wait.
Component: General → Antenna
Priority: P2 → P3
The underlying need here is to be able to run and test the pigeon deploy artifact in a lambda-like environment that runs locally.

Miles mentioned SAM: https://docs.aws.amazon.com/lambda/latest/dg/test-sam-local.html

We should look into using that.
Assignee: nobody → willkg
Status: NEW → ASSIGNED
PR 34 landed in https://github.com/mozilla-services/socorro-pigeon/commit/16c03ee67eb70abe64d2867e648d77f35055b913

We're all set here.
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: