Skip to content

Commit

Permalink
Merge branch 'master' into ftr/drop-legacyEs
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Jan 21, 2021
2 parents f09202c + dfd96d6 commit 28943c5
Show file tree
Hide file tree
Showing 28 changed files with 751 additions and 124 deletions.
12 changes: 11 additions & 1 deletion src/core/server/saved_objects/migrationsv2/model.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,7 @@ describe('migrations v2 model', () => {
expect(newState.retryCount).toEqual(0);
expect(newState.retryDelay).toEqual(0);
});
test('MARK_VERSION_INDEX_READY -> MARK_VERSION_INDEX_CONFLICT if someone else removed the current alias from the source index', () => {
test('MARK_VERSION_INDEX_READY -> MARK_VERSION_INDEX_CONFLICT if another removed the current alias from the source index', () => {
const res: ResponseType<'MARK_VERSION_INDEX_READY'> = Either.left({
type: 'alias_not_found_exception',
});
Expand All @@ -920,6 +920,16 @@ describe('migrations v2 model', () => {
expect(newState.retryCount).toEqual(0);
expect(newState.retryDelay).toEqual(0);
});
test('MARK_VERSION_INDEX_READY -> MARK_VERSION_INDEX_CONFLICT if another node removed the temporary index', () => {
const res: ResponseType<'MARK_VERSION_INDEX_READY'> = Either.left({
type: 'index_not_found_exception',
index: '.kibana_7.11.0_reindex_temp',
});
const newState = model(markVersionIndexReadyState, res);
expect(newState.controlState).toEqual('MARK_VERSION_INDEX_READY_CONFLICT');
expect(newState.retryCount).toEqual(0);
expect(newState.retryDelay).toEqual(0);
});
});
describe('MARK_VERSION_INDEX_READY_CONFLICT', () => {
const aliasActions = Option.some([Symbol('alias action')] as unknown) as Option.Some<
Expand Down
20 changes: 14 additions & 6 deletions src/core/server/saved_objects/migrationsv2/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -638,12 +638,20 @@ export const model = (currentState: State, resW: ResponseType<AllActionStates>):
// alias_not_found_exception another instance has completed a
// migration from the same source.
return { ...stateP, controlState: 'MARK_VERSION_INDEX_READY_CONFLICT' };
} else if (
left.type === 'remove_index_not_a_concrete_index' ||
left.type === 'index_not_found_exception'
) {
// We don't handle these errors as the migration algorithm will never
// cause them to occur (these are only relevant to the LEGACY_DELETE
} else if (left.type === 'index_not_found_exception') {
if (left.index === stateP.tempIndex) {
// another instance has already completed the migration and deleted
// the temporary index
return { ...stateP, controlState: 'MARK_VERSION_INDEX_READY_CONFLICT' };
} else {
// The migration algorithm will never cause a
// index_not_found_exception for an index other than the temporary
// index handled above.
throwBadResponse(stateP, left as never);
}
} else if (left.type === 'remove_index_not_a_concrete_index') {
// We don't handle this error as the migration algorithm will never
// cause it to occur (this error is only relevant to the LEGACY_DELETE
// step).
throwBadResponse(stateP, left as never);
} else {
Expand Down
5 changes: 4 additions & 1 deletion src/plugins/vis_type_vega/public/data_model/search_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ export class SearchAPI {
});

if (this.inspectorAdapters) {
requestResponders[requestId] = this.inspectorAdapters.requests.start(requestId, request);
requestResponders[requestId] = this.inspectorAdapters.requests.start(requestId, {
...request,
searchSessionId: this.searchSessionId,
});
requestResponders[requestId].json(params.body);
}

Expand Down
86 changes: 86 additions & 0 deletions test/scripts/run_multiple_kibana_nodes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

#!/bin/bash

#
# Script to run multiple kibana nodes in parallel on the same machine.
# Make sure to run the script from kibana root directory. Some functions depend on the jq command-line utility
# being installed.
#
# bash test/scripts/run_multiple_kibana_nodes.sh <function> [options]
# functions:
# start [instances] [args] - start multiple kibanas (3 default)
# es [args] - run elasticsearch
# tail - show logs of all kibanas
# kill - kills all started kibana processes
# clean - clean up nohup files
# kibana_index - search .kibana index against es
#

FN="$1"

if [ "${FN}" == "kill" ]; then
echo "killing main processes"
for pid in $(cat processes.out); do kill -9 $pid; done
echo "killing trailing processes"
for pid in $(pgrep -f scripts/kibana); do kill -9 $pid; done
exit 0;
fi

if [ "${FN}" == "tail" ]; then
tail -f nohup_*
exit 0;
fi

if [ "${FN}" == "clean" ]; then
rm -r nohup_*.out
rm processes.out
exit 0;
fi

if [ "${FN}" == "es" ]; then
ARGS="$2"
yarn es snapshot $ARGS
exit 0;
fi

if [ "${FN}" == "kibana_index" ]; then
# search the kibana index
curl -XPOST http://elastic:changeme@localhost:9200/.kibana/_search -u elastic:changeme -d '' | jq
exit 0;
fi

if [ "${FN}" == "start" ]; then
NUM="$2"
ARGS="$3"
if test ! "${NUM-}"; then
NUM=3
fi
node scripts/build_kibana_platform_plugins --no-examples
rm processes.out
for i in $(seq 0 $(expr $NUM - 1))
do
PORT="56${i}1"
PROXY="56${i}3"
echo "starting kibana on port $PORT"
nohup node scripts/kibana.js --dev.basePathProxyTarget=$PROXY --server.port=$PORT --dev --no-watch --no-optimizer --no-base-path $ARGS > nohup_$i.out &
PROCESS_ID=$!
echo "${PROCESS_ID}" >> processes.out
done
exit 0;
fi
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { UXMetrics } from './UXMetrics';
import { ImpactfulMetrics } from './ImpactfulMetrics';
import { PageLoadAndViews } from './Panels/PageLoadAndViews';
import { VisitorBreakdownsPanel } from './Panels/VisitorBreakdowns';
import { useBreakPoints } from './hooks/useBreakPoints';
import { useBreakPoints } from '../../../hooks/use_break_points';
import { getPercentileLabel } from './UXMetrics/translations';
import { useUrlParams } from '../../../context/url_params_context/use_url_params';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export function TransactionDetails({
<h1>{transactionName}</h1>
</EuiTitle>
</ApmHeader>
<SearchBar />
<SearchBar showTimeComparison />
<EuiPage>
<EuiFlexGroup>
<EuiFlexItem grow={1}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function ServiceInventory() {

return (
<>
<SearchBar />
<SearchBar showTimeComparison />
<EuiPage>
<EuiFlexGroup>
<EuiFlexItem grow={1}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ function wrapper({ children }: { children?: ReactNode }) {
rangeTo: 'now',
start: 'mystart',
end: 'myend',
comparisonEnabled: true,
comparisonType: 'yesterday',
}}
>
{children}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { isRumAgentName } from '../../../../common/agent_name';
import { AnnotationsContextProvider } from '../../../context/annotations/annotations_context';
import { useApmServiceContext } from '../../../context/apm_service/use_apm_service_context';
import { ChartPointerEventContextProvider } from '../../../context/chart_pointer_event/chart_pointer_event_context';
import { useBreakPoints } from '../../../hooks/use_break_points';
import { LatencyChart } from '../../shared/charts/latency_chart';
import { TransactionBreakdownChart } from '../../shared/charts/transaction_breakdown_chart';
import { TransactionErrorRateChart } from '../../shared/charts/transaction_error_rate_chart';
Expand All @@ -22,7 +23,6 @@ import { ServiceOverviewErrorsTable } from './service_overview_errors_table';
import { ServiceOverviewInstancesChartAndTable } from './service_overview_instances_chart_and_table';
import { ServiceOverviewThroughputChart } from './service_overview_throughput_chart';
import { ServiceOverviewTransactionsTable } from './service_overview_transactions_table';
import { useShouldUseMobileLayout } from './use_should_use_mobile_layout';

/**
* The height a chart should be if it's next to a table with 5 rows and a title.
Expand All @@ -44,8 +44,8 @@ export function ServiceOverview({

// The default EuiFlexGroup breaks at 768, but we want to break at 992, so we
// observe the window width and set the flex directions of rows accordingly
const shouldUseMobileLayout = useShouldUseMobileLayout();
const rowDirection = shouldUseMobileLayout ? 'column' : 'row';
const { isMedium } = useBreakPoints();
const rowDirection = isMedium ? 'column' : 'row';

const { transactionType } = useApmServiceContext();
const transactionTypeLabel = i18n.translate(
Expand All @@ -57,7 +57,7 @@ export function ServiceOverview({
return (
<AnnotationsContextProvider>
<ChartPointerEventContextProvider>
<SearchBar prepend={transactionTypeLabel} />
<SearchBar prepend={transactionTypeLabel} showTimeComparison />
<EuiPage>
<EuiFlexGroup direction="column" gutterSize="s">
{isRumAgent && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import React, { ReactNode } from 'react';
import styled from 'styled-components';
import { useShouldUseMobileLayout } from './use_should_use_mobile_layout';
import { useBreakPoints } from '../../../hooks/use_break_points';

/**
* The height for a table on the overview page. Is the height of a 5-row basic
Expand Down Expand Up @@ -58,12 +58,12 @@ export function ServiceOverviewTableContainer({
children?: ReactNode;
isEmptyAndLoading: boolean;
}) {
const shouldUseMobileLayout = useShouldUseMobileLayout();
const { isMedium } = useBreakPoints();

return (
<ServiceOverviewTableContainerDiv
isEmptyAndLoading={isEmptyAndLoading}
shouldUseMobileLayout={shouldUseMobileLayout}
shouldUseMobileLayout={isMedium}
>
{children}
</ServiceOverviewTableContainerDiv>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export function TransactionOverview({ serviceName }: TransactionOverviewProps) {

return (
<>
<SearchBar />
<SearchBar showTimeComparison />

<EuiPage>
<EuiFlexGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ describe('TransactionOverview', () => {
});

expect(history.location.search).toEqual(
'?transactionType=secondType&rangeFrom=now-15m&rangeTo=now'
'?transactionType=secondType&rangeFrom=now-15m&rangeTo=now&comparisonEnabled=true&comparisonType=yesterday'
);
expect(getByText(container, 'firstType')).toBeInTheDocument();
expect(getByText(container, 'secondType')).toBeInTheDocument();
Expand All @@ -139,7 +139,7 @@ describe('TransactionOverview', () => {

expect(history.push).toHaveBeenCalled();
expect(history.location.search).toEqual(
'?transactionType=firstType&rangeFrom=now-15m&rangeTo=now'
'?transactionType=firstType&rangeFrom=now-15m&rangeTo=now&comparisonEnabled=true&comparisonType=yesterday'
);
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ export type APMQueryParams = {
searchTerm?: string;
percentile?: 50 | 75 | 90 | 95 | 99;
latencyAggregationType?: string;
comparisonEnabled?: boolean;
comparisonType?: string;
} & { [key in LocalUIFilterName]?: string };

// forces every value of T[K] to be type: string
Expand Down
39 changes: 33 additions & 6 deletions x-pack/plugins/apm/public/components/shared/search_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,49 @@
import { EuiFlexGroup, EuiFlexItem } from '@elastic/eui';
import React from 'react';
import styled from 'styled-components';
import { px, unit } from '../../style/variables';
import { DatePicker } from './DatePicker';
import { KueryBar } from './KueryBar';
import { TimeComparison } from './time_comparison';
import { useBreakPoints } from '../../hooks/use_break_points';

const SearchBarFlexGroup = styled(EuiFlexGroup)`
margin: ${({ theme }) =>
`${theme.eui.euiSizeM} ${theme.eui.euiSizeM} -${theme.eui.gutterTypes.gutterMedium} ${theme.eui.euiSizeM}`};
`;

export function SearchBar(props: { prepend?: React.ReactNode | string }) {
interface Props {
prepend?: React.ReactNode | string;
showTimeComparison?: boolean;
}

function getRowDirection(showColumn: boolean) {
return showColumn ? 'column' : 'row';
}

export function SearchBar({ prepend, showTimeComparison = false }: Props) {
const { isMedium, isLarge } = useBreakPoints();
const itemsStyle = { marginBottom: isLarge ? px(unit) : 0 };
return (
<SearchBarFlexGroup alignItems="flexStart" gutterSize="s">
<EuiFlexItem grow={3}>
<KueryBar prepend={props.prepend} />
<SearchBarFlexGroup gutterSize="s" direction={getRowDirection(isLarge)}>
<EuiFlexItem>
<KueryBar prepend={prepend} />
</EuiFlexItem>
<EuiFlexItem grow={1}>
<DatePicker />
<EuiFlexItem grow={false}>
<EuiFlexGroup
justifyContent="flexEnd"
gutterSize="s"
direction={getRowDirection(isMedium)}
>
{showTimeComparison && (
<EuiFlexItem style={{ ...itemsStyle, minWidth: px(300) }}>
<TimeComparison />
</EuiFlexItem>
)}
<EuiFlexItem style={itemsStyle}>
<DatePicker />
</EuiFlexItem>
</EuiFlexGroup>
</EuiFlexItem>
</SearchBarFlexGroup>
);
Expand Down
Loading

0 comments on commit 28943c5

Please sign in to comment.