-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't retry flushing CloudWatch metrics (#720)
* Don't retry flushing CloudWatch metrics The api for flushing metrics is rate limited, in high load environments this may cause performance issues as we wait for this call to finish so if it fails we will not retry. Co-authored-by: Oliver Brook <[email protected]>
- Loading branch information
Showing
5 changed files
with
74 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
packages/pwa-kit-runtime/src/utils/ssr-server/utils.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (c) 2022, Salesforce, Inc. | ||
* All rights reserved. | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause | ||
*/ | ||
import * as utils from './utils' | ||
|
||
describe.each([[true], [false]])('Utils remote/local tests (isRemote: %p)', (isRemote) => { | ||
let originalEnv | ||
const bundleId = 'test-bundle-id-12345' | ||
|
||
beforeEach(() => { | ||
originalEnv = process.env | ||
process.env = Object.assign({}, process.env) | ||
process.env.BUNDLE_ID = bundleId | ||
if (isRemote) { | ||
process.env.AWS_LAMBDA_FUNCTION_NAME = 'remote-test-name' | ||
} | ||
}) | ||
|
||
afterEach(() => { | ||
process.env = originalEnv | ||
jest.restoreAllMocks() | ||
}) | ||
|
||
test(`getBundleBaseUrl should return the correct URL`, () => { | ||
const expectedId = isRemote ? bundleId : 'development' | ||
const expected = `/mobify/bundle/${expectedId}/` | ||
expect(utils.getBundleBaseUrl()).toBe(expected) | ||
}) | ||
|
||
describe.each([[true], [false]])('Quiet/loud tests', (quiet) => { | ||
let originalQuiet | ||
|
||
beforeEach(() => { | ||
originalQuiet = utils.isQuiet() | ||
utils.setQuiet(quiet) | ||
}) | ||
|
||
afterEach(() => { | ||
utils.setQuiet(originalQuiet) | ||
jest.restoreAllMocks() | ||
}) | ||
|
||
test(`localDevLog should log conditionally (quiet: ${quiet})`, () => { | ||
const log = jest.spyOn(console, 'log').mockImplementation(() => {}) | ||
const msg = 'message' | ||
utils.localDevLog(msg) | ||
const expected = !isRemote && !quiet ? [[msg]] : [] | ||
expect(log.mock.calls).toEqual(expected) | ||
}) | ||
|
||
test(`infoLog should log conditionally (quiet: ${quiet})`, () => { | ||
const log = jest.spyOn(console, 'log').mockImplementation(() => {}) | ||
const msg = 'message' | ||
utils.infoLog(msg) | ||
const expected = !quiet ? [[msg]] : [] | ||
expect(log.mock.calls).toEqual(expected) | ||
}) | ||
}) | ||
}) |