kibana/x-pack/plugins/uptime
Mikhail Shustov a15178a1b0
[7.x] ES client : use the new type definitions (#83808) (#95391)
* ES client : use the new type definitions (#83808)

* Use client from branch

* Get type checking working in core

* Fix types in other plugins

* Update client types + remove type errors from core

* migrate Task Manager Elasticsearch typing from legacy library to client library

* use SortOrder instead o string in alerts

* Update client types + fix core type issues

* fix maps ts errors

* Update Lens types

* Convert Search Profiler body from a string to an object to conform to SearchRequest type.

* Fix SOT types

* Fix/mute Security/Spaces plugins type errors.

* Fix bootstrap types

* Fix painless_lab

* corrected es typing in Event Log

* Use new types from client for inferred search responses

* Latest type defs

* Integrate latest type defs for APM/UX

* fix core errors

* fix telemetry errors

* fix canvas errors

* fix data_enhanced errors

* fix event_log errors

* mute lens errors

* fix or mute maps errors

* fix reporting errors

* fix security errors

* mute errors in task_manager

* fix errors in telemetry_collection_xpack

* fix errors in data plugins

* fix errors in alerts

* mute errors in index_management

* fix task_manager errors

* mute or fix lens errors

* fix upgrade_assistant errors

* fix or mute errors in index_lifecycle_management

* fix discover errors

* fix core tests

* ML changes

* fix core type errors

* mute error in kbn-es-archiver

* fix error in data plugin

* fix error in telemetry plugin

* fix error in discover

* fix discover errors

* fix errors in task_manager

* fix security errors

* fix wrong conflict resolution

* address errors with upstream code

* update deps to the last commit

* remove outdated comments

* fix core errors

* fix errors after update

* adding more expect errors to ML

* pull the lastest changes

* fix core errors

* fix errors in infra plugin

* fix errors in uptime plugin

* fix errors in ml

* fix errors in xpack telemetry

* fix or mute errors in transform

* fix errors in upgrade assistant

* fix or mute fleet errors

* start fixing apm errors

* fix errors in osquery

* fix telemetry tests

* core cleanup

* fix asMutableArray imports

* cleanup

* data_enhanced cleanup

* cleanup events_log

* cleaup

* fix error in kbn-es-archiver

* fix errors in kbn-es-archiver

* fix errors in kbn-es-archiver

* fix ES typings for Hit

* fix SO

* fix actions plugin

* fix fleet

* fix maps

* fix stack_alerts

* fix eslint problems

* fix event_log unit tests

* fix failures in data_enhanced tests

* fix test failure in kbn-es-archiver

* fix test failures in index_pattern_management

* fixing ML test

* remove outdated comment in kbn-es-archiver

* fix error type in ml

* fix eslint errors in osquery plugin

* fix runtime error in infra plugin

* revert changes to event_log cluser exist check

* fix eslint error in osquery

* fixing ML endpoint argument types

* fx types

* Update api-extractor docs

* attempt fix for ese test

* Fix lint error

* Fix types for ts refs

* Fix data_enhanced unit test

* fix lens types

* generate docs

* Fix a number of type issues in monitoring and ml

* fix triggers_actions_ui

* Fix ILM functional test

* Put search.d.ts typings back

* fix data plugin

* Update typings in typings/elasticsearch

* Update snapshots

* mute errors in task_manager

* mute fleet errors

* lens. remove unnecessary ts-expect-errors

* fix errors in stack_alerts

* mute errors in osquery

* fix errors in security_solution

* fix errors in lists

* fix errors in cases

* mute errors in search_examples

* use KibanaClient to enforce promise-based API

* fix errors in test/ folder

* update comment

* fix errors in x-pack/test folder

* fix errors in ml plugin

* fix optional fields in ml api_integartoon tests

* fix another casting problem in ml tests

* fix another ml test failure

* fix fleet problem after conflict resolution

* rollback changes in security_solution. trying to fix test

* Update type for discover rows

* uncomment runtime_mappings as its outdated

* address comments from Wylie

* remove eslint error due to any

* mute error due to incompatibility

* Apply suggestions from code review

Co-authored-by: John Schulz <github.com@jfsiii.org>

* fix type error in lens tests

* Update x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.ts

Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>

* Update x-pack/plugins/upgrade_assistant/server/lib/reindexing/reindex_service.test.ts

Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>

* update deps

* fix errors in core types

* fix errors for the new elastic/elasticsearch version

* remove unused type

* remove unnecessary manual type cast and put optional chaining back

* ML: mute Datafeed is missing indices_options

* Apply suggestions from code review

Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com>

* use canary pacakge instead of git commit

Co-authored-by: Josh Dover <me@joshdover.com>
Co-authored-by: Josh Dover <1813008+joshdover@users.noreply.github.com>
Co-authored-by: Gidi Meir Morris <github@gidi.io>
Co-authored-by: Nathan Reese <reese.nathan@gmail.com>
Co-authored-by: Wylie Conlon <wylieconlon@gmail.com>
Co-authored-by: CJ Cenizal <cj@cenizal.com>
Co-authored-by: Aleh Zasypkin <aleh.zasypkin@gmail.com>
Co-authored-by: Dario Gieselaar <dario.gieselaar@elastic.co>
Co-authored-by: restrry <restrry@gmail.com>
Co-authored-by: James Gowdy <jgowdy@elastic.co>
Co-authored-by: John Schulz <github.com@jfsiii.org>
Co-authored-by: Alison Goryachev <alisonmllr20@gmail.com>
# Conflicts:
#	package.json
#	src/core/server/saved_objects/migrationsv2/integration_tests/migration.test.ts
#	src/plugins/data/server/autocomplete/value_suggestions_route.ts
#	src/plugins/discover/public/application/angular/doc_table/create_doc_table_react.tsx
#	x-pack/plugins/apm/server/lib/services/get_service_dependencies/get_destination_map.ts
#	x-pack/plugins/infra/server/lib/alerting/inventory_metric_threshold/evaluate_condition.ts
#	x-pack/plugins/security/server/authentication/api_keys/api_keys.ts
#	yarn.lock

* fix file broken during conflict resolution

* fix lint errors and test failure

Co-authored-by: Tomas Della Vedova <delvedor@users.noreply.github.com>
2021-03-25 10:33:44 -04:00
..
common [7.x] ES client : use the new type definitions (#83808) (#95391) 2021-03-25 10:33:44 -04:00
public [Uptime] Synthetic check steps list view (#90978) (#94716) 2021-03-17 09:29:24 -04:00
server [7.x] ES client : use the new type definitions (#83808) (#95391) 2021-03-25 10:33:44 -04:00
jest.config.js
kibana.json Rename alerts plugin to alerting (#92898) (#93827) 2021-03-05 21:38:33 -05:00
README.md
tsconfig.json Rename alerts plugin to alerting (#92898) (#93827) 2021-03-05 21:38:33 -05:00

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 connected 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