-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Fleet] Display outputs in agent list table and agent details #195801
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
criamico
merged 29 commits into
elastic:main
from
criamico:192339_show_outputs_in_agents_table
Oct 22, 2024
Merged
Changes from 7 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
cdb906e
[Fleet] Display outputs in agent list table and agent details
criamico d88bdfe
Create component to render outputs
criamico de08fda
Merge branch 'main' into 192339_show_outputs_in_agents_table
elasticmachine 2064407
Implement text truncate and add badge with popover
criamico 749db59
small fixes and unit tests
criamico 5a22b25
Add outputs info in agent details section
criamico b6e8a5e
Merge branch 'main' into 192339_show_outputs_in_agents_table
elasticmachine de53fed
Merge branch 'main' into 192339_show_outputs_in_agents_table
elasticmachine ea3b503
Fix copy
criamico ce5c37b
Add basic functionality for new endpoint - get outputs by agent polic…
criamico 36a17a3
Move logic to AgentPolicyService
criamico 4e0a62b
Use new endpoint in UI
criamico 41eedb0
Merge branch 'main' into 192339_show_outputs_in_agents_table
elasticmachine 9ee5c29
Add new endpoint to retrieve outputs for all policies
criamico d80de5f
Improvements to new endpoint
criamico a2519c3
limit agent policies query to the ones displayed
criamico bdc585f
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine cdb247a
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine 77a03a8
Fix linter and one unit test
criamico 77e16d2
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine d99f2cd
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine 42dc2a6
Use post instead of get
criamico 4927926
fix failing test
criamico ef78686
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine fc6f095
Merge branch 'main' into 192339_show_outputs_in_agents_table
elasticmachine a27aa64
Add concurrency to pMap
criamico ad9bdf9
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine 03e11f6
add integration tests
criamico 34d780d
Merge branch 'main' into 192339_show_outputs_in_agents_table
elasticmachine File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
98 changes: 98 additions & 0 deletions
98
...ns/fleet/sections/agents/agent_list_page/components/agent_policy_outputs_summary.test.tsx
This file contains hidden or 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,98 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { act, fireEvent } from '@testing-library/react'; | ||
| import React from 'react'; | ||
|
|
||
| import { createFleetTestRendererMock } from '../../../../../../mock'; | ||
| import type { TestRenderer } from '../../../../../../mock'; | ||
|
|
||
| import type { AgentPolicy, Output } from '../../../../types'; | ||
| import { createAgentPolicyMock } from '../../../../../../../common/mocks'; | ||
|
|
||
| import { AgentPolicyOutputsSummary } from './agent_policy_outputs_summary'; | ||
|
|
||
| describe('MultipleAgentPolicySummaryLine', () => { | ||
| let testRenderer: TestRenderer; | ||
| const outputs: Output[] = [ | ||
| { | ||
| id: 'elasticsearch1', | ||
| name: 'Elasticsearch1', | ||
| type: 'elasticsearch', | ||
| is_default: false, | ||
| is_default_monitoring: false, | ||
| hosts: ['http://test.io:449'], | ||
| }, | ||
| { | ||
| id: 'logstash1', | ||
| name: 'Logstash 1', | ||
| type: 'logstash', | ||
| is_default: true, | ||
| is_default_monitoring: true, | ||
| hosts: ['http://test.io:449'], | ||
| }, | ||
| { | ||
| id: 'remote_es1', | ||
| name: 'Remote ES', | ||
| type: 'remote_elasticsearch', | ||
| is_default: false, | ||
| is_default_monitoring: false, | ||
| hosts: ['http://test.io:449', 'http://test.io:448', 'http://test.io:447'], | ||
| }, | ||
| ]; | ||
|
|
||
| const render = (agentPolicy: AgentPolicy, monitoring?: boolean) => | ||
| testRenderer.render( | ||
| <AgentPolicyOutputsSummary | ||
| agentPolicy={agentPolicy} | ||
| outputs={outputs} | ||
| monitoring={monitoring} | ||
| /> | ||
| ); | ||
|
|
||
| beforeEach(() => { | ||
| testRenderer = createFleetTestRendererMock(); | ||
| }); | ||
|
|
||
| test('it should render the host associated with the default output when the agent policy does not have custom outputs', async () => { | ||
| const mockAgentPolicy = createAgentPolicyMock(); | ||
| const results = render(mockAgentPolicy); | ||
| expect(results.container.textContent).toBe('http://test.io:449'); | ||
| expect(results.queryByTestId('outputNameLink')).toBeInTheDocument(); | ||
| expect(results.queryByTestId('outputHostsNumberBadge')).not.toBeInTheDocument(); | ||
| }); | ||
|
|
||
| test('it should render the first host name and the badge when there are multiple hosts', async () => { | ||
| const agentPolicy = createAgentPolicyMock({ | ||
| data_output_id: 'remote_es1', | ||
| monitoring_output_id: 'remote_es1', | ||
| }); | ||
| const results = render(agentPolicy); | ||
|
|
||
| expect(results.queryByTestId('outputNameLink')).toBeInTheDocument(); | ||
| expect(results.queryByTestId('outputHostsNumberBadge')).toBeInTheDocument(); | ||
|
|
||
| await act(async () => { | ||
| fireEvent.click(results.getByTestId('outputHostsNumberBadge')); | ||
| }); | ||
| expect(results.queryByTestId('outputHostsPopover')).toBeInTheDocument(); | ||
| expect(results.queryByTestId('output-host-0')?.textContent).toContain('http://test.io:449'); | ||
| expect(results.queryByTestId('output-host-1')?.textContent).toContain('http://test.io:448'); | ||
| expect(results.queryByTestId('output-host-2')?.textContent).toContain('http://test.io:447'); | ||
| }); | ||
|
|
||
| test('it should not render the badge when monitoring is true', async () => { | ||
| const agentPolicy = createAgentPolicyMock({ | ||
| data_output_id: 'remote_es1', | ||
| monitoring_output_id: 'remote_es1', | ||
| }); | ||
| const results = render(agentPolicy, true); | ||
|
|
||
| expect(results.queryByTestId('outputNameLink')).toBeInTheDocument(); | ||
| expect(results.queryByTestId('outputHostsNumberBadge')).not.toBeInTheDocument(); | ||
| }); | ||
| }); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.