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

Gather data about private API usage in test suite #1800

Merged
merged 8 commits into from
Jul 25, 2024

Commits on Jul 24, 2024

  1. Remove shortcuts to shared_helper properties

    This refactor is preparation for an upcoming change which will give each
    test function a unique helper object.
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    9e28603 View commit details
    Browse the repository at this point in the history
  2. Declare variables consistently in shared_helper

    Preparation for an upcoming change which will turn this helper into a
    class.
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    3ddc825 View commit details
    Browse the repository at this point in the history
  3. Stop using helper.AblyRealtime as a constructor

    It isn’t intended be called as a constructor.
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    2b7c2f5 View commit details
    Browse the repository at this point in the history
  4. Convert shared helper to a class

    Motivation as in 9e28603. To expand a little, in order to implement
    ECO-4821 (gathering detailed information about private API usage in the
    test suite), we will give each test function access to a unique helper
    object which is aware of the identity of the test case in which it is
    executing. This helper object will offer a method for recording the fact
    that a test function is calling a private API. By using the existing
    shared_helper object, we can also record the usage of private APIs by
    the various helper methods, access to which is currently funnelled
    through the shared_helper.
    
    The couple of methods that I’ve made static (randomString,
    whenPromiseSettles) are ones that are very frequently called _and_ which
    definitely don’t use any private APIs, so I’ve made them static so that,
    when we make the aforementioned change giving each test case its own
    helper object, we don’t need to pass a helper around just to enable
    these methods to be called. The choice of making just these two methods
    static was pretty arbitrary; once we’ve catalogued all of the private
    API usage it might turn out there some other ones that can be made
    static.
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    1fa5e13 View commit details
    Browse the repository at this point in the history
  5. Update tests so that each has its own helper instance

    This removes the per-file SharedHelper instance and instead makes sure
    that each context which will call SharedHelper instance methods (e.g.
    test cases, test hooks) has a unique SharedHelper instance that is aware
    of the context from which it is being called. (Motivation for this
    change already explained in 1fa5e13.)
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    4f0dbbe View commit details
    Browse the repository at this point in the history
  6. Move availableTransports and bestTransport inside helper

    Preparation for recording private API usage by tests (ECO-4821).
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    0bf4291 View commit details
    Browse the repository at this point in the history
  7. Record usages of private APIs in the test suite

    This adds annotations to each place in the test suite where a private
    API is called. When the tests are run, these annotations are used to
    emit a JSON file containing private API usage information. (In ECO-4834,
    we’ll process this JSON file to generate some useful reports.) This JSON
    file also contains a list of all of the tests which get run, which will
    be used as part of the aforementioned reporting to allow us to generate
    a report of the tests that do not use any private APIs.
    
    The motivation for this gathering this data is that we intend to try and
    reuse the ably-js test suite as a unified test suite for all of our
    client libraries. In order to do this, we’ll need to address the usage
    of ably-js private APIs in the test suite, and to do that we need to
    first gather data about the current usage.
    
    I originally intended to put the changes into the current commit into a
    separate unified test suite branch, instead of merging them into `main`.
    But I don’t really want to maintain a long-running feature branch, and
    also I want to make sure that we add private API annotations to any new
    tests that we add to ably-js, hence I decided to put this commit into
    `main`. But maybe, once we’re done with the unified test suite, we’ll
    decide to remove these annotations.
    
    Given the context in which we’re gathering this data, in the interests
    of saving time I skipped adding some annotations to some files that I’m
    pretty sure will not form part of the unified test suite:
    
    - test/realtime/transports.test.js
    - test/browser/simple.test.js
    - test/browser/http.test.js
    - test/browser/connection.test.js
    - test/browser/modular.test.js
    - test/browser/push.test.js
    - test/rest/bufferutils.test.js
    
    If we decide at some point that we’d like to for whatever reason gather
    data on these tests, we can do that later.
    
    (Note I haven't been very consistent with how many times per test I
    record the usage of a given private API; it’s not a stat I’m
    particularly interested in here. But for the most part I’m doing it at
    the point of each invocation of the private API.)
    
    Resolves ECO-4821.
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    2dcf4ed View commit details
    Browse the repository at this point in the history
  8. Generate reports on private API usage

    This uses the data gathered in 2dcf4ed to generate some CSV reports
    about private API usage in the test suite. We’ll use these reports as a
    starting point for deciding how to remove this private API usage when
    reusing the test suite as a unified test suite for all our client
    libraries.
    
    Resolves ECO-4834.
    lawrence-forooghian committed Jul 24, 2024
    Configuration menu
    Copy the full SHA
    f770124 View commit details
    Browse the repository at this point in the history