Skip to content

Commit

Permalink
Merge branch 'main' into 126695-make-upload-and-registry-package-info…
Browse files Browse the repository at this point in the history
…-consistent
  • Loading branch information
kibanamachine authored Mar 9, 2022
2 parents 5d97961 + 0ba204b commit 9122a63
Show file tree
Hide file tree
Showing 24 changed files with 78 additions and 81 deletions.
10 changes: 5 additions & 5 deletions .buildkite/scripts/steps/package_testing/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ mkdir -p target
cd target
if [[ "$TEST_PACKAGE" == "deb" ]]; then
buildkite-agent artifact download 'kibana-*.deb' . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
KIBANA_IP_ADDRESS="192.168.50.5"
KIBANA_IP_ADDRESS="192.168.56.5"
elif [[ "$TEST_PACKAGE" == "rpm" ]]; then
buildkite-agent artifact download 'kibana-*.rpm' . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
KIBANA_IP_ADDRESS="192.168.50.6"
KIBANA_IP_ADDRESS="192.168.56.6"
elif [[ "$TEST_PACKAGE" == "docker" ]]; then
buildkite-agent artifact download "kibana-$KIBANA_PKG_VERSION-SNAPSHOT-docker-image.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
KIBANA_IP_ADDRESS="192.168.50.7"
KIBANA_IP_ADDRESS="192.168.56.7"
fi
cd ..

export VAGRANT_CWD=test/package
vagrant up "$TEST_PACKAGE" --no-provision

node scripts/es snapshot \
-E network.bind_host=127.0.0.1,192.168.50.1 \
-E network.bind_host=127.0.0.1,192.168.56.1 \
-E discovery.type=single-node \
--license=trial &
while ! timeout 1 bash -c "echo > /dev/tcp/localhost/9200"; do sleep 30; done
Expand All @@ -33,7 +33,7 @@ vagrant provision "$TEST_PACKAGE"

export TEST_BROWSER_HEADLESS=1
export TEST_KIBANA_URL="http://elastic:changeme@$KIBANA_IP_ADDRESS:5601"
export TEST_ES_URL=http://elastic:changeme@192.168.50.1:9200
export TEST_ES_URL=http://elastic:changeme@192.168.56.1:9200

cd x-pack
node scripts/functional_test_runner.js --include-tag=smoke
10 changes: 5 additions & 5 deletions docs/developer/contributing/development-package-tests.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ pip3 install --user ansible
[cols=",,",options="header",]
|===
|Hostname |IP |Description
|deb |192.168.50.5 |Installation of Kibana’s deb package
|rpm |192.168.50.6 |Installation of Kibana’s rpm package
|docker |192.168.50.7 |Installation of Kibana’s docker image
|deb |192.168.56.5 |Installation of Kibana’s deb package
|rpm |192.168.56.6 |Installation of Kibana’s rpm package
|docker |192.168.56.7 |Installation of Kibana’s docker image
|===

=== Running
Expand All @@ -49,11 +49,11 @@ vagrant provision <hostname>

