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

delete useless resource files; dramatically simplified retry strategies and response parsing #18

Merged
merged 42 commits into from
Oct 3, 2017

Conversation

apurvis
Copy link
Contributor

@apurvis apurvis commented Feb 10, 2017

This includes all changes from #17 so if you prefer you can either merge that first, or just not merge that and go with this.

It also includes

  • delete useless resource files
  • move services to a folder
  • use a unified and reasonable retry strategy with the Retriable gem instead of chaos theory
  • ReadOnlyService superclass
  • deprecating LogLevelDataDownloadService - all the functionality lives in LogLevelDataService with the LogLevelDataDownloadService class to be removed whenever there's a 2.0 release

There are no functional changes to external APIs though if someone is reaching into the gem and mucking with classes like AdvertiserResource, this will break their code. In my opinion that means this doesn't warrant a major or even minor version bump - 1.0.1 would be fine.

@joshuawscott @infinite-monkeys

apurvis and others added 30 commits February 8, 2017 19:48
Better retries; move service files to their own directory
* Add APPNEXUS_API_DEBUG env variable falg; Add respond_to_missing

* Just use an accessor for raw_json

* Get rid of :return_response flag; it's not used
… time; set log level to debug if debug mode turned on
apurvis and others added 2 commits February 13, 2017 03:04
…ion class with default logger (#6)

* Consolidate download service

* Fix final issues with log level data download

* Real spec for log level data download; default feed
if body['error_code'] == RATE_EXCEEDED_ERROR
raise AppnexusApi::RateLimitExceeded, "Retry after #{response.response_headers['retry-after']}s"
elsif body['error_id'] && !body['error_id'].empty?
# TODO: this should raise an error, but a lot of the specs currently have error responses
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is kind of a bummer; not sure this is because of my account's access and @infinite-monkeys will be able to replace the .yml files but the specs were passing even with these error responses (in fact this kind of error response never even generated any errors, which is ... problematic)

@apurvis
Copy link
Contributor Author

apurvis commented Apr 6, 2017

@joshuawscott any plans to merge/release this?

@apurvis
Copy link
Contributor Author

apurvis commented Jul 19, 2017

@joshuawscott this has been open for over 5 months now... any plans to merge this? we have been running this streamlined version in production daily for that entire time.

@joshuawscott
Copy link
Member

@mcmoyer can you take a look and give a 👍 / 👎

apurvis@lumoslabs.com and others added 2 commits July 31, 2017 23:49
@apurvis
Copy link
Contributor Author

apurvis commented Aug 30, 2017

@mcmoyer / @joshuawscott ?

@apurvis
Copy link
Contributor Author

apurvis commented Sep 5, 2017

ping (sorry to be annoying, but it would be good if we could get this merged in the next 4 weeks)

@apurvis
Copy link
Contributor Author

apurvis commented Sep 15, 2017

ping

@mcmoyer
Copy link
Contributor

mcmoyer commented Sep 15, 2017

I’ll look at it this weekend…sorry for the delay

@mcmoyer
Copy link
Contributor

mcmoyer commented Sep 18, 2017

had issues getting the tests to run this weekend. I believe it may be due to permissions with our sandbox login. Will check into that today

@apurvis
Copy link
Contributor Author

apurvis commented Sep 18, 2017

thanks... are you trying to create new VCR files or just run the specs as is?

@apurvis
Copy link
Contributor Author

apurvis commented Sep 18, 2017

maybe you have an old .env file that is out of date? you should be able to just delete it and run specs without it
https://github.com/lumoslabs/appnexusapi#writing-new-specs-or-updating-old-ones

@mcmoyer
Copy link
Contributor

mcmoyer commented Sep 20, 2017

was able to get the tests running by renaming my .env file. I’m unable to get all the specs to pass

23 examples, 12 failures, 1 pending

It seems to be all permissions related so getting in touch with Appnexus to see if I can get a login with more permissions in the test system.

@apurvis
Copy link
Contributor Author

apurvis commented Sep 20, 2017

i get

23 examples, 0 failures, 1 pending

but yeah the one spec i could not get to pass had to do with permissions on my account (that's the pending one).

however, the specs should not be hitting appnexus in any way, as long as you don't clear the VCR files. are you trying to regenerate the VCR files from scratch? if so you need the .env file:

APPNEXUS_USERNAME=me@yahooooo.com
APPNEXUS_PASSWORD=PaSsWoRd
APPNEXUS_URI=https://api-test.appnexus.com

@apurvis
Copy link
Contributor Author

apurvis commented Sep 20, 2017

specifically the pending one is:

Pending: (Failures listed here are expected and do not affect your suite's status)

  1) AppnexusApi::PlacementService default placement
     # seems to rely on a configured default_site_id
     Failure/Error: raise 'seems to rely on a configured default_site_id'

     RuntimeError:
       seems to rely on a configured default_site_id
     # ./spec/integration/placement_spec.rb:10:in `block (2 levels) in <top (required)>'

@apurvis
Copy link
Contributor Author

apurvis commented Sep 20, 2017

FWIW i was able to get the specs to pass just with a fresh checkout and without hitting appnexus's actual test server in any way.

git clone git@github.com:lumoslabs/appnexusapi.git
cd appnexusapi
bundle install
bundle exec rspec

maybe it's an issue with some older version of some dependency gem that needs an update? my Gemfile.lock looks like this:

PATH
  remote: .
  specs:
    appnexusapi (1.1.0.pre.prerelease)
      faraday (~> 0.9)
      faraday_middleware
      multi_json
      retriable (>= 2.0)

GEM
  remote: https://rubygems.org/
  specs:
    addressable (2.5.2)
      public_suffix (>= 2.0.2, < 4.0)
    coderay (1.1.2)
    crack (0.4.3)
      safe_yaml (~> 1.0.0)
    diff-lcs (1.3)
    dotenv (2.2.1)
    faraday (0.13.1)
      multipart-post (>= 1.2, < 3)
    faraday_middleware (0.12.2)
      faraday (>= 0.7.4, < 1.0)
    hashdiff (0.3.6)
    method_source (0.8.2)
    multi_json (1.12.2)
    multipart-post (2.0.0)
    pry (0.11.0)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
    public_suffix (3.0.0)
    retriable (3.1.1)
    rspec (3.6.0)
      rspec-core (~> 3.6.0)
      rspec-expectations (~> 3.6.0)
      rspec-mocks (~> 3.6.0)
    rspec-core (3.6.0)
      rspec-support (~> 3.6.0)
    rspec-expectations (3.6.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.6.0)
    rspec-mocks (3.6.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.6.0)
    rspec-support (3.6.0)
    safe_yaml (1.0.4)
    vcr (3.0.3)
    webmock (3.0.1)
      addressable (>= 2.3.6)
      crack (>= 0.3.2)
      hashdiff

PLATFORMS
  ruby

DEPENDENCIES
  appnexusapi!
  bundler (>= 1.2.0)
  dotenv
  pry
  rspec
  vcr
  webmock

BUNDLED WITH
   1.16.0.pre.2

@apurvis
Copy link
Contributor Author

apurvis commented Sep 26, 2017

ping

@mcmoyer
Copy link
Contributor

mcmoyer commented Sep 28, 2017

I’m able to run the specs without a .env file. It’s not ideal since our login is unable to run the specs against the actual appnexus sandbox. Since it’s taking a while to get the required permissions from appnexus, I’m going to merge these so you’re not held up any longer

@apurvis
Copy link
Contributor Author

apurvis commented Sep 28, 2017

awesome, thanks.

@apurvis
Copy link
Contributor Author

apurvis commented Sep 28, 2017

(i would definitely squash + merge, not just merge... all the tiny commits are not helpful)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants