-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add TcpCheck construct [sc-22430] (#1012)
* feat: added tcp check construct [sc-22430] * feat: hide misleading url property from the user, use hostname instead * chore: add unit tests for TcpCheck (copied from ApiCheck) * chore: add a TcpCheck to e2e tests * feat: support all current TCP check features * fix: remove bodyType from TcpCheck, it has no purpose currently * refactor: update to new API schema * fix: responseData assertion does not have properties * Revert "fix: responseData assertion does not have properties" The property could be a regex, like with API checks and TEXT_BODY, so expose it after all. This reverts commit 2c7b8b8. * chore: fix variable name in tests * fix(tests): use our site for snapshots instead of an external page that's down --------- Co-authored-by: ejanusevicius <[email protected]>
- Loading branch information
1 parent
0173d7b
commit 9331762
Showing
10 changed files
with
377 additions
and
147 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
13 changes: 13 additions & 0 deletions
13
packages/cli/e2e/__tests__/fixtures/deploy-project/tcp.check.ts
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,13 @@ | ||
/* eslint-disable no-new */ | ||
import { TcpCheck } from 'checkly/constructs' | ||
|
||
new TcpCheck('tcp-check', { | ||
name: 'TCP Check', | ||
activated: false, | ||
request: { | ||
hostname: 'api.checklyhq.com', | ||
port: 443, | ||
}, | ||
degradedResponseTime: 5000, | ||
maxResponseTime: 20000, | ||
}) |
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
Binary file removed
BIN
-76.7 KB
...-project/snapshot-test.spec.ts-snapshots/WWW-Snapshot-Test-1-chromium-linux.png
Binary file not shown.
Binary file added
BIN
+19.9 KB
...ject/snapshot-test.spec.ts-snapshots/Welcome-Snapshot-Test-1-chromium-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 103 additions & 0 deletions
103
packages/cli/src/constructs/__tests__/tcp-check.spec.ts
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,103 @@ | ||
import { TcpCheck, CheckGroup, TcpRequest } from '../index' | ||
import { Project, Session } from '../project' | ||
|
||
const runtimes = { | ||
'2022.10': { name: '2022.10', default: false, stage: 'CURRENT', description: 'Main updates are Playwright 1.28.0, Node.js 16.x and Typescript support. We are also dropping support for Puppeteer', dependencies: { '@playwright/test': '1.28.0', '@opentelemetry/api': '1.0.4', '@opentelemetry/sdk-trace-base': '1.0.1', '@faker-js/faker': '5.5.3', aws4: '1.11.0', axios: '0.27.2', btoa: '1.2.1', chai: '4.3.7', 'chai-string': '1.5.0', 'crypto-js': '4.1.1', expect: '29.3.1', 'form-data': '4.0.0', jsonwebtoken: '8.5.1', lodash: '4.17.21', mocha: '10.1.0', moment: '2.29.2', node: '16.x', otpauth: '9.0.2', playwright: '1.28.0', typescript: '4.8.4', uuid: '9.0.0' } }, | ||
} | ||
|
||
const request: TcpRequest = { | ||
hostname: 'acme.com', | ||
port: 443, | ||
} | ||
|
||
describe('TcpCheck', () => { | ||
it('should not synthesize runtime if not specified even if default runtime is set', () => { | ||
Session.project = new Project('project-id', { | ||
name: 'Test Project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
}) | ||
Session.availableRuntimes = runtimes | ||
Session.defaultRuntimeId = '2022.02' | ||
const check = new TcpCheck('test-check', { | ||
name: 'Test Check', | ||
request, | ||
}) | ||
const payload = check.synthesize() | ||
expect(payload.runtimeId).toBeUndefined() | ||
delete Session.defaultRuntimeId | ||
}) | ||
|
||
it('should synthesize runtime if specified', () => { | ||
Session.project = new Project('project-id', { | ||
name: 'Test Project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
}) | ||
Session.availableRuntimes = runtimes | ||
Session.defaultRuntimeId = '2022.02' | ||
const check = new TcpCheck('test-check', { | ||
name: 'Test Check', | ||
runtimeId: '2022.02', | ||
request, | ||
}) | ||
const payload = check.synthesize() | ||
expect(payload.runtimeId).toEqual('2022.02') | ||
delete Session.defaultRuntimeId | ||
}) | ||
|
||
it('should apply default check settings', () => { | ||
Session.project = new Project('project-id', { | ||
name: 'Test Project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
}) | ||
Session.checkDefaults = { tags: ['default tags'] } | ||
const check = new TcpCheck('test-check', { | ||
name: 'Test Check', | ||
request, | ||
}) | ||
delete Session.checkDefaults | ||
expect(check).toMatchObject({ tags: ['default tags'] }) | ||
}) | ||
|
||
it('should overwrite default check settings with check-specific config', () => { | ||
Session.project = new Project('project-id', { | ||
name: 'Test Project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
}) | ||
Session.checkDefaults = { tags: ['default tags'] } | ||
const check = new TcpCheck('test-check', { | ||
name: 'Test Check', | ||
tags: ['test check'], | ||
request, | ||
}) | ||
delete Session.checkDefaults | ||
expect(check).toMatchObject({ tags: ['test check'] }) | ||
}) | ||
|
||
it('should support setting groups with `groupId`', () => { | ||
Session.project = new Project('project-id', { | ||
name: 'Test Project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
}) | ||
const group = new CheckGroup('main-group', { name: 'Main Group', locations: [] }) | ||
const check = new TcpCheck('main-check', { | ||
name: 'Main Check', | ||
request, | ||
groupId: group.ref(), | ||
}) | ||
expect(check.synthesize()).toMatchObject({ groupId: { ref: 'main-group' } }) | ||
}) | ||
|
||
it('should support setting groups with `group`', () => { | ||
Session.project = new Project('project-id', { | ||
name: 'Test Project', | ||
repoUrl: 'https://github.com/checkly/checkly-cli', | ||
}) | ||
const group = new CheckGroup('main-group', { name: 'Main Group', locations: [] }) | ||
const check = new TcpCheck('main-check', { | ||
name: 'Main Check', | ||
request, | ||
group, | ||
}) | ||
expect(check.synthesize()).toMatchObject({ groupId: { ref: 'main-group' } }) | ||
}) | ||
}) |
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
Oops, something went wrong.