-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #513 from snyk/feat/ED-215_conditional-preflight-c…
…hecks-loading feat: load rest-api-status preflight check only if high availability mode is enabled [ED-251]
- Loading branch information
Showing
9 changed files
with
108 additions
and
42 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
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,28 @@ | ||
import { Check } from '../../lib/client/checks/types'; | ||
import { Config } from '../../lib/client/config'; | ||
|
||
export const aCheck = (fields: Partial<Check>): Check => { | ||
const id = `check_${Date.now()}`; | ||
return { | ||
checkId: id, | ||
checkName: id, | ||
url: 'http://localhost:8080/check-url', | ||
active: true, | ||
timeoutMs: 500, | ||
...fields, | ||
}; | ||
}; | ||
|
||
/** | ||
* Config with all features disabled. | ||
*/ | ||
export const aConfig = (fields: Partial<Config>): Config => { | ||
return { | ||
API_BASE_URL: 'http://api:8080', | ||
BROKER_DISPATCHER_BASE_URL: 'http://dispatcher:8080', | ||
BROKER_HA_MODE_ENABLED: 'false', | ||
BROKER_SERVER_URL: 'http://broker-server:8080', | ||
PREFLIGHT_CHECKS_ENABLED: 'false', | ||
...fields, | ||
}; | ||
}; |
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,29 @@ | ||
import { aConfig } from '../../../helpers/test-factories'; | ||
import { checksConfig } from '../../../../lib/client/checks'; | ||
import { createRestApiHealthcheck } from '../../../../lib/client/checks/http/http-checks'; | ||
|
||
describe('preflight-checks-config', () => { | ||
it('should contain rest-api-status check if high availability mode is enabled', async () => { | ||
const config = aConfig({ | ||
BROKER_HA_MODE_ENABLED: 'true', | ||
}); | ||
const restApiCheck = createRestApiHealthcheck(config); | ||
const { preflightCheckStore } = await checksConfig(config); | ||
|
||
const actualChecks = await preflightCheckStore.getAll(); | ||
|
||
expect(actualChecks).toContainEqual(restApiCheck); | ||
}); | ||
|
||
it('should not contain rest-api-status check if high availability mode is disabled', async () => { | ||
const config = aConfig({ | ||
BROKER_HA_MODE_ENABLED: 'false', | ||
}); | ||
const restApiCheck = createRestApiHealthcheck(config); | ||
const { preflightCheckStore } = await checksConfig(config); | ||
|
||
const actualChecks = await preflightCheckStore.getAll(); | ||
|
||
expect(actualChecks).not.toContainEqual(restApiCheck); | ||
}); | ||
}); |
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