Commit ab669cf5 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '340627-rename-job-trace-store' into 'master'

Rename job trace to job log in code

See merge request gitlab-org/gitlab!70432
parents 4d1d5a4b 99098b5b
...@@ -139,6 +139,7 @@ export const receiveJobLogsSuccess = ({ commit }, data) => ...@@ -139,6 +139,7 @@ export const receiveJobLogsSuccess = ({ commit }, data) =>
export const fetchJobLogs = ({ dispatch, state }) => { export const fetchJobLogs = ({ dispatch, state }) => {
dispatch('requestJobLogs'); dispatch('requestJobLogs');
// update trace endpoint once BE compeletes trace re-naming in #340626
return axios return axios
.get(`${state.detailJob.path}/trace`, { params: { format: 'json' } }) .get(`${state.detailJob.path}/trace`, { params: { format: 'json' } })
.then(({ data }) => dispatch('receiveJobLogsSuccess', data)) .then(({ data }) => dispatch('receiveJobLogsSuccess', data))
......
...@@ -80,13 +80,13 @@ export default { ...@@ -80,13 +80,13 @@ export default {
'isLoading', 'isLoading',
'job', 'job',
'isSidebarOpen', 'isSidebarOpen',
'trace', 'jobLog',
'isTraceComplete', 'isJobLogComplete',
'traceSize', 'jobLogSize',
'isTraceSizeVisible', 'isJobLogSizeVisible',
'isScrollBottomDisabled', 'isScrollBottomDisabled',
'isScrollTopDisabled', 'isScrollTopDisabled',
'isScrolledToBottomBeforeReceivingTrace', 'isScrolledToBottomBeforeReceivingJobLog',
'hasError', 'hasError',
'selectedStage', 'selectedStage',
]), ]),
...@@ -97,7 +97,7 @@ export default { ...@@ -97,7 +97,7 @@ export default {
'shouldRenderTriggeredLabel', 'shouldRenderTriggeredLabel',
'hasEnvironment', 'hasEnvironment',
'shouldRenderSharedRunnerLimitWarning', 'shouldRenderSharedRunnerLimitWarning',
'hasTrace', 'hasJobLog',
'emptyStateIllustration', 'emptyStateIllustration',
'isScrollingDown', 'isScrollingDown',
'emptyStateAction', 'emptyStateAction',
...@@ -155,7 +155,7 @@ export default { ...@@ -155,7 +155,7 @@ export default {
this.updateSidebar(); this.updateSidebar();
}, },
beforeDestroy() { beforeDestroy() {
this.stopPollingTrace(); this.stopPollingJobLog();
this.stopPolling(); this.stopPolling();
window.removeEventListener('resize', this.onResize); window.removeEventListener('resize', this.onResize);
window.removeEventListener('scroll', this.updateScroll); window.removeEventListener('scroll', this.updateScroll);
...@@ -168,7 +168,7 @@ export default { ...@@ -168,7 +168,7 @@ export default {
'toggleSidebar', 'toggleSidebar',
'scrollBottom', 'scrollBottom',
'scrollTop', 'scrollTop',
'stopPollingTrace', 'stopPollingJobLog',
'stopPolling', 'stopPolling',
'toggleScrollButtons', 'toggleScrollButtons',
'toggleScrollAnimation', 'toggleScrollAnimation',
...@@ -270,7 +270,7 @@ export default { ...@@ -270,7 +270,7 @@ export default {
<div <div
v-if="job.archived" v-if="job.archived"
class="gl-mt-3 gl-py-2 gl-px-3 gl-align-items-center gl-z-index-1 gl-m-auto archived-job" class="gl-mt-3 gl-py-2 gl-px-3 gl-align-items-center gl-z-index-1 gl-m-auto archived-job"
:class="{ 'sticky-top gl-border-bottom-0': hasTrace }" :class="{ 'sticky-top gl-border-bottom-0': hasJobLog }"
data-testid="archived-job" data-testid="archived-job"
> >
<gl-icon name="lock" class="gl-vertical-align-bottom" /> <gl-icon name="lock" class="gl-vertical-align-bottom" />
...@@ -278,7 +278,7 @@ export default { ...@@ -278,7 +278,7 @@ export default {
</div> </div>
<!-- job log --> <!-- job log -->
<div <div
v-if="hasTrace" v-if="hasJobLog"
class="build-trace-container gl-relative" class="build-trace-container gl-relative"
:class="{ 'gl-mt-3': !job.archived }" :class="{ 'gl-mt-3': !job.archived }"
> >
...@@ -289,22 +289,22 @@ export default { ...@@ -289,22 +289,22 @@ export default {
'has-archived-block': job.archived, 'has-archived-block': job.archived,
}" }"
:erase-path="job.erase_path" :erase-path="job.erase_path"
:size="traceSize" :size="jobLogSize"
:raw-path="job.raw_path" :raw-path="job.raw_path"
:is-scroll-bottom-disabled="isScrollBottomDisabled" :is-scroll-bottom-disabled="isScrollBottomDisabled"
:is-scroll-top-disabled="isScrollTopDisabled" :is-scroll-top-disabled="isScrollTopDisabled"
:is-trace-size-visible="isTraceSizeVisible" :is-job-log-size-visible="isJobLogSizeVisible"
:is-scrolling-down="isScrollingDown" :is-scrolling-down="isScrollingDown"
@scrollJobLogTop="scrollTop" @scrollJobLogTop="scrollTop"
@scrollJobLogBottom="scrollBottom" @scrollJobLogBottom="scrollBottom"
/> />
<log :trace="trace" :is-complete="isTraceComplete" /> <log :job-log="jobLog" :is-complete="isJobLogComplete" />
</div> </div>
<!-- EO job log --> <!-- EO job log -->
<!-- empty state --> <!-- empty state -->
<empty-state <empty-state
v-if="!hasTrace" v-if="!hasJobLog"
:illustration-path="emptyStateIllustration.image" :illustration-path="emptyStateIllustration.image"
:illustration-size-class="emptyStateIllustration.size" :illustration-size-class="emptyStateIllustration.size"
:title="emptyStateTitle" :title="emptyStateTitle"
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
isTraceSizeVisible: { isJobLogSizeVisible: {
type: Boolean, type: Boolean,
required: true, required: true,
}, },
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
class="truncated-info gl-display-none gl-sm-display-block gl-float-left" class="truncated-info gl-display-none gl-sm-display-block gl-float-left"
data-testid="log-truncated-info" data-testid="log-truncated-info"
> >
<template v-if="isTraceSizeVisible"> <template v-if="isJobLogSizeVisible">
{{ jobLogSize }} {{ jobLogSize }}
<gl-link <gl-link
v-if="rawPath" v-if="rawPath"
......
...@@ -17,7 +17,7 @@ export default { ...@@ -17,7 +17,7 @@ export default {
type: Object, type: Object,
required: true, required: true,
}, },
traceEndpoint: { jobLogEndpoint: {
type: String, type: String,
required: true, required: true,
}, },
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
<log-line-header <log-line-header
:line="section.line" :line="section.line"
:duration="badgeDuration" :duration="badgeDuration"
:path="traceEndpoint" :path="jobLogEndpoint"
:is-closed="section.isClosed" :is-closed="section.isClosed"
@toggleLine="handleOnClickCollapsibleLine(section)" @toggleLine="handleOnClickCollapsibleLine(section)"
/> />
...@@ -53,10 +53,10 @@ export default { ...@@ -53,10 +53,10 @@ export default {
v-if="line.isHeader" v-if="line.isHeader"
:key="line.line.offset" :key="line.line.offset"
:section="line" :section="line"
:trace-endpoint="traceEndpoint" :job-log-endpoint="jobLogEndpoint"
@onClickCollapsibleLine="handleOnClickCollapsibleLine" @onClickCollapsibleLine="handleOnClickCollapsibleLine"
/> />
<log-line v-else :key="line.offset" :line="line" :path="traceEndpoint" /> <log-line v-else :key="line.offset" :line="line" :path="jobLogEndpoint" />
</template> </template>
</template> </template>
<template v-else> <template v-else>
...@@ -64,7 +64,7 @@ export default { ...@@ -64,7 +64,7 @@ export default {
v-for="line in section.lines" v-for="line in section.lines"
:key="line.offset" :key="line.offset"
:line="line" :line="line"
:path="traceEndpoint" :path="jobLogEndpoint"
/> />
</template> </template>
</template> </template>
......
...@@ -10,10 +10,10 @@ export default { ...@@ -10,10 +10,10 @@ export default {
}, },
computed: { computed: {
...mapState([ ...mapState([
'traceEndpoint', 'jobLogEndpoint',
'trace', 'jobLog',
'isTraceComplete', 'isJobLogComplete',
'isScrolledToBottomBeforeReceivingTrace', 'isScrolledToBottomBeforeReceivingJobLog',
]), ]),
}, },
updated() { updated() {
...@@ -39,7 +39,7 @@ export default { ...@@ -39,7 +39,7 @@ export default {
* In order to scroll the page down after `v-html` has finished, we need to use setTimeout * In order to scroll the page down after `v-html` has finished, we need to use setTimeout
*/ */
handleScrollDown() { handleScrollDown() {
if (this.isScrolledToBottomBeforeReceivingTrace) { if (this.isScrolledToBottomBeforeReceivingJobLog) {
setTimeout(() => { setTimeout(() => {
this.scrollBottom(); this.scrollBottom();
}, 0); }, 0);
...@@ -50,18 +50,18 @@ export default { ...@@ -50,18 +50,18 @@ export default {
</script> </script>
<template> <template>
<code class="job-log d-block" data-qa-selector="job_log_content"> <code class="job-log d-block" data-qa-selector="job_log_content">
<template v-for="(section, index) in trace"> <template v-for="(section, index) in jobLog">
<collapsible-log-section <collapsible-log-section
v-if="section.isHeader" v-if="section.isHeader"
:key="`collapsible-${index}`" :key="`collapsible-${index}`"
:section="section" :section="section"
:trace-endpoint="traceEndpoint" :job-log-endpoint="jobLogEndpoint"
@onClickCollapsibleLine="handleOnClickCollapsibleLine" @onClickCollapsibleLine="handleOnClickCollapsibleLine"
/> />
<log-line v-else :key="section.offset" :line="section" :path="traceEndpoint" /> <log-line v-else :key="section.offset" :line="section" :path="jobLogEndpoint" />
</template> </template>
<div v-if="!isTraceComplete" class="js-log-animation loader-animation pt-3 pl-3"> <div v-if="!isJobLogComplete" class="js-log-animation loader-animation pt-3 pl-3">
<div class="dot"></div> <div class="dot"></div>
<div class="dot"></div> <div class="dot"></div>
<div class="dot"></div> <div class="dot"></div>
......
...@@ -18,16 +18,16 @@ import * as types from './mutation_types'; ...@@ -18,16 +18,16 @@ import * as types from './mutation_types';
export const init = ({ dispatch }, { endpoint, logState, pagePath }) => { export const init = ({ dispatch }, { endpoint, logState, pagePath }) => {
dispatch('setJobEndpoint', endpoint); dispatch('setJobEndpoint', endpoint);
dispatch('setTraceOptions', { dispatch('setJobLogOptions', {
logState, logState,
pagePath, pagePath,
}); });
return Promise.all([dispatch('fetchJob'), dispatch('fetchTrace')]); return Promise.all([dispatch('fetchJob'), dispatch('fetchJobLog')]);
}; };
export const setJobEndpoint = ({ commit }, endpoint) => commit(types.SET_JOB_ENDPOINT, endpoint); export const setJobEndpoint = ({ commit }, endpoint) => commit(types.SET_JOB_ENDPOINT, endpoint);
export const setTraceOptions = ({ commit }, options) => commit(types.SET_TRACE_OPTIONS, options); export const setJobLogOptions = ({ commit }, options) => commit(types.SET_JOB_LOG_OPTIONS, options);
export const hideSidebar = ({ commit }) => commit(types.HIDE_SIDEBAR); export const hideSidebar = ({ commit }) => commit(types.HIDE_SIDEBAR);
export const showSidebar = ({ commit }) => commit(types.SHOW_SIDEBAR); export const showSidebar = ({ commit }) => commit(types.SHOW_SIDEBAR);
...@@ -107,7 +107,7 @@ export const receiveJobError = ({ commit }) => { ...@@ -107,7 +107,7 @@ export const receiveJobError = ({ commit }) => {
}; };
/** /**
* Job's Trace * Job Log
*/ */
export const scrollTop = ({ dispatch }) => { export const scrollTop = ({ dispatch }) => {
scrollUp(); scrollUp();
...@@ -156,59 +156,62 @@ export const toggleScrollAnimation = ({ commit }, toggle) => ...@@ -156,59 +156,62 @@ export const toggleScrollAnimation = ({ commit }, toggle) =>
* Responsible to handle automatic scroll * Responsible to handle automatic scroll
*/ */
export const toggleScrollisInBottom = ({ commit }, toggle) => { export const toggleScrollisInBottom = ({ commit }, toggle) => {
commit(types.TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_TRACE, toggle); commit(types.TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_JOB_LOG, toggle);
}; };
export const requestTrace = ({ commit }) => commit(types.REQUEST_TRACE); export const requestJobLog = ({ commit }) => commit(types.REQUEST_JOB_LOG);
export const fetchTrace = ({ dispatch, state }) => export const fetchJobLog = ({ dispatch, state }) =>
// update trace endpoint once BE compeletes trace re-naming in #340626
axios axios
.get(`${state.traceEndpoint}/trace.json`, { .get(`${state.jobLogEndpoint}/trace.json`, {
params: { state: state.traceState }, params: { state: state.jobLogState },
}) })
.then(({ data }) => { .then(({ data }) => {
dispatch('toggleScrollisInBottom', isScrolledToBottom()); dispatch('toggleScrollisInBottom', isScrolledToBottom());
dispatch('receiveTraceSuccess', data); dispatch('receiveJobLogSuccess', data);
if (data.complete) { if (data.complete) {
dispatch('stopPollingTrace'); dispatch('stopPollingJobLog');
} else if (!state.traceTimeout) { } else if (!state.jobLogTimeout) {
dispatch('startPollingTrace'); dispatch('startPollingJobLog');
} }
}) })
.catch((e) => { .catch((e) => {
if (e.response.status === httpStatusCodes.FORBIDDEN) { if (e.response.status === httpStatusCodes.FORBIDDEN) {
dispatch('receiveTraceUnauthorizedError'); dispatch('receiveJobLogUnauthorizedError');
} else { } else {
reportToSentry('job_actions', e); reportToSentry('job_actions', e);
dispatch('receiveTraceError'); dispatch('receiveJobLogError');
} }
}); });
export const startPollingTrace = ({ dispatch, commit }) => { export const startPollingJobLog = ({ dispatch, commit }) => {
const traceTimeout = setTimeout(() => { const jobLogTimeout = setTimeout(() => {
commit(types.SET_TRACE_TIMEOUT, 0); commit(types.SET_JOB_LOG_TIMEOUT, 0);
dispatch('fetchTrace'); dispatch('fetchJobLog');
}, 4000); }, 4000);
commit(types.SET_TRACE_TIMEOUT, traceTimeout); commit(types.SET_JOB_LOG_TIMEOUT, jobLogTimeout);
}; };
export const stopPollingTrace = ({ state, commit }) => { export const stopPollingJobLog = ({ state, commit }) => {
clearTimeout(state.traceTimeout); clearTimeout(state.jobLogTimeout);
commit(types.SET_TRACE_TIMEOUT, 0); commit(types.SET_JOB_LOG_TIMEOUT, 0);
commit(types.STOP_POLLING_TRACE); commit(types.STOP_POLLING_JOB_LOG);
}; };
export const receiveTraceSuccess = ({ commit }, log) => commit(types.RECEIVE_TRACE_SUCCESS, log); export const receiveJobLogSuccess = ({ commit }, log) => commit(types.RECEIVE_JOB_LOG_SUCCESS, log);
export const receiveTraceError = ({ dispatch }) => {
dispatch('stopPollingTrace'); export const receiveJobLogError = ({ dispatch }) => {
dispatch('stopPollingJobLog');
createFlash({ createFlash({
message: __('An error occurred while fetching the job log.'), message: __('An error occurred while fetching the job log.'),
}); });
}; };
export const receiveTraceUnauthorizedError = ({ dispatch }) => {
dispatch('stopPollingTrace'); export const receiveJobLogUnauthorizedError = ({ dispatch }) => {
dispatch('stopPollingJobLog');
createFlash({ createFlash({
message: __('The current user is not authorized to access the job log.'), message: __('The current user is not authorized to access the job log.'),
}); });
...@@ -248,6 +251,7 @@ export const fetchJobsForStage = ({ dispatch }, stage = {}) => { ...@@ -248,6 +251,7 @@ export const fetchJobsForStage = ({ dispatch }, stage = {}) => {
}; };
export const receiveJobsForStageSuccess = ({ commit }, data) => export const receiveJobsForStageSuccess = ({ commit }, data) =>
commit(types.RECEIVE_JOBS_FOR_STAGE_SUCCESS, data); commit(types.RECEIVE_JOBS_FOR_STAGE_SUCCESS, data);
export const receiveJobsForStageError = ({ commit }) => { export const receiveJobsForStageError = ({ commit }) => {
commit(types.RECEIVE_JOBS_FOR_STAGE_ERROR); commit(types.RECEIVE_JOBS_FOR_STAGE_ERROR);
createFlash({ createFlash({
......
...@@ -21,11 +21,12 @@ export const shouldRenderTriggeredLabel = (state) => isString(state.job.started) ...@@ -21,11 +21,12 @@ export const shouldRenderTriggeredLabel = (state) => isString(state.job.started)
export const hasEnvironment = (state) => !isEmpty(state.job.deployment_status); export const hasEnvironment = (state) => !isEmpty(state.job.deployment_status);
/** /**
* Checks if it the job has trace. * Checks if it the job has a log.
* Used to check if it should render the job log or the empty state * Used to check if it should render the job log or the empty state
* @returns {Boolean} * @returns {Boolean}
*/ */
export const hasTrace = (state) => export const hasJobLog = (state) =>
// update has_trace once BE compeletes trace re-naming in #340626
state.job.has_trace || (!isEmpty(state.job.status) && state.job.status.group === 'running'); state.job.has_trace || (!isEmpty(state.job.status) && state.job.status.group === 'running');
export const emptyStateIllustration = (state) => state?.job?.status?.illustration || {}; export const emptyStateIllustration = (state) => state?.job?.status?.illustration || {};
...@@ -43,7 +44,7 @@ export const shouldRenderSharedRunnerLimitWarning = (state) => ...@@ -43,7 +44,7 @@ export const shouldRenderSharedRunnerLimitWarning = (state) =>
!isEmpty(state.job.runners.quota) && !isEmpty(state.job.runners.quota) &&
state.job.runners.quota.used >= state.job.runners.quota.limit; state.job.runners.quota.used >= state.job.runners.quota.limit;
export const isScrollingDown = (state) => isScrolledToBottom() && !state.isTraceComplete; export const isScrollingDown = (state) => isScrolledToBottom() && !state.isJobLogComplete;
export const hasRunnersForProject = (state) => export const hasRunnersForProject = (state) =>
state?.job?.runners?.available && !state?.job?.runners?.online; state?.job?.runners?.available && !state?.job?.runners?.online;
export const SET_JOB_ENDPOINT = 'SET_JOB_ENDPOINT'; export const SET_JOB_ENDPOINT = 'SET_JOB_ENDPOINT';
export const SET_TRACE_OPTIONS = 'SET_TRACE_OPTIONS'; export const SET_JOB_LOG_OPTIONS = 'SET_JOB_LOG_OPTIONS';
export const HIDE_SIDEBAR = 'HIDE_SIDEBAR'; export const HIDE_SIDEBAR = 'HIDE_SIDEBAR';
export const SHOW_SIDEBAR = 'SHOW_SIDEBAR'; export const SHOW_SIDEBAR = 'SHOW_SIDEBAR';
...@@ -12,17 +12,17 @@ export const ENABLE_SCROLL_BOTTOM = 'ENABLE_SCROLL_BOTTOM'; ...@@ -12,17 +12,17 @@ export const ENABLE_SCROLL_BOTTOM = 'ENABLE_SCROLL_BOTTOM';
export const ENABLE_SCROLL_TOP = 'ENABLE_SCROLL_TOP'; export const ENABLE_SCROLL_TOP = 'ENABLE_SCROLL_TOP';
export const TOGGLE_SCROLL_ANIMATION = 'TOGGLE_SCROLL_ANIMATION'; export const TOGGLE_SCROLL_ANIMATION = 'TOGGLE_SCROLL_ANIMATION';
export const TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_TRACE = 'TOGGLE_IS_SCROLL_IN_BOTTOM'; export const TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_JOB_LOG = 'TOGGLE_IS_SCROLL_IN_BOTTOM';
export const REQUEST_JOB = 'REQUEST_JOB'; export const REQUEST_JOB = 'REQUEST_JOB';
export const RECEIVE_JOB_SUCCESS = 'RECEIVE_JOB_SUCCESS'; export const RECEIVE_JOB_SUCCESS = 'RECEIVE_JOB_SUCCESS';
export const RECEIVE_JOB_ERROR = 'RECEIVE_JOB_ERROR'; export const RECEIVE_JOB_ERROR = 'RECEIVE_JOB_ERROR';
export const REQUEST_TRACE = 'REQUEST_TRACE'; export const REQUEST_JOB_LOG = 'REQUEST_JOB_LOG';
export const SET_TRACE_TIMEOUT = 'SET_TRACE_TIMEOUT'; export const SET_JOB_LOG_TIMEOUT = 'SET_JOB_LOG_TIMEOUT';
export const STOP_POLLING_TRACE = 'STOP_POLLING_TRACE'; export const STOP_POLLING_JOB_LOG = 'STOP_POLLING_JOB_LOG';
export const RECEIVE_TRACE_SUCCESS = 'RECEIVE_TRACE_SUCCESS'; export const RECEIVE_JOB_LOG_SUCCESS = 'RECEIVE_JOB_LOG_SUCCESS';
export const RECEIVE_TRACE_ERROR = 'RECEIVE_TRACE_ERROR'; export const RECEIVE_JOB_LOG_ERROR = 'RECEIVE_JOB_LOG_ERROR';
export const TOGGLE_COLLAPSIBLE_LINE = 'TOGGLE_COLLAPSIBLE_LINE'; export const TOGGLE_COLLAPSIBLE_LINE = 'TOGGLE_COLLAPSIBLE_LINE';
export const SET_SELECTED_STAGE = 'SET_SELECTED_STAGE'; export const SET_SELECTED_STAGE = 'SET_SELECTED_STAGE';
......
import Vue from 'vue'; import Vue from 'vue';
import { INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF } from '../constants'; import { INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF } from '../constants';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { logLinesParser, logLinesParserLegacy, updateIncrementalTrace } from './utils'; import { logLinesParser, logLinesParserLegacy, updateIncrementalJobLog } from './utils';
export default { export default {
[types.SET_JOB_ENDPOINT](state, endpoint) { [types.SET_JOB_ENDPOINT](state, endpoint) {
state.jobEndpoint = endpoint; state.jobEndpoint = endpoint;
}, },
[types.SET_TRACE_OPTIONS](state, options = {}) { [types.SET_JOB_LOG_OPTIONS](state, options = {}) {
state.traceEndpoint = options.pagePath; state.jobLogEndpoint = options.pagePath;
state.traceState = options.logState; state.jobLogState = options.logState;
}, },
[types.HIDE_SIDEBAR](state) { [types.HIDE_SIDEBAR](state) {
...@@ -20,11 +20,11 @@ export default { ...@@ -20,11 +20,11 @@ export default {
state.isSidebarOpen = true; state.isSidebarOpen = true;
}, },
[types.RECEIVE_TRACE_SUCCESS](state, log = {}) { [types.RECEIVE_JOB_LOG_SUCCESS](state, log = {}) {
const infinitelyCollapsibleSectionsFlag = const infinitelyCollapsibleSectionsFlag =
gon.features?.[INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF]; gon.features?.[INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF];
if (log.state) { if (log.state) {
state.traceState = log.state; state.jobLogState = log.state;
} }
if (log.append) { if (log.append) {
...@@ -32,52 +32,52 @@ export default { ...@@ -32,52 +32,52 @@ export default {
if (log.lines) { if (log.lines) {
const parsedResult = logLinesParser( const parsedResult = logLinesParser(
log.lines, log.lines,
state.auxiliaryPartialTraceHelpers, state.auxiliaryPartialJobLogHelpers,
state.trace, state.jobLog,
); );
state.trace = parsedResult.parsedLines; state.jobLog = parsedResult.parsedLines;
state.auxiliaryPartialTraceHelpers = parsedResult.auxiliaryPartialTraceHelpers; state.auxiliaryPartialJobLogHelpers = parsedResult.auxiliaryPartialJobLogHelpers;
} }
} else { } else {
state.trace = log.lines ? updateIncrementalTrace(log.lines, state.trace) : state.trace; state.jobLog = log.lines ? updateIncrementalJobLog(log.lines, state.jobLog) : state.jobLog;
} }
state.traceSize += log.size; state.jobLogSize += log.size;
} else { } else {
// When the job still does not have a trace // When the job still does not have a log
// the trace response will not have a defined // the job log response will not have a defined
// html or size. We keep the old value otherwise these // html or size. We keep the old value otherwise these
// will be set to `null` // will be set to `null`
if (infinitelyCollapsibleSectionsFlag) { if (infinitelyCollapsibleSectionsFlag) {
const parsedResult = logLinesParser(log.lines); const parsedResult = logLinesParser(log.lines);
state.trace = parsedResult.parsedLines; state.jobLog = parsedResult.parsedLines;
state.auxiliaryPartialTraceHelpers = parsedResult.auxiliaryPartialTraceHelpers; state.auxiliaryPartialJobLogHelpers = parsedResult.auxiliaryPartialJobLogHelpers;
} else { } else {
state.trace = log.lines ? logLinesParserLegacy(log.lines) : state.trace; state.jobLog = log.lines ? logLinesParserLegacy(log.lines) : state.jobLog;
} }
state.traceSize = log.size || state.traceSize; state.jobLogSize = log.size || state.jobLogSize;
} }
if (state.traceSize < log.total) { if (state.jobLogSize < log.total) {
state.isTraceSizeVisible = true; state.isJobLogSizeVisible = true;
} else { } else {
state.isTraceSizeVisible = false; state.isJobLogSizeVisible = false;
} }
state.isTraceComplete = log.complete || state.isTraceComplete; state.isJobLogComplete = log.complete || state.isJobLogComplete;
}, },
[types.SET_TRACE_TIMEOUT](state, id) { [types.SET_JOB_LOG_TIMEOUT](state, id) {
state.traceTimeout = id; state.jobLogTimeout = id;
}, },
/** /**
* Will remove loading animation * Will remove loading animation
*/ */
[types.STOP_POLLING_TRACE](state) { [types.STOP_POLLING_JOB_LOG](state) {
state.isTraceComplete = true; state.isJobLogComplete = true;
}, },
/** /**
...@@ -137,8 +137,8 @@ export default { ...@@ -137,8 +137,8 @@ export default {
state.isScrollingDown = toggle; state.isScrollingDown = toggle;
}, },
[types.TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_TRACE](state, toggle) { [types.TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_JOB_LOG](state, toggle) {
state.isScrolledToBottomBeforeReceivingTrace = toggle; state.isScrolledToBottomBeforeReceivingJobLog = toggle;
}, },
[types.REQUEST_JOBS_FOR_STAGE](state, stage = {}) { [types.REQUEST_JOBS_FOR_STAGE](state, stage = {}) {
......
export default () => ({ export default () => ({
jobEndpoint: null, jobEndpoint: null,
traceEndpoint: null, jobLogEndpoint: null,
// sidebar // sidebar
isSidebarOpen: true, isSidebarOpen: true,
...@@ -14,16 +14,16 @@ export default () => ({ ...@@ -14,16 +14,16 @@ export default () => ({
isScrollTopDisabled: true, isScrollTopDisabled: true,
// Used to check if we should keep the automatic scroll // Used to check if we should keep the automatic scroll
isScrolledToBottomBeforeReceivingTrace: true, isScrolledToBottomBeforeReceivingJobLog: true,
trace: [], jobLog: [],
isTraceComplete: false, isJobLogComplete: false,
traceSize: 0, jobLogSize: 0,
isTraceSizeVisible: false, isJobLogSizeVisible: false,
traceTimeout: 0, jobLogTimeout: 0,
// used as a query parameter to fetch the trace // used as a query parameter to fetch the job log
traceState: null, jobLogState: null,
// sidebar dropdown & list of jobs // sidebar dropdown & list of jobs
isLoadingJobs: false, isLoadingJobs: false,
...@@ -32,5 +32,5 @@ export default () => ({ ...@@ -32,5 +32,5 @@ export default () => ({
jobs: [], jobs: [],
// to parse partial logs // to parse partial logs
auxiliaryPartialTraceHelpers: {}, auxiliaryPartialJobLogHelpers: {},
}); });
...@@ -131,17 +131,17 @@ export const logLinesParserLegacy = (lines = [], accumulator = []) => ...@@ -131,17 +131,17 @@ export const logLinesParserLegacy = (lines = [], accumulator = []) =>
[...accumulator], [...accumulator],
); );
export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLines = []) => { export const logLinesParser = (lines = [], previousJobLogState = {}, prevParsedLines = []) => {
let currentLineCount = previousTraceState?.prevLineCount ?? 0; let currentLineCount = previousJobLogState?.prevLineCount ?? 0;
let currentHeader = previousTraceState?.currentHeader; let currentHeader = previousJobLogState?.currentHeader;
let isPreviousLineHeader = previousTraceState?.isPreviousLineHeader ?? false; let isPreviousLineHeader = previousJobLogState?.isPreviousLineHeader ?? false;
const parsedLines = prevParsedLines.length > 0 ? prevParsedLines : []; const parsedLines = prevParsedLines.length > 0 ? prevParsedLines : [];
const sectionsQueue = previousTraceState?.sectionsQueue ?? []; const sectionsQueue = previousJobLogState?.sectionsQueue ?? [];
for (let i = 0; i < lines.length; i += 1) { for (let i = 0; i < lines.length; i += 1) {
const line = lines[i]; const line = lines[i];
// First run we can use the current index, later runs we have to retrieve the last number of lines // First run we can use the current index, later runs we have to retrieve the last number of lines
currentLineCount = previousTraceState?.prevLineCount ? currentLineCount + 1 : i + 1; currentLineCount = previousJobLogState?.prevLineCount ? currentLineCount + 1 : i + 1;
if (line.section_header && !isPreviousLineHeader) { if (line.section_header && !isPreviousLineHeader) {
// If there's no previous line header that means we're at the root of the log // If there's no previous line header that means we're at the root of the log
...@@ -198,7 +198,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi ...@@ -198,7 +198,7 @@ export const logLinesParser = (lines = [], previousTraceState = {}, prevParsedLi
return { return {
parsedLines, parsedLines,
auxiliaryPartialTraceHelpers: { auxiliaryPartialJobLogHelpers: {
isPreviousLineHeader, isPreviousLineHeader,
currentHeader, currentHeader,
sectionsQueue, sectionsQueue,
...@@ -241,7 +241,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => { ...@@ -241,7 +241,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
}; };
/** /**
* When the trace is not complete, backend may send the last received line * When the job log is not complete, backend may send the last received line
* in the new response. * in the new response.
* *
* We need to check if that is the case by looking for the offset property * We need to check if that is the case by looking for the offset property
...@@ -250,7 +250,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => { ...@@ -250,7 +250,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
* @param array oldLog * @param array oldLog
* @param array newLog * @param array newLog
*/ */
export const updateIncrementalTrace = (newLog = [], oldParsed = []) => { export const updateIncrementalJobLog = (newLog = [], oldParsed = []) => {
const parsedLog = findOffsetAndRemove(newLog, oldParsed); const parsedLog = findOffsetAndRemove(newLog, oldParsed);
return logLinesParserLegacy(newLog, parsedLog); return logLinesParserLegacy(newLog, parsedLog);
......
...@@ -31,7 +31,7 @@ export default () => ({ ...@@ -31,7 +31,7 @@ export default () => ({
}, },
/** /**
* Logs including trace * Jobs with logs
*/ */
logs: { logs: {
lines: [], lines: [],
......
...@@ -47,9 +47,9 @@ describe('Job App', () => { ...@@ -47,9 +47,9 @@ describe('Job App', () => {
wrapper = mount(JobApp, { propsData: { ...props }, store }); wrapper = mount(JobApp, { propsData: { ...props }, store });
}; };
const setupAndMount = ({ jobData = {}, traceData = {} } = {}) => { const setupAndMount = ({ jobData = {}, jobLogData = {} } = {}) => {
mock.onGet(initSettings.endpoint).replyOnce(200, { ...job, ...jobData }); mock.onGet(initSettings.endpoint).replyOnce(200, { ...job, ...jobData });
mock.onGet(`${initSettings.pagePath}/trace.json`).reply(200, traceData); mock.onGet(`${initSettings.pagePath}/trace.json`).reply(200, jobLogData);
const asyncInit = store.dispatch('init', initSettings); const asyncInit = store.dispatch('init', initSettings);
...@@ -77,11 +77,10 @@ describe('Job App', () => { ...@@ -77,11 +77,10 @@ describe('Job App', () => {
const findEmptyState = () => wrapper.find(EmptyState); const findEmptyState = () => wrapper.find(EmptyState);
const findJobNewIssueLink = () => wrapper.find('[data-testid="job-new-issue"]'); const findJobNewIssueLink = () => wrapper.find('[data-testid="job-new-issue"]');
const findJobEmptyStateTitle = () => wrapper.find('[data-testid="job-empty-state-title"]'); const findJobEmptyStateTitle = () => wrapper.find('[data-testid="job-empty-state-title"]');
const findJobTraceScrollTop = () => wrapper.find('[data-testid="job-controller-scroll-top"]'); const findJobLogScrollTop = () => wrapper.find('[data-testid="job-controller-scroll-top"]');
const findJobTraceScrollBottom = () => const findJobLogScrollBottom = () => wrapper.find('[data-testid="job-controller-scroll-bottom"]');
wrapper.find('[data-testid="job-controller-scroll-bottom"]'); const findJobLogController = () => wrapper.find('[data-testid="job-raw-link-controller"]');
const findJobTraceController = () => wrapper.find('[data-testid="job-raw-link-controller"]'); const findJobLogEraseLink = () => wrapper.find('[data-testid="job-log-erase-link"]');
const findJobTraceEraseLink = () => wrapper.find('[data-testid="job-log-erase-link"]');
beforeEach(() => { beforeEach(() => {
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
...@@ -315,7 +314,7 @@ describe('Job App', () => { ...@@ -315,7 +314,7 @@ describe('Job App', () => {
}); });
describe('empty states block', () => { describe('empty states block', () => {
it('renders empty state when job does not have trace and is not running', () => it('renders empty state when job does not have log and is not running', () =>
setupAndMount({ setupAndMount({
jobData: { jobData: {
has_trace: false, has_trace: false,
...@@ -342,7 +341,7 @@ describe('Job App', () => { ...@@ -342,7 +341,7 @@ describe('Job App', () => {
expect(findEmptyState().exists()).toBe(true); expect(findEmptyState().exists()).toBe(true);
})); }));
it('does not render empty state when job does not have trace but it is running', () => it('does not render empty state when job does not have log but it is running', () =>
setupAndMount({ setupAndMount({
jobData: { jobData: {
has_trace: false, has_trace: false,
...@@ -358,7 +357,7 @@ describe('Job App', () => { ...@@ -358,7 +357,7 @@ describe('Job App', () => {
expect(findEmptyState().exists()).toBe(false); expect(findEmptyState().exists()).toBe(false);
})); }));
it('does not render empty state when job has trace but it is not running', () => it('does not render empty state when job has log but it is not running', () =>
setupAndMount({ jobData: { has_trace: true } }).then(() => { setupAndMount({ jobData: { has_trace: true } }).then(() => {
expect(findEmptyState().exists()).toBe(false); expect(findEmptyState().exists()).toBe(false);
})); }));
...@@ -424,10 +423,10 @@ describe('Job App', () => { ...@@ -424,10 +423,10 @@ describe('Job App', () => {
}); });
}); });
describe('trace controls', () => { describe('job log controls', () => {
beforeEach(() => beforeEach(() =>
setupAndMount({ setupAndMount({
traceData: { jobLogData: {
html: '<span>Update</span>', html: '<span>Update</span>',
status: 'success', status: 'success',
append: false, append: false,
...@@ -439,16 +438,16 @@ describe('Job App', () => { ...@@ -439,16 +438,16 @@ describe('Job App', () => {
); );
it('should render scroll buttons', () => { it('should render scroll buttons', () => {
expect(findJobTraceScrollTop().exists()).toBe(true); expect(findJobLogScrollTop().exists()).toBe(true);
expect(findJobTraceScrollBottom().exists()).toBe(true); expect(findJobLogScrollBottom().exists()).toBe(true);
}); });
it('should render link to raw ouput', () => { it('should render link to raw ouput', () => {
expect(findJobTraceController().exists()).toBe(true); expect(findJobLogController().exists()).toBe(true);
}); });
it('should render link to erase job', () => { it('should render link to erase job', () => {
expect(findJobTraceEraseLink().exists()).toBe(true); expect(findJobLogEraseLink().exists()).toBe(true);
}); });
}); });
}); });
...@@ -18,7 +18,7 @@ describe('Job log controllers', () => { ...@@ -18,7 +18,7 @@ describe('Job log controllers', () => {
isScrollTopDisabled: false, isScrollTopDisabled: false,
isScrollBottomDisabled: false, isScrollBottomDisabled: false,
isScrollingDown: true, isScrollingDown: true,
isTraceSizeVisible: true, isJobLogSizeVisible: true,
}; };
const createWrapper = (props) => { const createWrapper = (props) => {
...@@ -38,7 +38,7 @@ describe('Job log controllers', () => { ...@@ -38,7 +38,7 @@ describe('Job log controllers', () => {
const findScrollBottom = () => wrapper.find('[data-testid="job-controller-scroll-bottom"]'); const findScrollBottom = () => wrapper.find('[data-testid="job-controller-scroll-bottom"]');
describe('Truncate information', () => { describe('Truncate information', () => {
describe('with isTraceSizeVisible', () => { describe('with isJobLogSizeVisible', () => {
beforeEach(() => { beforeEach(() => {
createWrapper(); createWrapper();
}); });
...@@ -47,31 +47,31 @@ describe('Job log controllers', () => { ...@@ -47,31 +47,31 @@ describe('Job log controllers', () => {
expect(findTruncatedInfo().text()).toMatch('499.95 KiB'); expect(findTruncatedInfo().text()).toMatch('499.95 KiB');
}); });
it('renders link to raw trace', () => { it('renders link to raw job log', () => {
expect(findRawLink().attributes('href')).toBe(defaultProps.rawPath); expect(findRawLink().attributes('href')).toBe(defaultProps.rawPath);
}); });
}); });
}); });
describe('links section', () => { describe('links section', () => {
describe('with raw trace path', () => { describe('with raw job log path', () => {
beforeEach(() => { beforeEach(() => {
createWrapper(); createWrapper();
}); });
it('renders raw trace link', () => { it('renders raw job log link', () => {
expect(findRawLinkController().attributes('href')).toBe(defaultProps.rawPath); expect(findRawLinkController().attributes('href')).toBe(defaultProps.rawPath);
}); });
}); });
describe('without raw trace path', () => { describe('without raw job log path', () => {
beforeEach(() => { beforeEach(() => {
createWrapper({ createWrapper({
rawPath: null, rawPath: null,
}); });
}); });
it('does not render raw trace link', () => { it('does not render raw job log link', () => {
expect(findRawLinkController().exists()).toBe(false); expect(findRawLinkController().exists()).toBe(false);
}); });
}); });
......
...@@ -6,7 +6,7 @@ describe('Job Log Collapsible Section', () => { ...@@ -6,7 +6,7 @@ describe('Job Log Collapsible Section', () => {
let wrapper; let wrapper;
let origGon; let origGon;
const traceEndpoint = 'jobs/335'; const jobLogEndpoint = 'jobs/335';
const findCollapsibleLine = () => wrapper.find('.collapsible-line'); const findCollapsibleLine = () => wrapper.find('.collapsible-line');
const findCollapsibleLineSvg = () => wrapper.find('.collapsible-line svg'); const findCollapsibleLineSvg = () => wrapper.find('.collapsible-line svg');
...@@ -35,7 +35,7 @@ describe('Job Log Collapsible Section', () => { ...@@ -35,7 +35,7 @@ describe('Job Log Collapsible Section', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
section: collapsibleSectionClosed, section: collapsibleSectionClosed,
traceEndpoint, jobLogEndpoint,
}); });
}); });
...@@ -52,7 +52,7 @@ describe('Job Log Collapsible Section', () => { ...@@ -52,7 +52,7 @@ describe('Job Log Collapsible Section', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
section: collapsibleSectionOpened, section: collapsibleSectionOpened,
traceEndpoint, jobLogEndpoint,
}); });
}); });
...@@ -72,7 +72,7 @@ describe('Job Log Collapsible Section', () => { ...@@ -72,7 +72,7 @@ describe('Job Log Collapsible Section', () => {
it('emits onClickCollapsibleLine on click', () => { it('emits onClickCollapsibleLine on click', () => {
createComponent({ createComponent({
section: collapsibleSectionOpened, section: collapsibleSectionOpened,
traceEndpoint, jobLogEndpoint,
}); });
findCollapsibleLine().trigger('click'); findCollapsibleLine().trigger('click');
......
...@@ -31,8 +31,8 @@ describe('Job Log', () => { ...@@ -31,8 +31,8 @@ describe('Job Log', () => {
window.gon = { features: { infinitelyCollapsibleSections: false } }; window.gon = { features: { infinitelyCollapsibleSections: false } };
state = { state = {
trace: logLinesParserLegacy(jobLog), jobLog: logLinesParserLegacy(jobLog),
traceEndpoint: 'jobs/id', jobLogEndpoint: 'jobs/id',
}; };
store = new Vuex.Store({ store = new Vuex.Store({
...@@ -59,7 +59,7 @@ describe('Job Log', () => { ...@@ -59,7 +59,7 @@ describe('Job Log', () => {
}); });
it('links to the provided path and correct line number', () => { it('links to the provided path and correct line number', () => {
expect(wrapper.find('#L1').attributes('href')).toBe(`${state.traceEndpoint}#L1`); expect(wrapper.find('#L1').attributes('href')).toBe(`${state.jobLogEndpoint}#L1`);
}); });
}); });
...@@ -111,8 +111,8 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => { ...@@ -111,8 +111,8 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => {
window.gon = { features: { infinitelyCollapsibleSections: true } }; window.gon = { features: { infinitelyCollapsibleSections: true } };
state = { state = {
trace: logLinesParser(jobLog).parsedLines, jobLog: logLinesParser(jobLog).parsedLines,
traceEndpoint: 'jobs/id', jobLogEndpoint: 'jobs/id',
}; };
store = new Vuex.Store({ store = new Vuex.Store({
...@@ -139,7 +139,7 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => { ...@@ -139,7 +139,7 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => {
}); });
it('links to the provided path and correct line number', () => { it('links to the provided path and correct line number', () => {
expect(wrapper.find('#L1').attributes('href')).toBe(`${state.traceEndpoint}#L1`); expect(wrapper.find('#L1').attributes('href')).toBe(`${state.jobLogEndpoint}#L1`);
}); });
}); });
......
...@@ -3,7 +3,7 @@ import { TEST_HOST } from 'helpers/test_constants'; ...@@ -3,7 +3,7 @@ import { TEST_HOST } from 'helpers/test_constants';
import testAction from 'helpers/vuex_action_helper'; import testAction from 'helpers/vuex_action_helper';
import { import {
setJobEndpoint, setJobEndpoint,
setTraceOptions, setJobLogOptions,
clearEtagPoll, clearEtagPoll,
stopPolling, stopPolling,
requestJob, requestJob,
...@@ -12,12 +12,12 @@ import { ...@@ -12,12 +12,12 @@ import {
receiveJobError, receiveJobError,
scrollTop, scrollTop,
scrollBottom, scrollBottom,
requestTrace, requestJobLog,
fetchTrace, fetchJobLog,
startPollingTrace, startPollingJobLog,
stopPollingTrace, stopPollingJobLog,
receiveTraceSuccess, receiveJobLogSuccess,
receiveTraceError, receiveJobLogError,
toggleCollapsibleLine, toggleCollapsibleLine,
requestJobsForStage, requestJobsForStage,
fetchJobsForStage, fetchJobsForStage,
...@@ -51,13 +51,13 @@ describe('Job State actions', () => { ...@@ -51,13 +51,13 @@ describe('Job State actions', () => {
}); });
}); });
describe('setTraceOptions', () => { describe('setJobLogOptions', () => {
it('should commit SET_TRACE_OPTIONS mutation', (done) => { it('should commit SET_JOB_LOG_OPTIONS mutation', (done) => {
testAction( testAction(
setTraceOptions, setJobLogOptions,
{ pagePath: 'job/872324/trace.json' }, { pagePath: 'job/872324/trace.json' },
mockedState, mockedState,
[{ type: types.SET_TRACE_OPTIONS, payload: { pagePath: 'job/872324/trace.json' } }], [{ type: types.SET_JOB_LOG_OPTIONS, payload: { pagePath: 'job/872324/trace.json' } }],
[], [],
done, done,
); );
...@@ -191,17 +191,17 @@ describe('Job State actions', () => { ...@@ -191,17 +191,17 @@ describe('Job State actions', () => {
}); });
}); });
describe('requestTrace', () => { describe('requestJobLog', () => {
it('should commit REQUEST_TRACE mutation', (done) => { it('should commit REQUEST_JOB_LOG mutation', (done) => {
testAction(requestTrace, null, mockedState, [{ type: types.REQUEST_TRACE }], [], done); testAction(requestJobLog, null, mockedState, [{ type: types.REQUEST_JOB_LOG }], [], done);
}); });
}); });
describe('fetchTrace', () => { describe('fetchJobLog', () => {
let mock; let mock;
beforeEach(() => { beforeEach(() => {
mockedState.traceEndpoint = `${TEST_HOST}/endpoint`; mockedState.jobLogEndpoint = `${TEST_HOST}/endpoint`;
mock = new MockAdapter(axios); mock = new MockAdapter(axios);
}); });
...@@ -212,14 +212,14 @@ describe('Job State actions', () => { ...@@ -212,14 +212,14 @@ describe('Job State actions', () => {
}); });
describe('success', () => { describe('success', () => {
it('dispatches requestTrace, receiveTraceSuccess and stopPollingTrace when job is complete', (done) => { it('dispatches requestJobLog, receiveJobLogSuccess and stopPollingJobLog when job is complete', (done) => {
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, { mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, {
html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :', html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :',
complete: true, complete: true,
}); });
testAction( testAction(
fetchTrace, fetchJobLog,
null, null,
mockedState, mockedState,
[], [],
...@@ -233,10 +233,10 @@ describe('Job State actions', () => { ...@@ -233,10 +233,10 @@ describe('Job State actions', () => {
html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :', html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :',
complete: true, complete: true,
}, },
type: 'receiveTraceSuccess', type: 'receiveJobLogSuccess',
}, },
{ {
type: 'stopPollingTrace', type: 'stopPollingJobLog',
}, },
], ],
done, done,
...@@ -244,43 +244,43 @@ describe('Job State actions', () => { ...@@ -244,43 +244,43 @@ describe('Job State actions', () => {
}); });
describe('when job is incomplete', () => { describe('when job is incomplete', () => {
let tracePayload; let jobLogPayload;
beforeEach(() => { beforeEach(() => {
tracePayload = { jobLogPayload = {
html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :', html: 'I, [2018-08-17T22:57:45.707325 #1841] INFO -- :',
complete: false, complete: false,
}; };
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, tracePayload); mock.onGet(`${TEST_HOST}/endpoint/trace.json`).replyOnce(200, jobLogPayload);
}); });
it('dispatches startPollingTrace', (done) => { it('dispatches startPollingJobLog', (done) => {
testAction( testAction(
fetchTrace, fetchJobLog,
null, null,
mockedState, mockedState,
[], [],
[ [
{ type: 'toggleScrollisInBottom', payload: true }, { type: 'toggleScrollisInBottom', payload: true },
{ type: 'receiveTraceSuccess', payload: tracePayload }, { type: 'receiveJobLogSuccess', payload: jobLogPayload },
{ type: 'startPollingTrace' }, { type: 'startPollingJobLog' },
], ],
done, done,
); );
}); });
it('does not dispatch startPollingTrace when timeout is non-empty', (done) => { it('does not dispatch startPollingJobLog when timeout is non-empty', (done) => {
mockedState.traceTimeout = 1; mockedState.jobLogTimeout = 1;
testAction( testAction(
fetchTrace, fetchJobLog,
null, null,
mockedState, mockedState,
[], [],
[ [
{ type: 'toggleScrollisInBottom', payload: true }, { type: 'toggleScrollisInBottom', payload: true },
{ type: 'receiveTraceSuccess', payload: tracePayload }, { type: 'receiveJobLogSuccess', payload: jobLogPayload },
], ],
done, done,
); );
...@@ -293,15 +293,15 @@ describe('Job State actions', () => { ...@@ -293,15 +293,15 @@ describe('Job State actions', () => {
mock.onGet(`${TEST_HOST}/endpoint/trace.json`).reply(500); mock.onGet(`${TEST_HOST}/endpoint/trace.json`).reply(500);
}); });
it('dispatches requestTrace and receiveTraceError ', (done) => { it('dispatches requestJobLog and receiveJobLogError ', (done) => {
testAction( testAction(
fetchTrace, fetchJobLog,
null, null,
mockedState, mockedState,
[], [],
[ [
{ {
type: 'receiveTraceError', type: 'receiveJobLogError',
}, },
], ],
done, done,
...@@ -310,7 +310,7 @@ describe('Job State actions', () => { ...@@ -310,7 +310,7 @@ describe('Job State actions', () => {
}); });
}); });
describe('startPollingTrace', () => { describe('startPollingJobLog', () => {
let dispatch; let dispatch;
let commit; let commit;
...@@ -318,18 +318,18 @@ describe('Job State actions', () => { ...@@ -318,18 +318,18 @@ describe('Job State actions', () => {
dispatch = jest.fn(); dispatch = jest.fn();
commit = jest.fn(); commit = jest.fn();
startPollingTrace({ dispatch, commit }); startPollingJobLog({ dispatch, commit });
}); });
afterEach(() => { afterEach(() => {
jest.clearAllTimers(); jest.clearAllTimers();
}); });
it('should save the timeout id but not call fetchTrace', () => { it('should save the timeout id but not call fetchJobLog', () => {
expect(commit).toHaveBeenCalledWith(types.SET_TRACE_TIMEOUT, expect.any(Number)); expect(commit).toHaveBeenCalledWith(types.SET_JOB_LOG_TIMEOUT, expect.any(Number));
expect(commit.mock.calls[0][1]).toBeGreaterThan(0); expect(commit.mock.calls[0][1]).toBeGreaterThan(0);
expect(dispatch).not.toHaveBeenCalledWith('fetchTrace'); expect(dispatch).not.toHaveBeenCalledWith('fetchJobLog');
}); });
describe('after timeout has passed', () => { describe('after timeout has passed', () => {
...@@ -337,14 +337,14 @@ describe('Job State actions', () => { ...@@ -337,14 +337,14 @@ describe('Job State actions', () => {
jest.advanceTimersByTime(4000); jest.advanceTimersByTime(4000);
}); });
it('should clear the timeout id and fetchTrace', () => { it('should clear the timeout id and fetchJobLog', () => {
expect(commit).toHaveBeenCalledWith(types.SET_TRACE_TIMEOUT, 0); expect(commit).toHaveBeenCalledWith(types.SET_JOB_LOG_TIMEOUT, 0);
expect(dispatch).toHaveBeenCalledWith('fetchTrace'); expect(dispatch).toHaveBeenCalledWith('fetchJobLog');
}); });
}); });
}); });
describe('stopPollingTrace', () => { describe('stopPollingJobLog', () => {
let origTimeout; let origTimeout;
beforeEach(() => { beforeEach(() => {
...@@ -358,40 +358,40 @@ describe('Job State actions', () => { ...@@ -358,40 +358,40 @@ describe('Job State actions', () => {
window.clearTimeout = origTimeout; window.clearTimeout = origTimeout;
}); });
it('should commit STOP_POLLING_TRACE mutation ', (done) => { it('should commit STOP_POLLING_JOB_LOG mutation ', (done) => {
const traceTimeout = 7; const jobLogTimeout = 7;
testAction( testAction(
stopPollingTrace, stopPollingJobLog,
null, null,
{ ...mockedState, traceTimeout }, { ...mockedState, jobLogTimeout },
[{ type: types.SET_TRACE_TIMEOUT, payload: 0 }, { type: types.STOP_POLLING_TRACE }], [{ type: types.SET_JOB_LOG_TIMEOUT, payload: 0 }, { type: types.STOP_POLLING_JOB_LOG }],
[], [],
) )
.then(() => { .then(() => {
expect(window.clearTimeout).toHaveBeenCalledWith(traceTimeout); expect(window.clearTimeout).toHaveBeenCalledWith(jobLogTimeout);
}) })
.then(done) .then(done)
.catch(done.fail); .catch(done.fail);
}); });
}); });
describe('receiveTraceSuccess', () => { describe('receiveJobLogSuccess', () => {
it('should commit RECEIVE_TRACE_SUCCESS mutation ', (done) => { it('should commit RECEIVE_JOB_LOG_SUCCESS mutation ', (done) => {
testAction( testAction(
receiveTraceSuccess, receiveJobLogSuccess,
'hello world', 'hello world',
mockedState, mockedState,
[{ type: types.RECEIVE_TRACE_SUCCESS, payload: 'hello world' }], [{ type: types.RECEIVE_JOB_LOG_SUCCESS, payload: 'hello world' }],
[], [],
done, done,
); );
}); });
}); });
describe('receiveTraceError', () => { describe('receiveJobLogError', () => {
it('should commit stop polling trace', (done) => { it('should commit stop polling job log', (done) => {
testAction(receiveTraceError, null, mockedState, [], [{ type: 'stopPollingTrace' }], done); testAction(receiveJobLogError, null, mockedState, [], [{ type: 'stopPollingJobLog' }], done);
}); });
}); });
......
...@@ -102,13 +102,13 @@ describe('Job Store Getters', () => { ...@@ -102,13 +102,13 @@ describe('Job Store Getters', () => {
}); });
}); });
describe('hasTrace', () => { describe('hasJobLog', () => {
describe('when has_trace is true', () => { describe('when has_trace is true', () => {
it('returns true', () => { it('returns true', () => {
localState.job.has_trace = true; localState.job.has_trace = true;
localState.job.status = {}; localState.job.status = {};
expect(getters.hasTrace(localState)).toEqual(true); expect(getters.hasJobLog(localState)).toEqual(true);
}); });
}); });
...@@ -117,7 +117,7 @@ describe('Job Store Getters', () => { ...@@ -117,7 +117,7 @@ describe('Job Store Getters', () => {
localState.job.has_trace = false; localState.job.has_trace = false;
localState.job.status = { group: 'running' }; localState.job.status = { group: 'running' };
expect(getters.hasTrace(localState)).toEqual(true); expect(getters.hasJobLog(localState)).toEqual(true);
}); });
}); });
...@@ -126,7 +126,7 @@ describe('Job Store Getters', () => { ...@@ -126,7 +126,7 @@ describe('Job Store Getters', () => {
localState.job.has_trace = false; localState.job.has_trace = false;
localState.job.status = { group: 'pending' }; localState.job.status = { group: 'pending' };
expect(getters.hasTrace(localState)).toEqual(false); expect(getters.hasJobLog(localState)).toEqual(false);
}); });
}); });
}); });
......
...@@ -45,39 +45,39 @@ describe('Jobs Store Mutations', () => { ...@@ -45,39 +45,39 @@ describe('Jobs Store Mutations', () => {
}); });
}); });
describe('RECEIVE_TRACE_SUCCESS', () => { describe('RECEIVE_JOB_LOG_SUCCESS', () => {
describe('when trace has state', () => { describe('when job log has state', () => {
it('sets traceState', () => { it('sets jobLogState', () => {
const stateLog = const stateLog =
'eyJvZmZzZXQiOjczNDQ1MSwibl9vcGVuX3RhZ3MiOjAsImZnX2NvbG9yIjpudWxsLCJiZ19jb2xvciI6bnVsbCwic3R5bGVfbWFzayI6MH0='; 'eyJvZmZzZXQiOjczNDQ1MSwibl9vcGVuX3RhZ3MiOjAsImZnX2NvbG9yIjpudWxsLCJiZ19jb2xvciI6bnVsbCwic3R5bGVfbWFzayI6MH0=';
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
state: stateLog, state: stateLog,
}); });
expect(stateCopy.traceState).toEqual(stateLog); expect(stateCopy.jobLogState).toEqual(stateLog);
}); });
}); });
describe('when traceSize is smaller than the total size', () => { describe('when jobLogSize is smaller than the total size', () => {
it('sets isTraceSizeVisible to true', () => { it('sets isJobLogSizeVisible to true', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { total: 51184600, size: 1231 }); mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, { total: 51184600, size: 1231 });
expect(stateCopy.isTraceSizeVisible).toEqual(true); expect(stateCopy.isJobLogSizeVisible).toEqual(true);
}); });
}); });
describe('when traceSize is bigger than the total size', () => { describe('when jobLogSize is bigger than the total size', () => {
it('sets isTraceSizeVisible to false', () => { it('sets isJobLogSizeVisible to false', () => {
const copy = { ...stateCopy, traceSize: 5118460, size: 2321312 }; const copy = { ...stateCopy, jobLogSize: 5118460, size: 2321312 };
mutations[types.RECEIVE_TRACE_SUCCESS](copy, { total: 511846 }); mutations[types.RECEIVE_JOB_LOG_SUCCESS](copy, { total: 511846 });
expect(copy.isTraceSizeVisible).toEqual(false); expect(copy.isJobLogSizeVisible).toEqual(false);
}); });
}); });
it('sets trace, trace size and isTraceComplete', () => { it('sets job log size and isJobLogComplete', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: true, append: true,
html, html,
size: 511846, size: 511846,
...@@ -85,15 +85,15 @@ describe('Jobs Store Mutations', () => { ...@@ -85,15 +85,15 @@ describe('Jobs Store Mutations', () => {
lines: [], lines: [],
}); });
expect(stateCopy.traceSize).toEqual(511846); expect(stateCopy.jobLogSize).toEqual(511846);
expect(stateCopy.isTraceComplete).toEqual(true); expect(stateCopy.isJobLogComplete).toEqual(true);
}); });
describe('with new job log', () => { describe('with new job log', () => {
describe('log.lines', () => { describe('log.lines', () => {
describe('when append is true', () => { describe('when append is true', () => {
it('sets the parsed log ', () => { it('sets the parsed log ', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: true, append: true,
size: 511846, size: 511846,
complete: true, complete: true,
...@@ -105,7 +105,7 @@ describe('Jobs Store Mutations', () => { ...@@ -105,7 +105,7 @@ describe('Jobs Store Mutations', () => {
], ],
}); });
expect(stateCopy.trace).toEqual([ expect(stateCopy.jobLog).toEqual([
{ {
offset: 1, offset: 1,
content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }], content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }],
...@@ -117,7 +117,7 @@ describe('Jobs Store Mutations', () => { ...@@ -117,7 +117,7 @@ describe('Jobs Store Mutations', () => {
describe('when it is defined', () => { describe('when it is defined', () => {
it('sets the parsed log ', () => { it('sets the parsed log ', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: false, append: false,
size: 511846, size: 511846,
complete: true, complete: true,
...@@ -126,7 +126,7 @@ describe('Jobs Store Mutations', () => { ...@@ -126,7 +126,7 @@ describe('Jobs Store Mutations', () => {
], ],
}); });
expect(stateCopy.trace).toEqual([ expect(stateCopy.jobLog).toEqual([
{ {
offset: 0, offset: 0,
content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }], content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }],
...@@ -138,7 +138,7 @@ describe('Jobs Store Mutations', () => { ...@@ -138,7 +138,7 @@ describe('Jobs Store Mutations', () => {
describe('when it is null', () => { describe('when it is null', () => {
it('sets the default value', () => { it('sets the default value', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: true, append: true,
html, html,
size: 511846, size: 511846,
...@@ -146,30 +146,30 @@ describe('Jobs Store Mutations', () => { ...@@ -146,30 +146,30 @@ describe('Jobs Store Mutations', () => {
lines: null, lines: null,
}); });
expect(stateCopy.trace).toEqual([]); expect(stateCopy.jobLog).toEqual([]);
}); });
}); });
}); });
}); });
}); });
describe('SET_TRACE_TIMEOUT', () => { describe('SET_JOB_LOG_TIMEOUT', () => {
it('sets the traceTimeout id', () => { it('sets the jobLogTimeout id', () => {
const id = 7; const id = 7;
expect(stateCopy.traceTimeout).not.toEqual(id); expect(stateCopy.jobLogTimeout).not.toEqual(id);
mutations[types.SET_TRACE_TIMEOUT](stateCopy, id); mutations[types.SET_JOB_LOG_TIMEOUT](stateCopy, id);
expect(stateCopy.traceTimeout).toEqual(id); expect(stateCopy.jobLogTimeout).toEqual(id);
}); });
}); });
describe('STOP_POLLING_TRACE', () => { describe('STOP_POLLING_JOB_LOG', () => {
it('sets isTraceComplete to true', () => { it('sets isJobLogComplete to true', () => {
mutations[types.STOP_POLLING_TRACE](stateCopy); mutations[types.STOP_POLLING_JOB_LOG](stateCopy);
expect(stateCopy.isTraceComplete).toEqual(true); expect(stateCopy.isJobLogComplete).toEqual(true);
}); });
}); });
...@@ -296,12 +296,12 @@ describe('Job Store mutations, feature flag ON', () => { ...@@ -296,12 +296,12 @@ describe('Job Store mutations, feature flag ON', () => {
window.gon = origGon; window.gon = origGon;
}); });
describe('RECEIVE_TRACE_SUCCESS', () => { describe('RECEIVE_JOB_LOG_SUCCESS', () => {
describe('with new job log', () => { describe('with new job log', () => {
describe('log.lines', () => { describe('log.lines', () => {
describe('when append is true', () => { describe('when append is true', () => {
it('sets the parsed log ', () => { it('sets the parsed log ', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: true, append: true,
size: 511846, size: 511846,
complete: true, complete: true,
...@@ -313,7 +313,7 @@ describe('Job Store mutations, feature flag ON', () => { ...@@ -313,7 +313,7 @@ describe('Job Store mutations, feature flag ON', () => {
], ],
}); });
expect(stateCopy.trace).toEqual([ expect(stateCopy.jobLog).toEqual([
{ {
offset: 1, offset: 1,
content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }], content: [{ text: 'Running with gitlab-runner 11.12.1 (5a147c92)' }],
...@@ -325,7 +325,7 @@ describe('Job Store mutations, feature flag ON', () => { ...@@ -325,7 +325,7 @@ describe('Job Store mutations, feature flag ON', () => {
describe('when lines are defined', () => { describe('when lines are defined', () => {
it('sets the parsed log ', () => { it('sets the parsed log ', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: false, append: false,
size: 511846, size: 511846,
complete: true, complete: true,
...@@ -334,7 +334,7 @@ describe('Job Store mutations, feature flag ON', () => { ...@@ -334,7 +334,7 @@ describe('Job Store mutations, feature flag ON', () => {
], ],
}); });
expect(stateCopy.trace).toEqual([ expect(stateCopy.jobLog).toEqual([
{ {
offset: 0, offset: 0,
content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }], content: [{ text: 'Running with gitlab-runner 11.11.1 (5a147c92)' }],
...@@ -346,7 +346,7 @@ describe('Job Store mutations, feature flag ON', () => { ...@@ -346,7 +346,7 @@ describe('Job Store mutations, feature flag ON', () => {
describe('when lines are null', () => { describe('when lines are null', () => {
it('sets the default value', () => { it('sets the default value', () => {
mutations[types.RECEIVE_TRACE_SUCCESS](stateCopy, { mutations[types.RECEIVE_JOB_LOG_SUCCESS](stateCopy, {
append: true, append: true,
html, html,
size: 511846, size: 511846,
...@@ -354,7 +354,7 @@ describe('Job Store mutations, feature flag ON', () => { ...@@ -354,7 +354,7 @@ describe('Job Store mutations, feature flag ON', () => {
lines: null, lines: null,
}); });
expect(stateCopy.trace).toEqual([]); expect(stateCopy.jobLog).toEqual([]);
}); });
}); });
}); });
......
import { import {
logLinesParser, logLinesParser,
logLinesParserLegacy, logLinesParserLegacy,
updateIncrementalTrace, updateIncrementalJobLog,
parseHeaderLine, parseHeaderLine,
parseLine, parseLine,
addDurationToHeader, addDurationToHeader,
...@@ -487,11 +487,11 @@ describe('Jobs Store Utils', () => { ...@@ -487,11 +487,11 @@ describe('Jobs Store Utils', () => {
}); });
}); });
describe('updateIncrementalTrace', () => { describe('updateIncrementalJobLog', () => {
describe('without repeated section', () => { describe('without repeated section', () => {
it('concats and parses both arrays', () => { it('concats and parses both arrays', () => {
const oldLog = logLinesParserLegacy(originalTrace); const oldLog = logLinesParserLegacy(originalTrace);
const result = updateIncrementalTrace(regularIncremental, oldLog); const result = updateIncrementalJobLog(regularIncremental, oldLog);
expect(result).toEqual([ expect(result).toEqual([
{ {
...@@ -519,7 +519,7 @@ describe('Jobs Store Utils', () => { ...@@ -519,7 +519,7 @@ describe('Jobs Store Utils', () => {
describe('with regular line repeated offset', () => { describe('with regular line repeated offset', () => {
it('updates the last line and formats with the incremental part', () => { it('updates the last line and formats with the incremental part', () => {
const oldLog = logLinesParserLegacy(originalTrace); const oldLog = logLinesParserLegacy(originalTrace);
const result = updateIncrementalTrace(regularIncrementalRepeated, oldLog); const result = updateIncrementalJobLog(regularIncrementalRepeated, oldLog);
expect(result).toEqual([ expect(result).toEqual([
{ {
...@@ -538,7 +538,7 @@ describe('Jobs Store Utils', () => { ...@@ -538,7 +538,7 @@ describe('Jobs Store Utils', () => {
describe('with header line repeated', () => { describe('with header line repeated', () => {
it('updates the header line and formats with the incremental part', () => { it('updates the header line and formats with the incremental part', () => {
const oldLog = logLinesParserLegacy(headerTrace); const oldLog = logLinesParserLegacy(headerTrace);
const result = updateIncrementalTrace(headerTraceIncremental, oldLog); const result = updateIncrementalJobLog(headerTraceIncremental, oldLog);
expect(result).toEqual([ expect(result).toEqual([
{ {
...@@ -564,7 +564,7 @@ describe('Jobs Store Utils', () => { ...@@ -564,7 +564,7 @@ describe('Jobs Store Utils', () => {
describe('with collapsible line repeated', () => { describe('with collapsible line repeated', () => {
it('updates the collapsible line and formats with the incremental part', () => { it('updates the collapsible line and formats with the incremental part', () => {
const oldLog = logLinesParserLegacy(collapsibleTrace); const oldLog = logLinesParserLegacy(collapsibleTrace);
const result = updateIncrementalTrace(collapsibleTraceIncremental, oldLog); const result = updateIncrementalJobLog(collapsibleTraceIncremental, oldLog);
expect(result).toEqual([ expect(result).toEqual([
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment