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

test: simplify endpoint integration tests #6373

Merged
merged 15 commits into from
Aug 12, 2024

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Aug 9, 2024

Issue

Internal JS-5234

Description

Simplifies endpoint integration tests as follows:

  • removes unused variables/functions
  • use describe.each
  • pass namespace when running tests
  • run tests which were skipped in the past

Testing

Before

$ yarn jest -c tests/endpoints-2.0/jest.config.js tests/endpoints-2.0/endpoints-integration.spec.ts
...
Test Suites: 1 passed, 1 total
Tests:       124 skipped, 14548 passed, 14672 total

After

$ yarn jest -c tests/endpoints-2.0/jest.config.js tests/endpoints-2.0/endpoints-integration.spec.ts
...
Test Suites: 1 passed, 1 total
Tests:       14672 passed, 14672 total

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr force-pushed the refactor-endpoints-integration-test branch from 4bb89fa to c366769 Compare August 9, 2024 19:25
trivikr added 3 commits August 9, 2024 19:34
Test Suites: 1 failed, 1 total
Tests:       22 failed, 124 skipped, 14526 passed, 14672 total
Snapshots:   0 total
Time:        61.488 s
@trivikr
Copy link
Member Author

trivikr commented Aug 9, 2024

Following tests are failing after passing Command from namespace