# Running functional tests
node scripts/es snapshot \
-E network.bind_host=127.0.0.1,192.168.50.1 \
-E network.bind_host=127.0.0.1,192.168.56.1 \
-E discovery.type=single-node \
--license=trial
TEST_KIBANA_URL=http://elastic:changeme@<ip>:5601 \
TEST_ES_URL=http://elastic:changeme@192.168.50.1:9200 \
TEST_ES_URL=http://elastic:changeme@192.168.56.1:9200 \
node scripts/functional_test_runner.js --include-tag=smoke
```

Expand Down
6 changes: 3 additions & 3 deletions test/package/Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Vagrant.configure("2") do |config|
deb.vm.provision "ansible" do |ansible|
ansible.playbook = "deb.yml"
end
deb.vm.network "private_network", ip: "192.168.50.5"
deb.vm.network "private_network", ip: "192.168.56.5"
end

config.vm.define "rpm" do |rpm|
Expand All @@ -20,7 +20,7 @@ Vagrant.configure("2") do |config|
rpm.vm.provision "ansible" do |ansible|
ansible.playbook = "rpm.yml"
end
rpm.vm.network "private_network", ip: "192.168.50.6"
rpm.vm.network "private_network", ip: "192.168.56.6"
end

config.vm.define "docker" do |docker|
Expand All @@ -31,6 +31,6 @@ Vagrant.configure("2") do |config|
docker.vm.provision "ansible" do |ansible|
ansible.playbook = "docker.yml"
end
docker.vm.network "private_network", ip: "192.168.50.7"
docker.vm.network "private_network", ip: "192.168.56.7"
end
end
2 changes: 1 addition & 1 deletion test/package/roles/install_kibana_docker/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
network_mode: host
env:
SERVER_HOST: 0.0.0.0
ELASTICSEARCH_HOSTS: http://192.168.50.1:9200
ELASTICSEARCH_HOSTS: http://192.168.56.1:9200
ELASTICSEARCH_USERNAME: '{{ elasticsearch_username }}'
ELASTICSEARCH_PASSWORD: '{{ elasticsearch_password }}'
2 changes: 1 addition & 1 deletion test/package/templates/kibana.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
server.host: 0.0.0.0

elasticsearch.hosts: http://192.168.50.1:9200
elasticsearch.hosts: http://192.168.56.1:9200
elasticsearch.username: "{{ elasticsearch_username }}"
elasticsearch.password: "{{ elasticsearch_password }}"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ import {
EuiToolTip,
} from '@elastic/eui';

import { i18n } from '@kbn/i18n';

import { EuiButtonEmptyTo } from '../../../../../shared/react_router_helpers';
import { SourceIcon } from '../../../../components/shared/source_icon';
import { getAddPath, getSourcesPath } from '../../../../routes';
Expand All @@ -29,7 +31,6 @@ import { hasMultipleConnectorOptions } from '../../../../utils';
import {
CONFIGURED_SOURCES_LIST_UNCONNECTED_TOOLTIP,
CONFIGURED_SOURCES_LIST_ACCOUNT_ONLY_TOOLTIP,
CONFIGURED_SOURCES_CONNECT_BUTTON,
CONFIGURED_SOURCES_EMPTY_STATE,
CONFIGURED_SOURCES_TITLE,
CONFIGURED_SOURCES_EMPTY_BODY,
Expand Down Expand Up @@ -112,7 +113,19 @@ export const ConfiguredSourcesList: React.FC<ConfiguredSourcesProps> = ({
hasMultipleConnectorOptions(sourceData) ? '' : 'connect'
}`}
>
{CONFIGURED_SOURCES_CONNECT_BUTTON}
{!connected
? i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.contentSource.configuredSources.connectButton',
{
defaultMessage: 'Connect',
}
)
: i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.contentSource.configuredSources.connectAnotherButton',
{
defaultMessage: 'Connect another',
}
)}
</EuiButtonEmptyTo>
)) || (
<EuiButtonEmpty className="eui-fullWidth" isDisabled>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,6 @@ export const CONFIGURED_SOURCES_LIST_ACCOUNT_ONLY_TOOLTIP = i18n.translate(
}
);

export const CONFIGURED_SOURCES_CONNECT_BUTTON = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.contentSource.configuredSources.connectButton',
{
defaultMessage: 'Connect another',
}
);

export const CONFIGURED_SOURCES_EMPTY_STATE = i18n.translate(
'xpack.enterpriseSearch.workplaceSearch.contentSource.configuredSources.emptyState',
{
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/fleet/.storybook/context/stubs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ type Stubs =
| 'licensing'
| 'storage'
| 'data'
| 'fieldFormats'
| 'deprecations'
| 'fatalErrors'
| 'navigation'
Expand All @@ -24,7 +23,6 @@ export const stubbedStartServices: StubbedStartServices = {
licensing: {} as FleetStartServices['licensing'],
storage: {} as FleetStartServices['storage'],
data: {} as FleetStartServices['data'],
fieldFormats: {} as FleetStartServices['fieldFormats'],
deprecations: {} as FleetStartServices['deprecations'],
fatalErrors: {} as FleetStartServices['fatalErrors'],
navigation: {} as FleetStartServices['navigation'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ properties:
package_version:
type: string
last_activity_ms:
type: string
type: number
size_in_bytes:
type: number
size_in_bytes_formatted:
type: string
dashboard:
type: array
Expand Down
1 change: 1 addition & 0 deletions x-pack/plugins/fleet/common/types/models/data_stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface DataStream {
package_version: string;
last_activity_ms: number;
size_in_bytes: number;
size_in_bytes_formatted: number | string;
dashboards: Array<{
id: string;
title: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,17 @@ import {
EuiInMemoryTable,
} from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FormattedMessage, FormattedDate } from '@kbn/i18n-react';
import { FormattedMessage, FormattedDate, FormattedTime } from '@kbn/i18n-react';

import type { DataStream } from '../../../types';
import { useGetDataStreams, useStartServices, usePagination, useBreadcrumbs } from '../../../hooks';
import { useGetDataStreams, usePagination, useBreadcrumbs } from '../../../hooks';
import { PackageIcon } from '../../../components';

import { DataStreamRowActions } from './components/data_stream_row_actions';

export const DataStreamListPage: React.FunctionComponent<{}> = () => {
useBreadcrumbs('data_streams');

const { fieldFormats } = useStartServices();

const { pagination, pageSizeOptions } = usePagination();

// Fetch data streams
Expand Down Expand Up @@ -97,30 +95,21 @@ export const DataStreamListPage: React.FunctionComponent<{}> = () => {
defaultMessage: 'Last activity',
}),
render: (date: DataStream['last_activity_ms']) => {
try {
const formatter = fieldFormats.getInstance('date', {
pattern: 'MMM D, YYYY @ HH:mm:ss',
});
return formatter.convert(date);
} catch (e) {
return <FormattedDate value={date} year="numeric" month="short" day="2-digit" />;
}
return (
<>
<FormattedDate value={date} year="numeric" month="short" day="numeric" />
<> @ </>
<FormattedTime value={date} hour="numeric" minute="numeric" second="numeric" />
</>
);
},
},
{
field: 'size_in_bytes',
field: 'size_in_bytes_formatted',
sortable: true,
name: i18n.translate('xpack.fleet.dataStreamList.sizeColumnTitle', {
defaultMessage: 'Size',
}),
render: (size: DataStream['size_in_bytes']) => {
try {
const formatter = fieldFormats.getInstance('bytes');
return formatter.convert(size);
} catch (e) {
return `${size}b`;
}
},
},
{
name: i18n.translate('xpack.fleet.dataStreamList.actionsColumnTitle', {
Expand All @@ -134,7 +123,7 @@ export const DataStreamListPage: React.FunctionComponent<{}> = () => {
},
];
return cols;
}, [fieldFormats]);
}, []);

const emptyPrompt = useMemo(
() => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const EnrollmentStepAgentPolicy: React.FC<Props> = (props) => {
defaultMessage: 'Agent policy',
}
)}
hasNoInitialSelection={agentPolicies.length > 1}
hasNoInitialSelection={!selectedAgentPolicyId}
data-test-subj="agentPolicyDropdown"
isInvalid={!selectedAgentPolicyId}
/>
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/fleet/public/mock/plugin_dependencies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { homePluginMock } from '../../../../../src/plugins/home/public/mocks';
import { navigationPluginMock } from '../../../../../src/plugins/navigation/public/mocks';
import { customIntegrationsMock } from '../../../../../src/plugins/custom_integrations/public/mocks';
import { sharePluginMock } from '../../../../../src/plugins/share/public/mocks';
import { fieldFormatsServiceMock } from '../../../../../src/plugins/field_formats/public/mocks';

export const createSetupDepsMock = () => {
const cloud = cloudMock.createSetup();
Expand All @@ -28,7 +27,6 @@ export const createStartDepsMock = () => {
return {
licensing: licensingMock.createStart(),
data: dataPluginMock.createStartContract(),
fieldFormats: fieldFormatsServiceMock.createStartContract() as any,
navigation: navigationPluginMock.createStartContract(),
customIntegrations: customIntegrationsMock.createStart(),
share: sharePluginMock.createStartContract(),
Expand Down
2 changes: 0 additions & 2 deletions x-pack/plugins/fleet/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import type {
DataPublicPluginSetup,
DataPublicPluginStart,
} from '../../../../src/plugins/data/public';
import type { FieldFormatsStart } from '../../../../src/plugins/field_formats/public/index';
import { FeatureCatalogueCategory } from '../../../../src/plugins/home/public';
import type { HomePublicPluginSetup } from '../../../../src/plugins/home/public';
import { Storage } from '../../../../src/plugins/kibana_utils/public';
Expand Down Expand Up @@ -96,7 +95,6 @@ export interface FleetSetupDeps {
export interface FleetStartDeps {
licensing: LicensingPluginStart;
data: DataPublicPluginStart;
fieldFormats: FieldFormatsStart;
navigation: NavigationPublicPluginStart;
customIntegrations: CustomIntegrationsStart;
share: SharePluginStart;
Expand Down
14 changes: 5 additions & 9 deletions x-pack/plugins/fleet/server/routes/data_streams/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ interface ESDataStreamInfo {
hidden: boolean;
}

interface ESDataStreamStats {
data_stream: string;
backing_indices: number;
store_size_bytes: number;
maximum_timestamp: number;
}

export const getListHandler: RequestHandler = async (context, request, response) => {
// Query datastreams as the current user as the Kibana internal user may not have all the required permission
const esClient = context.core.elasticsearch.client.asCurrentUser;
Expand All @@ -60,12 +53,12 @@ export const getListHandler: RequestHandler = async (context, request, response)
packageSavedObjects,
] = await Promise.all([
esClient.indices.getDataStream({ name: DATA_STREAM_INDEX_PATTERN }),
esClient.indices.dataStreamsStats({ name: DATA_STREAM_INDEX_PATTERN }),
esClient.indices.dataStreamsStats({ name: DATA_STREAM_INDEX_PATTERN, human: true }),
getPackageSavedObjects(context.core.savedObjects.client),
]);

const dataStreamsInfoByName = keyBy<ESDataStreamInfo>(dataStreamsInfo, 'name');
const dataStreamsStatsByName = keyBy<ESDataStreamStats>(dataStreamStats, 'data_stream');
const dataStreamsStatsByName = keyBy(dataStreamStats, 'data_stream');

// Combine data stream info
const dataStreams = merge(dataStreamsInfoByName, dataStreamsStatsByName);
Expand Down Expand Up @@ -127,6 +120,9 @@ export const getListHandler: RequestHandler = async (context, request, response)
package_version: '',
last_activity_ms: dataStream.maximum_timestamp, // overridden below if maxIngestedTimestamp agg returns a result
size_in_bytes: dataStream.store_size_bytes,
// `store_size` should be available from ES due to ?human=true flag
// but fallback to bytes just in case
size_in_bytes_formatted: dataStream.store_size || `${dataStream.store_size_bytes}b`,
dashboards: [],
};

Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/fleet/server/services/agent_policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,7 @@ class AgentPolicyService {
const res = await esClient.search({
index: AGENT_POLICY_INDEX,
ignore_unavailable: true,
rest_total_hits_as_int: true,
body: {
query: {
term: {
Expand All @@ -678,8 +679,7 @@ class AgentPolicyService {
},
});

// @ts-expect-error value is number | TotalHits
if (res.body.hits.total.value === 0) {
if ((res.hits.total as number) === 0) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/fleet/server/services/agents/crud.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('Agents CRUD test', () => {
function getEsResponse(ids: string[], total: number) {
return {
hits: {
total: { value: total },
total,
hits: ids.map((id: string) => ({
_id: id,
_source: {},
Expand Down
Loading

0 comments on commit 9122a63

Please sign in to comment.