Closed ahatzz11 closed 6 years ago
The wiki has docker instructions, but I need to add local instructions for the wiki and contributing.
git clone https://github.com/r-spacex/SpaceX-API.git
yarn install
yarn test
That should let the tests run. The mongo connection is read-only and hardcoded in the application, so that shouldn't be the issue.
Previously I was getting an error on yarn install
that I didn't have the right version of node:
error spacex-api@2.4.0: The engine "node" is incompatible with this module. Expected version "9.x.x".
I upgraded and am now using node v9.10.1
. The yarn install
works fine, but yarn test
still has 75/75 failing tests. I've tried having docker up and running (using docker-compose build
and docker-compose up
) before running yarn test
, but that also fails.
Are you able to run yarn start
and access the endpoints normally?
Also, what do the tests return? Is it returning 404's or 500's?
I can use yarn start
and hit the API locally! So that's a start.
~/code/SpaceX-API(branch:master) » curl http://localhost:80/v2/launches/latest 7 ↵
{"flight_number":59,"launch_year":"2018","launch_date_unix":1522701041,"launch_date_utc":"2018-04-02T20:30:41Z","launch_date_local":"2018-04-02T16:30:41-04:00","rocket":{"rocket_id":"falcon9","rocket_name":"Falcon 9","rocket_type":"FT","first_stage":{"cores":[{"core_serial":"B1039","flight":2,"block":4,"reused":true,"land_success":null,"landing_type":null,"landing_vehicle":null}]},"second_stage":{"payloads":[{"payload_id":"SpaceX CRS-14","cap_serial":"C110","reused":true,"customers":["NASA (CRS)"],"payload_type":"Dragon 1.1","payload_mass_kg":2760,"payload_mass_lbs":6084.7,"orbit":"ISS","mass_returned_kg":null,"mass_returned_lbs":null,"flight_time_sec":null,"cargo_manifest":"https://www.nasa.gov/sites/default/files/atoms/files/spacex_crs-14_mision_overview_high_res.pdf"}]}},"telemetry":{"flight_club":"https://www.flightclub.io/results/?code=CR14"},"reuse":{"core":true,"side_core1":false,"side_core2":false,"fairings":false,"capsule":true},"launch_site":{"site_id":"ccafs_slc_40","site_name":"CCAFS SLC 40","site_name_long":"Cape Canaveral Air Force Station Space Launch Complex 40"},"launch_success":true,"links":{"mission_patch":"https://i.imgur.com/eHxbiG3.png","reddit_campaign":"https://www.reddit.com/r/spacex/comments/82op7a/crs14_launch_campaign_thread/","reddit_launch":"https://www.reddit.com/r/spacex/comments/88s8a7/rspacex_crs14_official_launch_discussion_updates/","reddit_recovery":null,"reddit_media":"https://www.reddit.com/r/spacex/comments/88l52i/rspacex_crs14_media_thread_videos_images_gifs/","presskit":"http://www.spacex.com/sites/spacex/files/crs-14presskit2018.pdf","article_link":null,"video_link":"https://www.youtube.com/watch?v=BPQHG-LevZM"},"details":"The launch used a refurbished booster (from CRS-12) for the 11th time, and a refurbished capsule (C110 from CRS-8) for the third time. External payloads include a materials research platform MISSE-FF phase 3 of the Robotic Refueling Mission TSIS, heliophysics sensor several crystallization experiments, and the RemoveDebris spacecraft aimed at space junk removal. The booster was expended in order to test a new landing profile."}%
The failures I'm getting are all 500's. Here's a sample log from yarn test
:
```
FAIL test/routes/v2-parts.test.js (5.142s)
● Console
console.error node_modules/koa/lib/application.js:194
console.error node_modules/koa/lib/application.js:195
TypeError: Cannot read property 'collection' of undefined
at Object.
Definitely a mongo connection issue, looking into this
Do you have a PORT environment variable set?
Because I saw you had it running on port 80, and the test command sets PORT to 0 to allow for random port assignments during tests.
Now that we're using Koa, there's a better solution to this, but it's in the pipeline.
I do not have a PORT
env variable. What is the default port that the api should live on when using yarn start
? I'm pretty new to node.js, so I looked around online and tried a few different ports I saw until 80
finally worked for me.
~ » echo $PORT
------------------------------------------------------------
~ »
Default PORT should be 5000
const port = process.env.PORT || 5000;
Were you running it in Docker-Compose? For Docker-Compose I have the port set to 80
This is interesting - I can hit the api from both ports.
~/code/SpaceX-API(branch:master*) » curl http://localhost:80/v2/launches/latest
{"flight_number":59,"launch_year":"2018","launch_date_unix":1522701041,"launch_date_utc":"2018-04-02T20:30:41Z","launch_date_local":"2018-04-02T16:30:41-04:00","rocket":{"rocket_id":"falcon9","rocket_name":"Falcon 9","rocket_type":"FT","first_stage":{"cores":[{"core_serial":"B1039","flight":2,"block":4,"reused":true,"land_success":null,"landing_type":null,"landing_vehicle":null}]},"second_stage":{"payloads":[{"payload_id":"SpaceX CRS-14","cap_serial":"C110","reused":true,"customers":["NASA (CRS)"],"payload_type":"Dragon 1.1","payload_mass_kg":2760,"payload_mass_lbs":6084.7,"orbit":"ISS","mass_returned_kg":null,"mass_returned_lbs":null,"flight_time_sec":null,"cargo_manifest":"https://www.nasa.gov/sites/default/files/atoms/files/spacex_crs-14_mision_overview_high_res.pdf"}]}},"telemetry":{"flight_club":"https://www.flightclub.io/results/?code=CR14"},"reuse":{"core":true,"side_core1":false,"side_core2":false,"fairings":false,"capsule":true},"launch_site":{"site_id":"ccafs_slc_40","site_name":"CCAFS SLC 40","site_name_long":"Cape Canaveral Air Force Station Space Launch Complex 40"},"launch_success":true,"links":{"mission_patch":"https://i.imgur.com/eHxbiG3.png","reddit_campaign":"https://www.reddit.com/r/spacex/comments/82op7a/crs14_launch_campaign_thread/","reddit_launch":"https://www.reddit.com/r/spacex/comments/88s8a7/rspacex_crs14_official_launch_discussion_updates/","reddit_recovery":null,"reddit_media":"https://www.reddit.com/r/spacex/comments/88l52i/rspacex_crs14_media_thread_videos_images_gifs/","presskit":"http://www.spacex.com/sites/spacex/files/crs-14presskit2018.pdf","article_link":null,"video_link":"https://www.youtube.com/watch?v=BPQHG-LevZM"},"details":"The launch used a refurbished booster (from CRS-12) for the 11th time, and a refurbished capsule (C110 from CRS-8) for the third time. External payloads include a materials research platform MISSE-FF phase 3 of the Robotic Refueling Mission TSIS, heliophysics sensor several crystallization experiments, and the RemoveDebris spacecraft aimed at space junk removal. The booster was expended in order to test a new landing profile."}%
------------------------------------------------------------
~/code/SpaceX-API(branch:master*) » curl http://localhost:5000/v2/launches/latest
{"flight_number":59,"launch_year":"2018","launch_date_unix":1522701041,"launch_date_utc":"2018-04-02T20:30:41Z","launch_date_local":"2018-04-02T16:30:41-04:00","rocket":{"rocket_id":"falcon9","rocket_name":"Falcon 9","rocket_type":"FT","first_stage":{"cores":[{"core_serial":"B1039","flight":2,"block":4,"reused":true,"land_success":null,"landing_type":null,"landing_vehicle":null}]},"second_stage":{"payloads":[{"payload_id":"SpaceX CRS-14","cap_serial":"C110","reused":true,"customers":["NASA (CRS)"],"payload_type":"Dragon 1.1","payload_mass_kg":2760,"payload_mass_lbs":6084.7,"orbit":"ISS","mass_returned_kg":null,"mass_returned_lbs":null,"flight_time_sec":null,"cargo_manifest":"https://www.nasa.gov/sites/default/files/atoms/files/spacex_crs-14_mision_overview_high_res.pdf"}]}},"telemetry":{"flight_club":"https://www.flightclub.io/results/?code=CR14"},"reuse":{"core":true,"side_core1":false,"side_core2":false,"fairings":false,"capsule":true},"launch_site":{"site_id":"ccafs_slc_40","site_name":"CCAFS SLC 40","site_name_long":"Cape Canaveral Air Force Station Space Launch Complex 40"},"launch_success":true,"links":{"mission_patch":"https://i.imgur.com/eHxbiG3.png","reddit_campaign":"https://www.reddit.com/r/spacex/comments/82op7a/crs14_launch_campaign_thread/","reddit_launch":"https://www.reddit.com/r/spacex/comments/88s8a7/rspacex_crs14_official_launch_discussion_updates/","reddit_recovery":null,"reddit_media":"https://www.reddit.com/r/spacex/comments/88l52i/rspacex_crs14_media_thread_videos_images_gifs/","presskit":"http://www.spacex.com/sites/spacex/files/crs-14presskit2018.pdf","article_link":null,"video_link":"https://www.youtube.com/watch?v=BPQHG-LevZM"},"details":"The launch used a refurbished booster (from CRS-12) for the 11th time, and a refurbished capsule (C110 from CRS-8) for the third time. External payloads include a materials research platform MISSE-FF phase 3 of the Robotic Refueling Mission TSIS, heliophysics sensor several crystallization experiments, and the RemoveDebris spacecraft aimed at space junk removal. The booster was expended in order to test a new landing profile."}%
Are you only running it once?
Did you get it working?
I've been playing with this API a little bit, and I'd love to submit a PR at some point in the future. I see the contributions page, but I don't see very much info on how to run the test suite locally. I checked out what travis-ci is doing, and when I run
yarn test
all of the tests fail. I think I'm missing a step getting the data from mongo. A little doc about how to get tests running locally would be great!Thanks