Skip to content

Commit

Permalink
Merge branch 'main' into eui/v88.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cee-chen authored Sep 5, 2023
2 parents 1c37660 + 8ca63ad commit ac172e7
Show file tree
Hide file tree
Showing 83 changed files with 1,887 additions and 958 deletions.
3 changes: 1 addition & 2 deletions .buildkite/scripts/steps/functional/osquery_cypress.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ echo "--- Osquery Cypress tests"

cd x-pack/plugins/osquery

set +e
yarn cypress:run; status=$?; yarn junit:merge && exit $status
yarn --cwd x-pack/plugins/osquery cypress:run
3 changes: 1 addition & 2 deletions .buildkite/scripts/steps/functional/osquery_cypress_burn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@ buildkite-agent meta-data set "${BUILDKITE_JOB_ID}_is_test_execution_step" 'fals

echo "--- Osquery Cypress tests, burning changed specs (Chrome)"

set +e
yarn cypress:changed-specs-only; status=$?; yarn junit:merge && exit $status
yarn --cwd x-pack/plugins/osquery cypress:changed-specs-only
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export function ErrorCountRuleType(props: Props) {
start,
end,
groupBy: params.groupBy,
searchConfiguration: JSON.stringify(params.searchConfiguration),
searchConfiguration: params.searchConfiguration?.query?.query
? JSON.stringify(params.searchConfiguration)
: undefined,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ export function TransactionDurationRuleType(props: Props) {
start,
end,
groupBy: params.groupBy,
searchConfiguration: JSON.stringify(params.searchConfiguration),
searchConfiguration: params.searchConfiguration?.query?.query
? JSON.stringify(params.searchConfiguration)
: undefined,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ export function TransactionErrorRateRuleType(props: Props) {
start,
end,
groupBy: params.groupBy,
searchConfiguration: JSON.stringify(params.searchConfiguration),
searchConfiguration: params.searchConfiguration?.query?.query
? JSON.stringify(params.searchConfiguration)
: undefined,
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ export function registerErrorCountRuleType({

const indices = await getApmIndices(savedObjectsClient);

const termFilterQuery = !ruleParams.searchConfiguration
const termFilterQuery = !ruleParams.searchConfiguration?.query?.query
? [
...termQuery(SERVICE_NAME, ruleParams.serviceName, {
queryEmptyString: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export function registerTransactionDurationRuleType({
searchAggregatedTransactions
);

const termFilterQuery = !ruleParams.searchConfiguration
const termFilterQuery = !ruleParams.searchConfiguration?.query?.query
? [
...termQuery(SERVICE_NAME, ruleParams.serviceName, {
queryEmptyString: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export function registerTransactionErrorRateRuleType({
? indices.metric
: indices.transaction;

const termFilterQuery = !ruleParams.searchConfiguration
const termFilterQuery = !ruleParams.searchConfiguration?.query?.query
? [
...termQuery(SERVICE_NAME, ruleParams.serviceName, {
queryEmptyString: false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ export class LensAttributes {
operationType: capitalize(operationType),
},
}),
customLabel: true,
filter: columnFilter,
operationType,
params:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const testMobileKPIAttr = {
params: {},
scale: 'ratio',
sourceField: 'system.memory.usage',
customLabel: true,
dataType: 'number',
filter: {
query:
Expand Down
13 changes: 13 additions & 0 deletions x-pack/plugins/fleet/common/constants/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,16 @@ export const DOWNLOAD_SOURCE_API_ROUTES = {
UPDATE_PATTERN: `${API_ROOT}/agent_download_sources/{sourceId}`,
DELETE_PATTERN: `${API_ROOT}/agent_download_sources/{sourceId}`,
};

// API versioning constants
export const API_VERSIONS = {
public: {
v1: '2023-10-31',
},
internal: {
v1: '1',
},
};

export const PUBLIC_API_ACCESS = 'public';
export const INTERNAL_API_ACCESS = 'internal';
6 changes: 4 additions & 2 deletions x-pack/plugins/fleet/cypress/e2e/a11y/home_page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import { AGENT_POLICY_NAME_LINK } from '../../screens/integrations';
import { cleanupAgentPolicies, unenrollAgent } from '../../tasks/cleanup';
import { setFleetServerHost } from '../../tasks/fleet_server';

import { API_VERSIONS } from '../../../common/constants';

describe('Home page', () => {
before(() => {
setFleetServerHost('https://fleetserver:8220');
Expand Down Expand Up @@ -152,7 +154,7 @@ describe('Home page', () => {
method: 'POST',
url: '/api/fleet/agent_policies',
body: { name: 'Agent policy for A11y test', namespace: 'default', id: 'agent-policy-a11y' },
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
beforeEach(() => {
Expand All @@ -164,7 +166,7 @@ describe('Home page', () => {
method: 'POST',
url: '/api/fleet/agent_policies/delete',
body: { agentPolicyId: 'agent-policy-a11y' },
headers: { 'kbn-xsrf': 'kibana' },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
it('Uninstall Tokens Table', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import { cleanupDownloadSources } from '../tasks/cleanup';
import { FLEET, navigateTo } from '../tasks/navigation';
import { CONFIRM_MODAL } from '../screens/navigation';

import { API_VERSIONS } from '../../common/constants';

describe('Agent binary download source section', () => {
beforeEach(() => {
cleanupDownloadSources();
Expand Down Expand Up @@ -80,7 +82,7 @@ describe('Agent binary download source section', () => {
id: 'fleet-local-registry',
host: 'https://new-custom-host.co',
},
headers: { 'kbn-xsrf': 'kibana' },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
cy.request({
method: 'POST',
Expand All @@ -93,7 +95,7 @@ describe('Agent binary download source section', () => {
id: 'new-agent-policy',
download_source_id: 'fleet-local-registry',
},
headers: { 'kbn-xsrf': 'kibana' },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
}).then((response: any) => {
navigateTo('app/fleet/policies/new-agent-policy/settings');
cy.getBySel(AGENT_POLICY_FORM.DOWNLOAD_SOURCE_SELECT).contains('Custom Host');
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/cypress/e2e/agents/agent_list.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { deleteFleetServerDocs, deleteAgentDocs, cleanupAgentPolicies } from '..
import type { CreateAgentPolicyRequest } from '../../../common/types';
import { setUISettings } from '../../tasks/ui_settings';

import { API_VERSIONS } from '../../../common/constants';

const createAgentDocs = (kibanaVersion: string) => [
createAgentDoc('agent-1', 'policy-1'), // this agent will have upgrade available
createAgentDoc('agent-2', 'policy-2', 'error', kibanaVersion),
Expand Down Expand Up @@ -66,7 +68,7 @@ function createAgentPolicy(body: CreateAgentPolicyRequest['body']) {
cy.request({
method: 'POST',
url: '/api/fleet/agent_policies',
headers: { 'kbn-xsrf': 'xx' },
headers: { 'kbn-xsrf': 'xx', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body,
});
}
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/cypress/e2e/enrollment_token.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import { cleanupAgentPolicies } from '../tasks/cleanup';
import { ENROLLMENT_TOKENS } from '../screens/fleet';

import { API_VERSIONS } from '../../common/constants';

describe('Enrollment token page', () => {
before(() => {
cy.request({
Expand All @@ -20,7 +22,7 @@ describe('Enrollment token page', () => {
monitoring_enabled: ['logs', 'metrics'],
id: 'agent-policy-1',
},
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});

Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/cypress/e2e/fleet_agent_flyout.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { createAgentDoc } from '../tasks/agents';
import { setFleetServerHost } from '../tasks/fleet_server';
import { FLEET, navigateTo } from '../tasks/navigation';

import { API_VERSIONS } from '../../common/constants';

const FLEET_SERVER_POLICY_ID = 'fleet-server-policy';

function cleanUp() {
Expand All @@ -28,7 +30,7 @@ describe('Fleet add agent flyout', () => {
cy.request({
method: 'POST',
url: '/api/fleet/agent_policies',
headers: { 'kbn-xsrf': 'xx' },
headers: { 'kbn-xsrf': 'xx', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: {
id: FLEET_SERVER_POLICY_ID,
name: 'Fleet Server policy',
Expand Down
3 changes: 2 additions & 1 deletion x-pack/plugins/fleet/cypress/e2e/integrations_real.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
import { LOADING_SPINNER, CONFIRM_MODAL } from '../screens/navigation';
import { ADD_PACKAGE_POLICY_BTN } from '../screens/fleet';
import { cleanupAgentPolicies } from '../tasks/cleanup';
import { API_VERSIONS } from '../../common/constants';

function setupIntegrations() {
cy.intercept(
Expand Down Expand Up @@ -135,7 +136,7 @@ describe('Add Integration - Real API', () => {
namespace: 'default',
monitoring_enabled: ['logs', 'metrics'],
},
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});

cy.request('/api/fleet/agent_policies').then((response: any) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const INPUT_TEST_PACKAGE = 'input_package-1.0.0';
const INTEGRATION_TEST_PACKAGE = 'logs_integration-1.0.0';
const INTEGRATION_TEST_PACKAGE_NO_DATASET = 'logs_int_no_dataset-1.0.0';

import { API_VERSIONS } from '../../common/constants';

describe('Input package create and edit package policy', () => {
const agentPolicyId = 'test-input-package-policy';
const agentPolicyName = 'Test input package policy';
Expand Down Expand Up @@ -45,15 +47,15 @@ describe('Input package create and edit package policy', () => {
namespace: 'default',
monitoring_enabled: [],
},
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
after(() => {
// delete agent policy
cy.request({
method: 'POST',
url: `/api/fleet/agent_policies/delete`,
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: JSON.stringify({
agentPolicyId,
}),
Expand Down Expand Up @@ -120,15 +122,15 @@ describe('Integration package with custom dataset create and edit package policy
namespace: 'default',
monitoring_enabled: [],
},
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
after(() => {
// delete agent policy
cy.request({
method: 'POST',
url: `/api/fleet/agent_policies/delete`,
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: JSON.stringify({
agentPolicyId,
}),
Expand Down Expand Up @@ -184,15 +186,15 @@ describe('Integration package with fixed dataset create and edit package policy'
namespace: 'default',
monitoring_enabled: [],
},
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
after(() => {
// delete agent policy
cy.request({
method: 'POST',
url: `/api/fleet/agent_policies/delete`,
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
body: JSON.stringify({
agentPolicyId,
}),
Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/fleet/cypress/e2e/uninstall_token.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { cleanupAgentPolicies } from '../tasks/cleanup';
import { UNINSTALL_TOKENS } from '../screens/fleet';
import type { GetUninstallTokenResponse } from '../../common/types/rest_spec/uninstall_token';

import { API_VERSIONS } from '../../common/constants';

describe('Uninstall token page', () => {
before(() => {
cleanupAgentPolicies();
Expand Down Expand Up @@ -78,7 +80,7 @@ describe('Uninstall token page', () => {
method: 'POST',
url: '/api/fleet/agent_policies',
body: { name: `Agent policy ${i}00`, namespace: 'default', id: `agent-policy-${i}00` },
headers: { 'kbn-xsrf': 'cypress' },
headers: { 'kbn-xsrf': 'cypress', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
}
};
Expand Down
8 changes: 7 additions & 1 deletion x-pack/plugins/fleet/cypress/plugins/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import fs from 'fs';
import fetch from 'node-fetch';
import { createEsClientForTesting } from '@kbn/test';

import { API_VERSIONS } from '../../common/constants';

const plugin: Cypress.PluginConfig = (on, config) => {
const client = createEsClientForTesting({
esUrl: config.env.ELASTICSEARCH_URL,
Expand All @@ -22,8 +24,9 @@ const plugin: Cypress.PluginConfig = (on, config) => {
path: string;
body?: any;
contentType?: string;
version?: string;
}) {
const { method, path, body, contentType } = opts;
const { method, path, body, contentType, version } = opts;
const Authorization = `Basic ${Buffer.from(
`elastic:${config.env.ELASTICSEARCH_PASSWORD}`
).toString('base64')}`;
Expand All @@ -35,6 +38,7 @@ const plugin: Cypress.PluginConfig = (on, config) => {
'kbn-xsrf': 'cypress',
'Content-Type': contentType || 'application/json',
Authorization,
...(version ? { 'Elastic-Api-Version': version } : {}),
},
...(body ? { body } : {}),
});
Expand Down Expand Up @@ -75,13 +79,15 @@ const plugin: Cypress.PluginConfig = (on, config) => {
path: '/api/fleet/epm/packages',
body: Buffer.from(zipContent, 'base64'),
contentType: 'application/zip',
version: API_VERSIONS.public.v1,
});
},

async uninstallTestPackage(packageName: string) {
return kibanaFetch({
method: 'DELETE',
path: `/api/fleet/epm/packages/${packageName}`,
version: API_VERSIONS.public.v1,
});
},
});
Expand Down
7 changes: 4 additions & 3 deletions x-pack/plugins/fleet/cypress/tasks/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { API_VERSIONS } from '../../common/constants';

export function cleanupAgentPolicies() {
cy.request('/api/fleet/agent_policies').then((response: any) => {
Expand All @@ -14,7 +15,7 @@ export function cleanupAgentPolicies() {
method: 'POST',
url: '/api/fleet/agent_policies/delete',
body: { agentPolicyId: policy.id },
headers: { 'kbn-xsrf': 'kibana' },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
});
Expand All @@ -28,7 +29,7 @@ export function unenrollAgent() {
method: 'POST',
url: `api/fleet/agents/${agent.id}/unenroll`,
body: { revoke: true },
headers: { 'kbn-xsrf': 'kibana' },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
}
Expand All @@ -43,7 +44,7 @@ export function cleanupDownloadSources() {
cy.request({
method: 'DELETE',
url: `/api/fleet/agent_download_sources/${ds.id}`,
headers: { 'kbn-xsrf': 'kibana' },
headers: { 'kbn-xsrf': 'kibana', 'Elastic-Api-Version': `${API_VERSIONS.public.v1}` },
});
});
});
Expand Down
Loading

0 comments on commit ac172e7

Please sign in to comment.