$ yarn jest -c tests/endpoints-2.0/jest.config.js tests/endpoints-2.0/endpoints-integration.spec.ts
...
● client list › client-s3-control endpoint test cases › Vanilla outposts without ARN region + access point ARN@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-west-2.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › Vanilla outposts with ARN region + access point ARN@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-east-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › accept an access point ARN@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-west-2.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › vanilla outposts china@cn-north-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.cn-north-1.amazonaws.com.cn/"
    Received string:    "https://123456789012.s3-control.cn-north-1.amazonaws.com.cn/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › gov region@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-west-2.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › gov cloud with fips@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts-fips.us-west-2.amazonaws.com/"
    Received string:    "https://123456789012.s3-control-fips.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › govcloud with fips + arn region@us-gov-west-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control-fips.us-gov-west-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › gov region@cn-north-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.cn-north-1.amazonaws.com.cn/"
    Received string:    "https://123456789012.s3-control.cn-north-1.amazonaws.com.cn/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › gov cloud with fips@cn-north-1

    EndpointError: Partition does not support FIPS

      85 |                 params
      86 |               )) as EndpointParams;
    > 87 |               const observed = resolveEndpoint(ruleSet, { endpointParams });
         |                                               ^
      88 |               assertEndpointResolvedCorrectly(endpoint, observed);
      89 |             }
      90 |           } else {

      at evaluateErrorRule (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:401:9)
      at evaluateRules (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:431:7)
      at evaluateTreeRule (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:416:10)
      at evaluateRules (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:433:35)
      at evaluateTreeRule (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:416:10)
      at evaluateRules (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:433:35)
      at evaluateTreeRule (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:416:10)
      at evaluateRules (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:433:35)
      at resolveEndpoint (../../node_modules/@smithy/util-endpoints/dist-cjs/index.js:462:20)
      at Object.<anonymous> (endpoints-integration.spec.ts:87:47)

  ● client list › client-s3-control endpoint test cases › govcloud with fips + arn region@us-gov-west-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control-fips.us-gov-west-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › gov region@af-south-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.af-south-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.af-south-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › gov cloud with fips@af-south-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts-fips.af-south-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control-fips.af-south-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › govcloud with fips + arn region@us-gov-west-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts-fips.us-gov-east-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control-fips.us-gov-west-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › outpost access points support dualstack@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-west-2.api.aws/"
    Received string:    "https://123456789012.s3-control.dualstack.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › outpost access points support dualstack@af-south-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.af-south-1.api.aws/"
    Received string:    "https://123456789012.s3-control.dualstack.af-south-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › outpost access points support fips + dualstack@af-south-1

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts-fips.af-south-1.api.aws/"
    Received string:    "https://123456789012.s3-control-fips.dualstack.af-south-1.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › Account ID set inline and in ARN but they both match@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-west-2.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › Account ID set inline and in ARN and they do not match@us-west-2

    expect(received).toBeUndefined()

    Received: "https://999999999999.s3-control.us-west-2.amazonaws.com/"

      107 |               const observedError = await (async () => defaultEndpointResolver(endpointParams as any))().catch(pass);
      108 |               expect(observedError).not.toBeUndefined();
    > 109 |               expect(observedError?.url).toBeUndefined();
          |                                          ^
      110 |               // expect(normalizeQuotes(String(observedError))).toContain(normalizeQuotes(error));
      111 |             }
      112 |           } else {

      at Object.<anonymous> (endpoints-integration.spec.ts:109:42)

  ● client list › client-s3-control endpoint test cases › endpoint url with s3-outposts@us-west-2

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://beta.example.com/"
    Received string:    "https://123456789012.beta.example.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › Outpost Accesspoint ARN with arn region and client region mismatch with UseArnRegion=false

    expect(received).toBeUndefined()

    Received: "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      107 |               const observedError = await (async () => defaultEndpointResolver(endpointParams as any))().catch(pass);
      108 |               expect(observedError).not.toBeUndefined();
    > 109 |               expect(observedError?.url).toBeUndefined();
          |                                          ^
      110 |               // expect(normalizeQuotes(String(observedError))).toContain(normalizeQuotes(error));
      111 |             }
      112 |           } else {

      at Object.<anonymous> (endpoints-integration.spec.ts:109:42)

  ● client list › client-s3-control endpoint test cases › Accesspoint ARN with region mismatch and UseArnRegion unset

    expect(received).toContain(expected) // indexOf

    Expected substring: "https://s3-outposts.us-east-1.amazonaws.com/"
    Received string:    "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      129 |   const { authSchemes } = properties || {};
      130 |   if (url) {
    > 131 |     expect(observed.url.href).toContain(new URL(url).href);
          |                               ^
      132 |     expect(Math.abs(observed.url.href.length - url.length)).toBeLessThan(2);
      133 |   }
      134 |   if (headers) {

      at assertEndpointResolvedCorrectly (endpoints-integration.spec.ts:131:31)
      at Object.<anonymous> (endpoints-integration.spec.ts:88:15)

  ● client list › client-s3-control endpoint test cases › Accesspoint ARN with partition mismatch and UseArnRegion=true

    expect(received).toBeUndefined()

    Received: "https://123456789012.s3-control.us-west-2.amazonaws.com/"

      107 |               const observedError = await (async () => defaultEndpointResolver(endpointParams as any))().catch(pass);
      108 |               expect(observedError).not.toBeUndefined();
    > 109 |               expect(observedError?.url).toBeUndefined();
          |                                          ^
      110 |               // expect(normalizeQuotes(String(observedError))).toContain(normalizeQuotes(error));
      111 |             }
      112 |           } else {

      at Object.<anonymous> (endpoints-integration.spec.ts:109:42)

Test Suites: 1 failed, 1 total
Tests:       22 failed, 124 skipped, 14526 passed, 14672 total
Snapshots:   0 total
Time:        28.648 s

@trivikr
Copy link
Member Author

trivikr commented Aug 12, 2024

The fix in #6376 was verified

$ yarn jest -c tests/endpoints-2.0/jest.config.js tests/endpoints-2.0/endpoints-integration.spec.ts
...
Test Suites: 1 passed, 1 total
Tests:       124 skipped, 14548 passed, 14672 total
Snapshots:   0 total
Time:        23.957 s, estimated 29 s

@trivikr trivikr marked this pull request as ready for review August 12, 2024 20:57
@trivikr trivikr requested a review from a team as a code owner August 12, 2024 20:57
@trivikr trivikr merged commit 88d384c into aws:main Aug 12, 2024
5 checks passed
@trivikr trivikr deleted the refactor-endpoints-integration-test branch August 12, 2024 21:21
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 27, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants