* Add new runtime types for parsing on client/server. * Add more runtime types. * Remove dead code. * Mark parameter as unused. * Improve typing for failed journey request function. * Add new API functions, improve typing in a few others. * Modify API calls to work with new screenshot_ref data. * Fix untested refactor error. * Add required fields to runtime type. * Update typing in failed steps component. * Adapt client to work with old screenshots as well as new screenshot_ref. * Refactor composite code to reusable hook. * Implement screenshot blocks endpoint. * Define runtime types for full-size screenshots. * Delete dedicated screenshot and ref queries. * Optimize screenshot endpoint by combining queries. * Handle parsing error. * Clean up screenshot/ref typings. * Remove dead types. DRY a type out. * Simplify types. * Improve typing in step screenshot components. * Prefer PNG to JPG for canvas composite op. * Simplify and clean up some code. * Remove reliance on `Ping` type, clean up types. * Add a comment. * Add a comment. * Fix typing for `FailedStep` component. * Standardize loading spinner sizes. * Add comments to composite code. * Remove unnecessary optional chaining. * Reformat error string. * Remove unneeded key from request return object. * Add a comment to a return object explaining very large cache value. * Make type annotation more accurate. * Resolve some type and test errors. * Clean up remaining type errors. * Move type definitions to simplify imports. * Simplify `PingTimestamp` interface. * Refactor failing unit test to use RTL and actually test things. * Add tests for new helper functions. * Add a comment. * Test `PingTimestamp` for screenshot ref data. * Test `StepImageCaption` for ref data. * Improve typing for step list column definitions. * Harden a test. * Extract code to avoid repeated declarations. * Create centralized mock for `useCompositeImage`. * Add test for ref to `StepScreenshotDisplay`. * Add tests for `getJourneyDetails`. * Extract search results wrapper to helper lib. * Add tests for `getJourneyFailedSteps`. * Add support for aggs to result helper wrapper. * Write tests for `getJourneyScreenshot` and simplify type checking. * Write tests for `getJourneyScreenshotBlocks`. * Simplify prop types for `FailedStep`. * Remove unused type. * Fix regression in step navigating for new style screenshots. * Implement PR feedback. * Implement PR feedback. * Implement PR feedback. * Reduce limit of screenshot block queries from 10k to 1k. * Remove redundant field selection from ES query. * Implement PR feedback. * Fix regression that caused "Last successful step" to not show an image. * Delete unused props from `Ping` runtime type. * More precise naming. * Naming improvements. Add `useCallback` to prevent callback re-declaration. * Prefer explicit props to `{...spread}` syntax. * Remove redundant type checking. * Delete obsolete unit tests. * Fix a regression. * Add effect to `useEffect`. |
||
---|---|---|
.. | ||
common | ||
public | ||
server | ||
jest.config.js | ||
kibana.json | ||
README.md | ||
tsconfig.json |
Uptime Monitoring
Purpose
The purpose of this plugin is to provide users of Heartbeat more visibility of what's happening in their infrastructure.
Layout
There are three sections to the app, common
, public
, and server
.
common
Contains runtime types types, constants and a few other files.
Notably, we use io-ts
/fp-ts
functions and types to help provide
additional runtime safety for our API requests/responses.
public
We use Redux and associated tools for managing our app state. Components come in the usual connect
ed and
presentational varieties.
The lib
directory controls bootstrapping code and adapter types.
There is a pages
directory; each view gets its own page component.
The principal structure of the app is stored in uptime_app.tsx
.
server
The lib
directory contains adapters
, which are connections to external resources like Kibana
Server, Elasticsearch, etc. In addition, it contains domains, which are libraries that provide
functionality via adapters.
The requests
directory contains functions responsible for querying Elasticsearch and parsing its
responses.
There's also a rest_api
folder that defines the structure of the RESTful API endpoints.
Testing
Unit tests
Documentation: https://www.elastic.co/guide/en/kibana/current/development-tests.html#_unit_testing
yarn test:jest x-pack/plugins/uptime
Functional tests
In one shell, from ~/kibana/x-pack:
node scripts/functional_tests_server.js
In another shell, from ~kibana/x-pack:
node ../scripts/functional_test_runner.js --grep="{TEST_NAME}"
.
API tests
If instead you need to run API tests, start up the test server and then in another shell, from ~kibana/x-pack:
node ../scripts/functional_test_runner.js --config test/api_integration/config.ts --grep="{TEST_NAME}"
.
You can update snapshots by prefixing the runner command with env UPDATE_UPTIME_FIXTURES=1
You can access the functional test server's Kibana at http://localhost:5620/
.
You can login with username elastic
and password changeme
by default.
If you want to freeze a UI or API test you can include an async call like await new Promise(r => setTimeout(r, 1000 * 60))
to freeze the execution for 60 seconds if you need to click around or check things in the state that is loaded.
Running --ssl tests
Some of our tests require there to be an SSL connection between Kibana and Elasticsearch.
We can run these tests like described above, but with some special config.
node scripts/functional_tests_server.js --config=test/functional_with_es_ssl/config.ts
node scripts/functional_test_runner.js --config=test/functional_with_es_ssl/config.ts
Running accessibility tests
We maintain a suite of Accessibility tests (you may see them referred to elsewhere as a11y
tests).
These tests render each of our pages and ensure that the inputs and other elements contain the attributes necessary to ensure all users are able to make use of Kibana (for example, users relying on screen readers).
The commands for running these tests are very similar to the other functional tests described above.
From the ~/x-pack
directory:
Start the server: node scripts/functional_tests_server --config test/accessibility/config.ts
Run the uptime a11y
tests: node scripts/functional_test_runner.js --config test/accessibility/config.ts --grep=uptime