Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cloud functions e2e test #552

Merged
merged 3 commits into from Jan 13, 2023

Conversation

dashpole
Copy link
Contributor

@dashpole dashpole commented Dec 21, 2022

This is split into 3 commits:

Fix detector

The detector was incorrectly detecting the cloud run platform instead of the cloud functions platform. This is because cloud functions v2 is implemented on top of cloud run. This commit makes the detector check for cloud functions first to fix this issue.

Reorganize e2e-test-server

This commit splits the scenario handler into its own folder. This way, environment variables like SUBSCRIPTION_MODE are only checked when using the push/pull server, and don't cause cloud functions tests to fail.

Add cloud functions test

A few problems I ran into while getting this to work:

  • The function entrypoint must be at the root of the "project". This means we can't just zip up the entire repo and use it as our function.
  • If we zip up the cloud functions directory as-is, it will try to fetch dependencies from the internet, including other modules in this repo (like the trace exporter!). It doesn't have access to or understand replace statements.

To solve these, we go mod vendor the dependencies into the same directory as our cloud function, which copies the files from elsewhere in our repo. We also zip -r to ensure the vendor directory is also zipped.

@codecov
Copy link

codecov bot commented Jan 10, 2023

Codecov Report

Merging #552 (60c68d1) into main (bfb214a) will decrease coverage by 0.19%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #552      +/-   ##
==========================================
- Coverage   64.19%   64.00%   -0.20%     
==========================================
  Files          37       37              
  Lines        4175     4175              
==========================================
- Hits         2680     2672       -8     
- Misses       1382     1390       +8     
  Partials      113      113              
Impacted Files Coverage Δ
detectors/gcp/detector.go 76.19% <100.00%> (ø)
...lector/internal/datapointstorage/datapointcache.go 80.30% <0.00%> (-6.07%) ⬇️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@dashpole dashpole force-pushed the cloud_functions_test branch 8 times, most recently from 6d9c9f6 to 6ea13af Compare January 11, 2023 17:27
@dashpole dashpole changed the title WIP cloud functions e2e test Add cloud functions e2e test Jan 11, 2023
@dashpole dashpole force-pushed the cloud_functions_test branch 6 times, most recently from 2a12c79 to bebef58 Compare January 11, 2023 18:46
@dashpole dashpole marked this pull request as ready for review January 11, 2023 18:59
@dashpole dashpole added the enhancement New feature or request label Jan 11, 2023
@dashpole dashpole requested a review from damemi January 11, 2023 19:00
@dashpole dashpole merged commit cc4a77e into GoogleCloudPlatform:main Jan 13, 2023
@dashpole dashpole deleted the cloud_functions_test branch January 13, 2023 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants