Skip to content

Commit

Permalink
merge: merge branch 'ESAS/add_polling_delay_SDCOSMO-1768'
Browse files Browse the repository at this point in the history
  • Loading branch information
csm-thu committed Apr 26, 2024
2 parents 111b7d6 + 366912f commit 1b31032
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cypress/commons/actions/generic/DatasetManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ export const getDatasetOverviewPlaceholderApiLink = () => cy.get(SELECTORS.overv

export const getIndicatorCard = (kpiId) => cy.get(SELECTORS.overview.indicators.cardByKpiId.replace('$KPI_ID', kpiId));
export const getKpiLoading = (parent) => parent.find(SELECTORS.overview.indicators.kpiLoading);
export const getKpiValue = (parent) => parent.find(SELECTORS.overview.indicators.kpiValue);
export const getKpiValue = (parent, timeout) =>
parent.find(SELECTORS.overview.indicators.kpiValue, timeout ? { timeout: timeout * 1000 } : undefined);
export const getKpiError = (parent) => parent.find(SELECTORS.overview.indicators.kpiError);
export const getKpiUnknownState = (parent) => parent.find(SELECTORS.overview.indicators.kpiUnknownState);

Expand Down
11 changes: 7 additions & 4 deletions cypress/commons/utils/apiUtils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Copyright (c) Cosmo Tech.
// Licensed under the MIT license.
import { POLLING_START_DELAY } from '../../../src/services/config/FunctionalConstants';
import utils from '../../commons/TestUtils';
import { DEFAULT_DATASET, SCENARIO_EXAMPLE, SCENARIO_RUN_EXAMPLE } from '../../fixtures/stubbing/default';
import { API_ENDPOINT, API_REGEX, AUTH_QUERY_URL, URL_POWERBI, URL_ROOT } from '../constants/generic/TestConstants';
Expand Down Expand Up @@ -137,11 +138,13 @@ const interceptLaunchScenario = (stubbingOptions) => {
stub.patchScenario(scenarioId, { state: 'Running', lastRun: scenarioLastRun });

setTimeout(() => {
stub.patchScenario(scenarioId, { state: 'DataIngestionInProgress' });
setTimeout(() => {
stub.patchScenario(scenarioId, { state: finalStatus });
}, dataIngestionDuration);
}, runDuration);
stub.patchScenario(scenarioId, { state: 'DataIngestionInProgress' });
setTimeout(() => {
stub.patchScenario(scenarioId, { state: finalStatus });
}, dataIngestionDuration);
}, runDuration);
}, POLLING_START_DELAY);

req.reply(scenarioRun);
}
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/brewery/DatasetManager_e2e.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ describe('End-to-end test of the dataset manager view', () => {
DatasetManager.getAllReuploadDatasetButtons().click();
DatasetManager.getConfirmDatasetRefreshButton().click();
DatasetManager.getAllReuploadDatasetInputs().attachFile(NINE_CUSTOMERS_DATASET_ZIP_FILE_PATH);
DatasetManager.getKpiValue(DatasetManager.getIndicatorCard('satisfaction_links_count')).should('have.text', 16);
DatasetManager.getKpiValue(DatasetManager.getIndicatorCard('satisfaction_links_count'), 10).should('have.text', 16);

DatasetManager.getAllDeleteDatasetButtons().click();
DatasetManager.getDeleteDatasetDialogBody().contains(fileDatasetName);
Expand Down
1 change: 1 addition & 0 deletions src/services/config/FunctionalConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const SESSION_INACTIVITY_TIMEOUT = 30;

// Polling delay to update running scenario status (milliseconds)
export const SCENARIO_STATUS_POLLING_DELAY = 10000;
export const POLLING_START_DELAY = 5000;

// Polling delay to update Power BI information (milliseconds)
export const POWER_BI_INFO_POLLING_DELAY = 10000;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { t } from 'i18next';
import { call, delay, put, select, takeEvery } from 'redux-saga/effects';
import { Api } from '../../../../services/config/Api';
import { INGESTION_STATUS, TWINCACHE_STATUS } from '../../../../services/config/ApiConstants';
import { TWINGRAPH_STATUS_POLLING_DELAY } from '../../../../services/config/FunctionalConstants';
import { POLLING_START_DELAY, TWINGRAPH_STATUS_POLLING_DELAY } from '../../../../services/config/FunctionalConstants';
import { DATASET_ACTIONS_KEY, DATASET_TWINGRAPH_QUERIES_RESULTS_ACTIONS } from '../../../commons/DatasetConstants';
import { dispatchSetApplicationErrorMessage } from '../../../dispatchers/app/ApplicationDispatcher';

Expand All @@ -15,7 +15,10 @@ export function* pollTwingraphStatus(action) {
let twingraphStatus = INGESTION_STATUS.PENDING;
const datasetId = action.datasetId;
const organizationId = action.organizationId;

// Polling start is delayed to avoid an erroneous ERROR status due to the fact that, probably, the creation of
// an AKS container takes time and API returns ERROR while the creation of the twingraph is successful.
// For more details, see https://cosmo-tech.atlassian.net/browse/SDCOSMO-1768
yield delay(POLLING_START_DELAY);
try {
do {
const { data: newStatus } = yield call(Api.Datasets.getDatasetTwingraphStatus, organizationId, datasetId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { call, put, take, takeEvery, delay, race, select } from 'redux-saga/effe
import { AppInsights } from '../../../../services/AppInsights';
import { Api } from '../../../../services/config/Api';
import { SCENARIO_RUN_STATE } from '../../../../services/config/ApiConstants';
import { SCENARIO_STATUS_POLLING_DELAY } from '../../../../services/config/FunctionalConstants';
import { POLLING_START_DELAY, SCENARIO_STATUS_POLLING_DELAY } from '../../../../services/config/FunctionalConstants';
import { STATUSES } from '../../../commons/Constants';
import { SCENARIO_ACTIONS_KEY } from '../../../commons/ScenarioConstants';
import { dispatchSetApplicationErrorMessage } from '../../../dispatchers/app/ApplicationDispatcher';
Expand All @@ -21,6 +21,11 @@ function forgeStopPollingAction(scenarioId) {
const getCurrentScenarioState = (state) => state.scenario.current?.data?.state;

export function* pollScenarioState(action) {
// Polling start is delayed to avoid an erroneous Unknown state due to the fact that in first seconds of the run,
// the AKS container isn't created yet and scenario.state passes to Unknown for a few seconds before returning to
// Running again.
// For more details, see https://cosmo-tech.atlassian.net/browse/SDCOSMO-1768
yield delay(POLLING_START_DELAY);
// Loop until the scenario state is FAILED, SUCCESS or UNKNOWN
while (true) {
try {
Expand Down

0 comments on commit 1b31032

Please sign in to comment.