Skip to content

Commit

Permalink
Merge branch 'main' into editable-required-fields
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaindik authored May 15, 2024
2 parents 1b1221b + 70b1879 commit 9489507
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 24 deletions.
36 changes: 20 additions & 16 deletions .buildkite/scripts/steps/serverless/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ deploy() {
}'

echo "--- Create $PROJECT_TYPE_LABEL project"
DEPLOY_LOGS=$(mktemp --suffix ".json")

echo "Checking if project already exists..."
PROJECT_DEPLOY_LOGS=$(mktemp --suffix ".json")
PROJECT_EXISTS_LOGS=$(mktemp --suffix ".json")
PROJECT_INFO_LOGS=$(mktemp --suffix ".json")

curl -s \
-H "Authorization: ApiKey $PROJECT_API_KEY" \
"${PROJECT_API_DOMAIN}/api/v1/serverless/projects/${PROJECT_TYPE}" \
-XGET &>> $DEPLOY_LOGS
-XGET &> $PROJECT_EXISTS_LOGS

PROJECT_ID=$(jq -r --slurp '[.[0].items[] | select(.name == "'$PROJECT_NAME'")] | .[0].id' $DEPLOY_LOGS)
PROJECT_ID=$(jq -r '[.items[] | select(.name == "'$PROJECT_NAME'")] | .[0].id' $PROJECT_EXISTS_LOGS)
if is_pr_with_label "ci:project-redeploy"; then
if [ -z "${PROJECT_ID}" ]; then
echo "No project to remove"
Expand All @@ -72,21 +75,16 @@ deploy() {
-H "Authorization: ApiKey $PROJECT_API_KEY" \
-H "Content-Type: application/json" \
"${PROJECT_API_DOMAIN}/api/v1/serverless/projects/${PROJECT_TYPE}" \
-XPOST -d "$PROJECT_CREATE_CONFIGURATION" &>> $DEPLOY_LOGS
-XPOST -d "$PROJECT_CREATE_CONFIGURATION" &> $PROJECT_DEPLOY_LOGS

PROJECT_ID=$(jq -r --slurp '.[1].id' $DEPLOY_LOGS)
PROJECT_ID=$(jq -r '.id' $PROJECT_DEPLOY_LOGS)
if [ -z "${PROJECT_ID}" ] || [ "$PROJECT_ID" = 'null' ]; then
echo "Failed to create project. Deploy logs:"
cat $DEPLOY_LOGS
cat $PROJECT_DEPLOY_LOGS
exit 1
fi

echo "Get credentials..."
curl -s -XPOST -H "Authorization: ApiKey $PROJECT_API_KEY" \
"${PROJECT_API_DOMAIN}/api/v1/serverless/projects/${PROJECT_TYPE}/${PROJECT_ID}/_reset-internal-credentials" &>> $DEPLOY_LOGS

PROJECT_USERNAME=$(jq -r --slurp '.[2].username' $DEPLOY_LOGS)
PROJECT_PASSWORD=$(jq -r --slurp '.[2].password' $DEPLOY_LOGS)
PROJECT_USERNAME=$(jq -r '.credentials.username' $PROJECT_DEPLOY_LOGS)
PROJECT_PASSWORD=$(jq -r '.credentials.password' $PROJECT_DEPLOY_LOGS)

echo "Write to vault..."

Expand All @@ -107,12 +105,18 @@ deploy() {
-H "Authorization: ApiKey $PROJECT_API_KEY" \
-H "Content-Type: application/json" \
"${PROJECT_API_DOMAIN}/api/v1/serverless/projects/${PROJECT_TYPE}/${PROJECT_ID}" \
-XPUT -d "$PROJECT_UPDATE_CONFIGURATION" &>> $DEPLOY_LOGS
-XPUT -d "$PROJECT_UPDATE_CONFIGURATION" &> $PROJECT_DEPLOY_LOGS
fi

PROJECT_KIBANA_URL=$(jq -r --slurp '.[1].endpoints.kibana' $DEPLOY_LOGS)
echo "Getting project info..."
curl -s \
-H "Authorization: ApiKey $PROJECT_API_KEY" \
"${PROJECT_API_DOMAIN}/api/v1/serverless/projects/${PROJECT_TYPE}/${PROJECT_ID}" \
-XGET &> $PROJECT_INFO_LOGS

PROJECT_KIBANA_URL=$(jq -r '.endpoints.kibana' $PROJECT_INFO_LOGS)
PROJECT_KIBANA_LOGIN_URL="${PROJECT_KIBANA_URL}/login"
PROJECT_ELASTICSEARCH_URL=$(jq -r --slurp '.[1].endpoints.elasticsearch' $DEPLOY_LOGS)
PROJECT_ELASTICSEARCH_URL=$(jq -r '.endpoints.elasticsearch' $PROJECT_INFO_LOGS)

# TODO: remove after https://github.com/elastic/kibana-operations/issues/15 is done
if [[ "$IS_LEGACY_VAULT_ADDR" == "true" ]]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ jest.mock('./api');

const useKibanaMock = useKibana as jest.Mock;

describe('useGetCurrentUserProfile', () => {
// FLAKY: https://github.com/elastic/kibana/issues/183144
describe.skip('useGetCurrentUserProfile', () => {
const addSuccess = jest.fn();
(useToasts as jest.Mock).mockReturnValue({ addSuccess, addError: jest.fn() });

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* 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 { SerializedEvent } from '@kbn/ui-actions-enhanced-plugin/common/types';
import { getDynamicActionsState } from './get_dynamic_actions_state';

describe('getDynamicActionsState', () => {
test('should return empty state when enhancements is undefined', () => {
expect(getDynamicActionsState()).toEqual({ dynamicActions: { events: [] } });
});

test('should return empty state when enhancements is empty object', () => {
expect(getDynamicActionsState({})).toEqual({ dynamicActions: { events: [] } });
});

test('should return empty state when enhancements.dynamicActions is undefined', () => {
expect(getDynamicActionsState({ dynamicActions: undefined })).toEqual({
dynamicActions: { events: [] },
});
});

test('should return empty state when enhancements.dynamicActions is empty object', () => {
expect(getDynamicActionsState({ dynamicActions: {} })).toEqual({
dynamicActions: { events: [] },
});
});

test('should return state when enhancements.dynamicActions is provided', () => {
expect(
getDynamicActionsState({ dynamicActions: { events: [{} as unknown as SerializedEvent] } })
).toEqual({ dynamicActions: { events: [{}] } });
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* 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 type { DynamicActionsState } from '@kbn/ui-actions-enhanced-plugin/public';

export function getDynamicActionsState(enhancements?: {
dynamicActions?: Partial<DynamicActionsState>;
}) {
return {
dynamicActions: {
events: [],
...(enhancements?.dynamicActions ?? {}),
},
};
}
5 changes: 3 additions & 2 deletions x-pack/plugins/embeddable_enhanced/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import {
} from './embeddables/dynamic_action_storage';
import { HasDynamicActions } from './embeddables/interfaces/has_dynamic_actions';
import { EnhancedEmbeddable } from './types';
import { getDynamicActionsState } from './get_dynamic_actions_state';

export interface SetupDependencies {
embeddable: EmbeddableSetup;
Expand Down Expand Up @@ -148,7 +149,7 @@ export class EmbeddableEnhancedPlugin
startDynamicActions: () => { stopDynamicActions: () => void };
} {
const dynamicActionsState$ = new BehaviorSubject<DynamicActionsSerializedState['enhancements']>(
{ dynamicActions: { events: [] }, ...(state.enhancements ?? {}) }
getDynamicActionsState(state.enhancements)
);
const api: DynamicActionStorageApi = {
dynamicActionsState$,
Expand All @@ -173,7 +174,7 @@ export class EmbeddableEnhancedPlugin
dynamicActionsState$,
api.setDynamicActions,
(a, b) => {
return deepEqual(a, b);
return deepEqual(getDynamicActionsState(a), getDynamicActionsState(b));
},
],
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const supertest = getService('supertest');

describe('Lists API', () => {
// FLAKY: https://github.com/elastic/kibana/issues/151636
describe.skip('Lists API', () => {
before(async () => await esArchiver.load('x-pack/test/functional/es_archives/lists'));

after(async () => await esArchiver.unload('x-pack/test/functional/es_archives/lists'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,8 @@ describe('indicator match', { tags: ['@ess', '@serverless'] }, () => {
});
});

describe('Indicator mapping', () => {
// FLAKY: https://github.com/elastic/kibana/issues/182669
describe.skip('Indicator mapping', () => {
beforeEach(() => {
const rule = getNewThreatIndicatorRule();
visit(CREATE_RULE_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('Timeline scope', { tags: ['@ess', '@serverless', '@skipInServerless']
});

// FLAKY: https://github.com/elastic/kibana/issues/173854
describe('Modified badge', () => {
describe.skip('Modified badge', () => {
it('Selecting new data view does not add a modified badge', () => {
openTimelineUsingToggle();
cy.get(SOURCERER.badgeModified).should(`not.exist`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ describe('Fields Browser', { tags: ['@ess', '@serverless'] }, () => {
openTimelineFieldsBrowser();
});

describe('Fields Browser rendering', () => {
// FLAKY: https://github.com/elastic/kibana/issues/178776
describe.skip('Fields Browser rendering', () => {
it('should display the expected count of categories and fields that match the filter input', () => {
const filterInput = 'host.mac';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ import {

import { hostsUrl } from '../../../urls/navigation';

describe('timeline flyout button', () => {
// FLAKY: https://github.com/elastic/kibana/issues/183085
describe.skip('timeline flyout button', () => {
beforeEach(() => {
login();
visitWithTimeRange(hostsUrl('allHosts'));
Expand Down

0 comments on commit 9489507

Please sign in to comment.