Skip to content
This repository has been archived by the owner on Jul 18, 2024. It is now read-only.

Cloud9 setup fails on integration tests #158

Open
matscarrgard opened this issue Jan 19, 2021 · 0 comments
Open

Cloud9 setup fails on integration tests #158

matscarrgard opened this issue Jan 19, 2021 · 0 comments

Comments

@matscarrgard
Copy link

matscarrgard commented Jan 19, 2021

After running the 'make setup-cloud9' and 'make setup' script, running the 'make all' script, the setup fails during the integration tests:

[*] \033[0;96mtests-integ delivery-pricing\033[0m
make[3]: Entering directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/delivery-pricing' make[3]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/delivery-pricing'
make[2]: Leaving directory `/home/ec2-user/environment/aws-serverless-ecommerce-platform'

Package artifacts

if [ ! -d build/artifacts/ ]; then
mkdir build/artifacts/ ;
fi
/home/ec2-user/environment/aws-serverless-ecommerce-platform/tools/helpers/build_artifacts . build/artifacts/
make[3]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p' make[2]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform'
make[2]: Entering directory /home/ec2-user/environment/aws-serverless-ecommerce-platform' [*] \033[0;96mtests-unit payment-3p\033[0m make[3]: Entering directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p'
npm run tests-unit

[email protected] tests-unit /home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p
jest --projects unit.jest.config.js

jest-haste-map: Haste module naming collision: check
The following files share their name; please adjust your hasteImpl:
* /src/cancelPayment/package.json
* /src/check/package.json

jest-haste-map: Haste module naming collision: preauth
The following files share their name; please adjust your hasteImpl:
* /src/preauth/package.json
* /build/src/preauth/package.json

PASS tests/unit/updateAmount.test.ts (14.362 s)
● Console

console.log
  { message: 'Error updating the paymentToken in the database',
    errormsg:
     Error: 
         at Function.AWSMock.mock (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/updateAmount.test.ts:91:18)
         at DocumentClient.<anonymous> (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/aws-sdk-mock/index.js:205:28)
         at Object.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/behavior.js:163:32)
         at DocumentClient.functionStub (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/stub.js:39:43)
         at Function.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy-invoke.js:47:47)
         at DocumentClient.get (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy.js:225:26)
         at Object.updateAmount (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/src/updateAmount/index.ts:32:39)
         at Object.<anonymous>.test (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/updateAmount.test.ts:99:29)
         at Object.asyncJestTest (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)
         at resolve (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:45:12)
         at new Promise (<anonymous>)
         at mapper (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:28:19)
         at promise.then (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:75:41) }

  at Object.updateAmount (src/updateAmount/index.ts:57:17)

console.log
  { message: 'Error updating the paymentToken in the database',
    errormsg:
     Error: 
         at Function.AWSMock.mock (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/updateAmount.test.ts:120:18)
         at DocumentClient.<anonymous> (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/aws-sdk-mock/index.js:205:28)
         at Object.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/behavior.js:163:32)
         at DocumentClient.functionStub (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/stub.js:39:43)
         at Function.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy-invoke.js:47:47)
         at DocumentClient.put (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy.js:225:26)
         at Object.updateAmount (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/src/updateAmount/index.ts:47:22) }

  at Object.updateAmount (src/updateAmount/index.ts:57:17)

PASS tests/unit/check.test.ts (5.224 s)
● Console

console.log
  { message: 'Error retrieving the paymentToken from the database',
    errormsg:
     Error: 
         at Function.AWSMock.mock (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/check.test.ts:77:18)
         at DocumentClient.<anonymous> (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/aws-sdk-mock/index.js:205:28)
         at Object.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/behavior.js:163:32)
         at DocumentClient.functionStub (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/stub.js:39:43)
         at Function.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy-invoke.js:47:47)
         at DocumentClient.get (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy.js:225:26)
         at Object.checkToken (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/src/check/index.ts:30:39)
         at Object.<anonymous>.test (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/check.test.ts:81:29)
         at Object.asyncJestTest (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)
         at resolve (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:45:12)
         at new Promise (<anonymous>)
         at mapper (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:28:19)
         at promise.then (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:75:41) }

  at Object.checkToken (src/check/index.ts:38:17)

PASS tests/unit/preauth.test.ts
● Console

console.log
  { message: 'Error storing payment token in database',
    errormsg:
     Error: 
         at Function.AWSMock.mock (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/preauth.test.ts:42:18)
         at DocumentClient.<anonymous> (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/aws-sdk-mock/index.js:205:28)
         at Object.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/behavior.js:163:32)
         at DocumentClient.functionStub (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/stub.js:39:43)
         at Function.invoke (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy-invoke.js:47:47)
         at DocumentClient.put (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/sinon/lib/sinon/proxy.js:225:26)
         at Object.genToken (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/src/preauth/index.ts:33:22)
         at Object.<anonymous>.test (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/tests/unit/preauth.test.ts:45:29)
         at Object.asyncJestTest (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/jasmineAsyncInstall.js:106:37)
         at resolve (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:45:12)
         at new Promise (<anonymous>)
         at mapper (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:28:19)
         at promise.then (/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/jest-jasmine2/build/queueRunner.js:75:41) }

  at Object.genToken (src/preauth/index.ts:42:17)

RUNS tests/unit/processPayment.test.ts

<--- Last few GCs --->

[660:0x42f6830] 42302 ms: Mark-sweep 1389.8 (1424.6) -> 1389.1 (1425.1) MB, 1147.5 / 0.0 ms (average mu = 0.169, current mu = 0.005) allocation failure scavenge might not succeed
[660:0x42f6830] 43430 ms: Mark-sweep 1389.9 (1425.1) -> 1389.5 (1425.1) MB, 1121.8 / 0.0 ms (average mu = 0.092, current mu = 0.005) allocation failure scavenge might not succeed

<--- JS stacktrace --->

==== JS stack trace =========================================

0: ExitFrame [pc: 0x38137475bf1d]
1: StubFrame [pc: 0x3813747110cb]

Security context: 0x1ba27d91e6c1
2: getTokenText [0x3b141c760021] [/home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p/node_modules/typescript/lib/typescript.js:~9959] [pc=0x381374d95d6a](this=0x12f886405fb1 )
3: /* anonymous /(aka / anonymous */) [0x3be23bfc94b9] [/home/ec2-user/environment/aws...

FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x8fb090 node::Abort() [node]
2: 0x8fb0dc [node]
3: 0xb0336e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb035a4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xef7602 [node]
6: 0xef7708 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [node]
7: 0xf037e2 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [node]
8: 0xf04114 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [node]
9: 0xf06d81 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [node]
10: 0xed0204 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [node]
11: 0x11702de v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [node]
12: 0x38137475bf1d
make[3]: *** [tests-unit] Aborted
make[3]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/payment-3p' make[2]: *** [tests-unit-payment-3p] Error 2 make[2]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform'
make[1]: *** [all-payment-3p] Error 2
make[1]: *** Waiting for unfinished jobs....
make[3]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/platform' make[2]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform'
make[2]: Entering directory /home/ec2-user/environment/aws-serverless-ecommerce-platform' [*] \033[0;96mtests-integ platform\033[0m make[3]: Entering directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/platform'
============================= test session starts ==============================
platform linux -- Python 3.8.1, pytest-5.4.3, py-1.10.0, pluggy-0.13.1
rootdir: /home/ec2-user/environment/aws-serverless-ecommerce-platform/platform
plugins: cov-2.8.1, requests-mock-1.7.0
collected 1 item

tests/integ/test_on_events.py F [100%]

=================================== FAILURES ===================================
________________________________ test_listener _________________________________

listener = <function listener.._listener at 0x7f393402d8b0>
event_bus_name = 'ecommerce-dev'

def test_listener(listener, event_bus_name):
    service_name = "ecommerce.test"
    resource = str(uuid.uuid4())
    event_type = "TestEvent"

    events = boto3.client("events")
  listener(service_name, lambda:
        events.put_events(Entries=[{
            "Time": datetime.datetime.utcnow(),
            "Source": service_name,
            "Resources": [resource],
            "DetailType": event_type,
            "Detail": "{}",
            "EventBusName": event_bus_name
        }]),
        lambda x: (
            x["source"] == service_name and
            x["resources"][0] == resource and
            x["detail-type"] == event_type
        )
    )

tests/integ/test_on_events.py:34:


../shared/tests/integ/fixtures.py:120: in _listener
return asyncio.run(_listen())
../../../.pyenv/versions/3.8.1/lib/python3.8/asyncio/runners.py:43: in run
return loop.run_until_complete(main)
../../../.pyenv/versions/3.8.1/lib/python3.8/asyncio/base_events.py:612: in run_until_complete
return future.result()
../shared/tests/integ/fixtures.py:82: in _listen
async with websockets.connect(listener_api_url, extra_headers=headers) as websocket:
../../../.pyenv/versions/3.8.1/envs/ecommerce-platform/lib/python3.8/site-packages/websockets/client.py:517: in aenter
return await self
../../../.pyenv/versions/3.8.1/envs/ecommerce-platform/lib/python3.8/site-packages/websockets/client.py:542: in await_impl
await protocol.handshake(


self = <websockets.client.WebSocketClientProtocol object at 0x7f39340275b0>
wsuri = WebSocketURI(secure=True, host='x1x9uipp31.execute-api.eu-west-1.amazonaws.com', port=443, resource_name='/prod/', user_info=None)
origin = None
available_extensions = [<websockets.extensions.permessage_deflate.ClientPerMessageDeflateFactory object at 0x7f3934027520>]
available_subprotocols = None
extra_headers = dict_items([('x-amz-date', '20210119T072039Z'), ('Authorization', 'AWS4-HMAC-SHA256 Credential=ASIASLCIY55SJY5TPC6I/20..._request, SignedHeaders=host;x-amz-date, Signature=a514c06074e6bc6e8254f2798d31ac68f5f5c9a3b72b33943727f365336aa372')])

async def handshake(
    self,
    wsuri: WebSocketURI,
    origin: Optional[Origin] = None,
    available_extensions: Optional[Sequence[ClientExtensionFactory]] = None,
    available_subprotocols: Optional[Sequence[Subprotocol]] = None,
    extra_headers: Optional[HeadersLike] = None,
) -> None:
    """
    Perform the client side of the opening handshake.

    :param origin: sets the Origin HTTP header
    :param available_extensions: list of supported extensions in the order
        in which they should be used
    :param available_subprotocols: list of supported subprotocols in order
        of decreasing preference
    :param extra_headers: sets additional HTTP request headers; it must be
        a :class:`~websockets.http.Headers` instance, a
        :class:`~collections.abc.Mapping`, or an iterable of ``(name,
        value)`` pairs
    :raises ~websockets.exceptions.InvalidHandshake: if the handshake
        fails

    """
    request_headers = Headers()

    if wsuri.port == (443 if wsuri.secure else 80):  # pragma: no cover
        request_headers["Host"] = wsuri.host
    else:
        request_headers["Host"] = f"{wsuri.host}:{wsuri.port}"

    if wsuri.user_info:
        request_headers["Authorization"] = build_authorization_basic(
            *wsuri.user_info
        )

    if origin is not None:
        request_headers["Origin"] = origin

    key = build_request(request_headers)

    if available_extensions is not None:
        extensions_header = build_extension(
            [
                (extension_factory.name, extension_factory.get_request_params())
                for extension_factory in available_extensions
            ]
        )
        request_headers["Sec-WebSocket-Extensions"] = extensions_header

    if available_subprotocols is not None:
        protocol_header = build_subprotocol(available_subprotocols)
        request_headers["Sec-WebSocket-Protocol"] = protocol_header

    if extra_headers is not None:
        if isinstance(extra_headers, Headers):
            extra_headers = extra_headers.raw_items()
        elif isinstance(extra_headers, collections.abc.Mapping):
            extra_headers = extra_headers.items()
        for name, value in extra_headers:
            request_headers[name] = value

    request_headers.setdefault("User-Agent", USER_AGENT)

    self.write_http_request(wsuri.resource_name, request_headers)

    status_code, response_headers = await self.read_http_response()
    if status_code in (301, 302, 303, 307, 308):
        if "Location" not in response_headers:
            raise InvalidHeader("Location")
        raise RedirectHandshake(response_headers["Location"])
    elif status_code != 101:
      raise InvalidStatusCode(status_code)

E websockets.exceptions.InvalidStatusCode: server rejected WebSocket connection: HTTP 403

../../../.pyenv/versions/3.8.1/envs/ecommerce-platform/lib/python3.8/site-packages/websockets/client.py:296: InvalidStatusCode

  • generated xml file: /home/ec2-user/environment/aws-serverless-ecommerce-platform/reports/platform-integ.xml -
    =========================== short test summary info ============================
    FAILED tests/integ/test_on_events.py::test_listener - websockets.exceptions.I...
    ============================== 1 failed in 0.68s ===============================
    make[3]: *** [tests-integ] Error 1
    make[3]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform/platform' make[2]: *** [tests-integ-platform] Error 2 make[2]: Leaving directory /home/ec2-user/environment/aws-serverless-ecommerce-platform'
    make[1]: *** [all-platform] Error 2
    make[1]: Leaving directory `/home/ec2-user/environment/aws-serverless-ecommerce-platform'
    make: *** [all] Error 1

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

No branches or pull requests

1 participant