Class GHRateLimitTest


public class GHRateLimitTest extends AbstractGitHubWireMockTest
Test showing the behavior of OkHttpGitHubConnector with and without cache.

Key take aways:

  • These tests are artificial and intended to highlight the differences in behavior between scenarios. However, the differences they indicate are stark.
  • Caching reduces rate limit consumption by at least a factor of two in even the simplest case.
  • The OkHttp cache is pretty smart and will often connect read and write requests made on the same client and invalidate caches.
  • Changes made outside the current client cause the OkHttp cache to return stale data. This is expected and correct behavior.
  • "max-age=0" addresses the problem of external changes by revalidating caches for each request. This produces the same number of requests as OkHttp without caching, but those requests only count towards the GitHub rate limit if data has changes.
Author:
Liam Newman
  • Constructor Details

    • GHRateLimitTest

      public GHRateLimitTest()
      Instantiates a new GH rate limit test.
  • Method Details

    • getWireMockOptions

      protected com.github.tomakehurst.wiremock.core.WireMockConfiguration getWireMockOptions()
      Gets the wire mock options.
      Overrides:
      getWireMockOptions in class AbstractGitHubWireMockTest
      Returns:
      the wire mock options
    • testGitHubRateLimit

      public void testGitHubRateLimit() throws Exception
      Test git hub rate limit.
      Throws:
      Exception - the exception
    • testGitHubEnterpriseDoesNotHaveRateLimit

      public void testGitHubEnterpriseDoesNotHaveRateLimit() throws Exception
      Test git hub enterprise does not have rate limit.
      Throws:
      Exception - the exception
    • testGitHubRateLimitWithBadData

      public void testGitHubRateLimitWithBadData() throws Exception
      Test git hub rate limit with bad data.
      Throws:
      Exception - the exception
    • testGitHubRateLimitExpirationServerFiveMinutesAhead

      public void testGitHubRateLimitExpirationServerFiveMinutesAhead() throws Exception
      Test git hub rate limit expiration server five minutes ahead.
      Throws:
      Exception - the exception
    • testGitHubRateLimitExpirationServerFiveMinutesBehind

      public void testGitHubRateLimitExpirationServerFiveMinutesBehind() throws Exception
      Test git hub rate limit expiration server five minutes behind.
      Throws:
      Exception - the exception