Class GHRateLimitTest


  • public class GHRateLimitTest
    extends AbstractGitHubWireMockTest
    Test showing the behavior of OkHttpConnector 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 Detail

      • GHRateLimitTest

        public GHRateLimitTest()
    • Method Detail

      • testGitHubRateLimit

        public void testGitHubRateLimit()
                                 throws Exception
        Throws:
        Exception
      • testGitHubEnterpriseDoesNotHaveRateLimit

        public void testGitHubEnterpriseDoesNotHaveRateLimit()
                                                      throws Exception
        Throws:
        Exception
      • testGitHubRateLimitWithBadData

        public void testGitHubRateLimitWithBadData()
                                            throws Exception
        Throws:
        Exception
      • testGitHubRateLimitExpirationServerFiveMinutesAhead

        public void testGitHubRateLimitExpirationServerFiveMinutesAhead()
                                                                 throws Exception
        Throws:
        Exception
      • testGitHubRateLimitExpirationServerFiveMinutesBehind

        public void testGitHubRateLimitExpirationServerFiveMinutesBehind()
                                                                  throws Exception
        Throws:
        Exception