Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
41d44191
Commit
41d44191
authored
Sep 15, 2021
by
pburdette
Committed by
Payton Burdette
Sep 17, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename job trace to job log
Rename job trace to job log to align with docs.
parent
b523ca57
Changes
18
Hide whitespace changes
Inline
Side-by-side
Showing
18 changed files
with
235 additions
and
229 deletions
+235
-229
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
...ssets/javascripts/ide/stores/modules/pipelines/actions.js
+1
-0
app/assets/javascripts/jobs/components/job_app.vue
app/assets/javascripts/jobs/components/job_app.vue
+14
-14
app/assets/javascripts/jobs/components/job_log_controllers.vue
...ssets/javascripts/jobs/components/job_log_controllers.vue
+2
-2
app/assets/javascripts/jobs/components/log/collapsible_section.vue
...s/javascripts/jobs/components/log/collapsible_section.vue
+5
-5
app/assets/javascripts/jobs/components/log/log.vue
app/assets/javascripts/jobs/components/log/log.vue
+9
-9
app/assets/javascripts/jobs/store/actions.js
app/assets/javascripts/jobs/store/actions.js
+33
-29
app/assets/javascripts/jobs/store/getters.js
app/assets/javascripts/jobs/store/getters.js
+4
-3
app/assets/javascripts/jobs/store/mutation_types.js
app/assets/javascripts/jobs/store/mutation_types.js
+7
-7
app/assets/javascripts/jobs/store/mutations.js
app/assets/javascripts/jobs/store/mutations.js
+28
-28
app/assets/javascripts/jobs/store/state.js
app/assets/javascripts/jobs/store/state.js
+10
-10
app/assets/javascripts/jobs/store/utils.js
app/assets/javascripts/jobs/store/utils.js
+9
-9
spec/frontend/jobs/components/job_log_controllers_spec.js
spec/frontend/jobs/components/job_log_controllers_spec.js
+2
-2
spec/frontend/jobs/components/log/collapsible_section_spec.js
.../frontend/jobs/components/log/collapsible_section_spec.js
+4
-4
spec/frontend/jobs/components/log/log_spec.js
spec/frontend/jobs/components/log/log_spec.js
+6
-6
spec/frontend/jobs/store/actions_spec.js
spec/frontend/jobs/store/actions_spec.js
+52
-52
spec/frontend/jobs/store/getters_spec.js
spec/frontend/jobs/store/getters_spec.js
+4
-4
spec/frontend/jobs/store/mutations_spec.js
spec/frontend/jobs/store/mutations_spec.js
+39
-39
spec/frontend/jobs/store/utils_spec.js
spec/frontend/jobs/store/utils_spec.js
+6
-6
No files found.
app/assets/javascripts/ide/stores/modules/pipelines/actions.js
View file @
41d44191
...
...
@@ -139,6 +139,7 @@ export const receiveJobLogsSuccess = ({ commit }, data) =>
export
const
fetchJobLogs
=
({
dispatch
,
state
})
=>
{
dispatch
(
'
requestJobLogs
'
);
// update trace endpoint once BE compeletes trace re-naming in #340626
return
axios
.
get
(
`
${
state
.
detailJob
.
path
}
/trace`
,
{
params
:
{
format
:
'
json
'
}
})
.
then
(({
data
})
=>
dispatch
(
'
receiveJobLogsSuccess
'
,
data
))
...
...
app/assets/javascripts/jobs/components/job_app.vue
View file @
41d44191
...
...
@@ -80,13 +80,13 @@ export default {
'
isLoading
'
,
'
job
'
,
'
isSidebarOpen
'
,
'
trace
'
,
'
is
Trace
Complete
'
,
'
trace
Size
'
,
'
is
Trace
SizeVisible
'
,
'
jobLog
'
,
'
is
JobLog
Complete
'
,
'
jobLog
Size
'
,
'
is
JobLog
SizeVisible
'
,
'
isScrollBottomDisabled
'
,
'
isScrollTopDisabled
'
,
'
isScrolledToBottomBeforeReceiving
Trace
'
,
'
isScrolledToBottomBeforeReceiving
JobLog
'
,
'
hasError
'
,
'
selectedStage
'
,
]),
...
...
@@ -97,7 +97,7 @@ export default {
'
shouldRenderTriggeredLabel
'
,
'
hasEnvironment
'
,
'
shouldRenderSharedRunnerLimitWarning
'
,
'
has
Trace
'
,
'
has
JobLog
'
,
'
emptyStateIllustration
'
,
'
isScrollingDown
'
,
'
emptyStateAction
'
,
...
...
@@ -155,7 +155,7 @@ export default {
this
.
updateSidebar
();
},
beforeDestroy
()
{
this
.
stopPolling
Trace
();
this
.
stopPolling
JobLog
();
this
.
stopPolling
();
window
.
removeEventListener
(
'
resize
'
,
this
.
onResize
);
window
.
removeEventListener
(
'
scroll
'
,
this
.
updateScroll
);
...
...
@@ -168,7 +168,7 @@ export default {
'
toggleSidebar
'
,
'
scrollBottom
'
,
'
scrollTop
'
,
'
stopPolling
Trace
'
,
'
stopPolling
JobLog
'
,
'
stopPolling
'
,
'
toggleScrollButtons
'
,
'
toggleScrollAnimation
'
,
...
...
@@ -270,7 +270,7 @@ export default {
<div
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=
"
{ 'sticky-top gl-border-bottom-0': has
Trace
}"
:class=
"
{ 'sticky-top gl-border-bottom-0': has
JobLog
}"
data-testid="archived-job"
>
<gl-icon
name=
"lock"
class=
"gl-vertical-align-bottom"
/>
...
...
@@ -278,7 +278,7 @@ export default {
</div>
<!-- job log -->
<div
v-if=
"has
Trace
"
v-if=
"has
JobLog
"
class=
"build-trace-container gl-relative"
:class=
"
{ 'gl-mt-3': !job.archived }"
>
...
...
@@ -289,22 +289,22 @@ export default {
'has-archived-block': job.archived,
}"
:erase-path="job.erase_path"
:size="
trace
Size"
:size="
jobLog
Size"
:raw-path="job.raw_path"
:is-scroll-bottom-disabled="isScrollBottomDisabled"
:is-scroll-top-disabled="isScrollTopDisabled"
:is-
trace-size-visible="isTrace
SizeVisible"
:is-
job-log-size-visible="isJobLog
SizeVisible"
:is-scrolling-down="isScrollingDown"
@scrollJobLogTop="scrollTop"
@scrollJobLogBottom="scrollBottom"
/>
<log
:
trace=
"trace"
:is-complete=
"isTrace
Complete"
/>
<log
:
job-log=
"jobLog"
:is-complete=
"isJobLog
Complete"
/>
</div>
<!-- EO job log -->
<!-- empty state -->
<empty-state
v-if=
"!has
Trace
"
v-if=
"!has
JobLog
"
:illustration-path=
"emptyStateIllustration.image"
:illustration-size-class=
"emptyStateIllustration.size"
:title=
"emptyStateTitle"
...
...
app/assets/javascripts/jobs/components/job_log_controllers.vue
View file @
41d44191
...
...
@@ -44,7 +44,7 @@ export default {
type
:
Boolean
,
required
:
true
,
},
is
Trace
SizeVisible
:
{
is
JobLog
SizeVisible
:
{
type
:
Boolean
,
required
:
true
,
},
...
...
@@ -73,7 +73,7 @@ export default {
class=
"truncated-info gl-display-none gl-sm-display-block gl-float-left"
data-testid=
"log-truncated-info"
>
<template
v-if=
"is
Trace
SizeVisible"
>
<template
v-if=
"is
JobLog
SizeVisible"
>
{{
jobLogSize
}}
<gl-link
v-if=
"rawPath"
...
...
app/assets/javascripts/jobs/components/log/collapsible_section.vue
View file @
41d44191
...
...
@@ -17,7 +17,7 @@ export default {
type
:
Object
,
required
:
true
,
},
trace
Endpoint
:
{
jobLog
Endpoint
:
{
type
:
String
,
required
:
true
,
},
...
...
@@ -42,7 +42,7 @@ export default {
<log-line-header
:line=
"section.line"
:duration=
"badgeDuration"
:path=
"
trace
Endpoint"
:path=
"
jobLog
Endpoint"
:is-closed=
"section.isClosed"
@
toggleLine=
"handleOnClickCollapsibleLine(section)"
/>
...
...
@@ -53,10 +53,10 @@ export default {
v-if=
"line.isHeader"
:key=
"line.line.offset"
:section=
"line"
:
trace-endpoint=
"trace
Endpoint"
:
job-log-endpoint=
"jobLog
Endpoint"
@
onClickCollapsibleLine=
"handleOnClickCollapsibleLine"
/>
<log-line
v-else
:key=
"line.offset"
:line=
"line"
:path=
"
trace
Endpoint"
/>
<log-line
v-else
:key=
"line.offset"
:line=
"line"
:path=
"
jobLog
Endpoint"
/>
</
template
>
</template>
<
template
v-else
>
...
...
@@ -64,7 +64,7 @@ export default {
v-for=
"line in section.lines"
:key=
"line.offset"
:line=
"line"
:path=
"
trace
Endpoint"
:path=
"
jobLog
Endpoint"
/>
</
template
>
</template>
...
...
app/assets/javascripts/jobs/components/log/log.vue
View file @
41d44191
...
...
@@ -10,10 +10,10 @@ export default {
},
computed
:
{
...
mapState
([
'
trace
Endpoint
'
,
'
trace
'
,
'
is
Trace
Complete
'
,
'
isScrolledToBottomBeforeReceiving
Trace
'
,
'
jobLog
Endpoint
'
,
'
jobLog
'
,
'
is
JobLog
Complete
'
,
'
isScrolledToBottomBeforeReceiving
JobLog
'
,
]),
},
updated
()
{
...
...
@@ -39,7 +39,7 @@ export default {
* In order to scroll the page down after `v-html` has finished, we need to use setTimeout
*/
handleScrollDown
()
{
if
(
this
.
isScrolledToBottomBeforeReceiving
Trace
)
{
if
(
this
.
isScrolledToBottomBeforeReceiving
JobLog
)
{
setTimeout
(()
=>
{
this
.
scrollBottom
();
},
0
);
...
...
@@ -50,18 +50,18 @@ export default {
</
script
>
<
template
>
<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
v-if=
"section.isHeader"
:key=
"`collapsible-$
{index}`"
:section="section"
:
trace-endpoint="trace
Endpoint"
:
job-log-endpoint="jobLog
Endpoint"
@onClickCollapsibleLine="handleOnClickCollapsibleLine"
/>
<log-line
v-else
:key=
"section.offset"
:line=
"section"
:path=
"
trace
Endpoint"
/>
<log-line
v-else
:key=
"section.offset"
:line=
"section"
:path=
"
jobLog
Endpoint"
/>
</
template
>
<div
v-if=
"!is
Trace
Complete"
class=
"js-log-animation loader-animation pt-3 pl-3"
>
<div
v-if=
"!is
JobLog
Complete"
class=
"js-log-animation loader-animation pt-3 pl-3"
>
<div
class=
"dot"
></div>
<div
class=
"dot"
></div>
<div
class=
"dot"
></div>
...
...
app/assets/javascripts/jobs/store/actions.js
View file @
41d44191
...
...
@@ -18,16 +18,16 @@ import * as types from './mutation_types';
export
const
init
=
({
dispatch
},
{
endpoint
,
logState
,
pagePath
})
=>
{
dispatch
(
'
setJobEndpoint
'
,
endpoint
);
dispatch
(
'
set
Trace
Options
'
,
{
dispatch
(
'
set
JobLog
Options
'
,
{
logState
,
pagePath
,
});
return
Promise
.
all
([
dispatch
(
'
fetchJob
'
),
dispatch
(
'
fetch
Trace
'
)]);
return
Promise
.
all
([
dispatch
(
'
fetchJob
'
),
dispatch
(
'
fetch
JobLog
'
)]);
};
export
const
setJobEndpoint
=
({
commit
},
endpoint
)
=>
commit
(
types
.
SET_JOB_ENDPOINT
,
endpoint
);
export
const
set
TraceOptions
=
({
commit
},
options
)
=>
commit
(
types
.
SET_TRACE
_OPTIONS
,
options
);
export
const
set
JobLogOptions
=
({
commit
},
options
)
=>
commit
(
types
.
SET_JOB_LOG
_OPTIONS
,
options
);
export
const
hideSidebar
=
({
commit
})
=>
commit
(
types
.
HIDE_SIDEBAR
);
export
const
showSidebar
=
({
commit
})
=>
commit
(
types
.
SHOW_SIDEBAR
);
...
...
@@ -107,7 +107,7 @@ export const receiveJobError = ({ commit }) => {
};
/**
* Job
's Trace
* Job
Log
*/
export
const
scrollTop
=
({
dispatch
})
=>
{
scrollUp
();
...
...
@@ -156,59 +156,62 @@ export const toggleScrollAnimation = ({ commit }, toggle) =>
* Responsible to handle automatic scroll
*/
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
request
Trace
=
({
commit
})
=>
commit
(
types
.
REQUEST_TRACE
);
export
const
request
JobLog
=
({
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
.
get
(
`
${
state
.
trace
Endpoint
}
/trace.json`
,
{
params
:
{
state
:
state
.
trace
State
},
.
get
(
`
${
state
.
jobLog
Endpoint
}
/trace.json`
,
{
params
:
{
state
:
state
.
jobLog
State
},
})
.
then
(({
data
})
=>
{
dispatch
(
'
toggleScrollisInBottom
'
,
isScrolledToBottom
());
dispatch
(
'
receive
Trace
Success
'
,
data
);
dispatch
(
'
receive
JobLog
Success
'
,
data
);
if
(
data
.
complete
)
{
dispatch
(
'
stopPolling
Trace
'
);
}
else
if
(
!
state
.
trace
Timeout
)
{
dispatch
(
'
startPolling
Trace
'
);
dispatch
(
'
stopPolling
JobLog
'
);
}
else
if
(
!
state
.
jobLog
Timeout
)
{
dispatch
(
'
startPolling
JobLog
'
);
}
})
.
catch
((
e
)
=>
{
if
(
e
.
response
.
status
===
httpStatusCodes
.
FORBIDDEN
)
{
dispatch
(
'
receive
Trace
UnauthorizedError
'
);
dispatch
(
'
receive
JobLog
UnauthorizedError
'
);
}
else
{
reportToSentry
(
'
job_actions
'
,
e
);
dispatch
(
'
receive
Trace
Error
'
);
dispatch
(
'
receive
JobLog
Error
'
);
}
});
export
const
startPolling
Trace
=
({
dispatch
,
commit
})
=>
{
const
trace
Timeout
=
setTimeout
(()
=>
{
commit
(
types
.
SET_
TRACE
_TIMEOUT
,
0
);
dispatch
(
'
fetch
Trace
'
);
export
const
startPolling
JobLog
=
({
dispatch
,
commit
})
=>
{
const
jobLog
Timeout
=
setTimeout
(()
=>
{
commit
(
types
.
SET_
JOB_LOG
_TIMEOUT
,
0
);
dispatch
(
'
fetch
JobLog
'
);
},
4000
);
commit
(
types
.
SET_
TRACE_TIMEOUT
,
trace
Timeout
);
commit
(
types
.
SET_
JOB_LOG_TIMEOUT
,
jobLog
Timeout
);
};
export
const
stopPolling
Trace
=
({
state
,
commit
})
=>
{
clearTimeout
(
state
.
trace
Timeout
);
commit
(
types
.
SET_
TRACE
_TIMEOUT
,
0
);
commit
(
types
.
STOP_POLLING_
TRACE
);
export
const
stopPolling
JobLog
=
({
state
,
commit
})
=>
{
clearTimeout
(
state
.
jobLog
Timeout
);
commit
(
types
.
SET_
JOB_LOG
_TIMEOUT
,
0
);
commit
(
types
.
STOP_POLLING_
JOB_LOG
);
};
export
const
receiveTraceSuccess
=
({
commit
},
log
)
=>
commit
(
types
.
RECEIVE_TRACE_SUCCESS
,
log
);
export
const
receiveTraceError
=
({
dispatch
})
=>
{
dispatch
(
'
stopPollingTrace
'
);
export
const
receiveJobLogSuccess
=
({
commit
},
log
)
=>
commit
(
types
.
RECEIVE_JOB_LOG_SUCCESS
,
log
);
export
const
receiveJobLogError
=
({
dispatch
})
=>
{
dispatch
(
'
stopPollingJobLog
'
);
createFlash
({
message
:
__
(
'
An error occurred while fetching the job log.
'
),
});
};
export
const
receiveTraceUnauthorizedError
=
({
dispatch
})
=>
{
dispatch
(
'
stopPollingTrace
'
);
export
const
receiveJobLogUnauthorizedError
=
({
dispatch
})
=>
{
dispatch
(
'
stopPollingJobLog
'
);
createFlash
({
message
:
__
(
'
The current user is not authorized to access the job log.
'
),
});
...
...
@@ -248,6 +251,7 @@ export const fetchJobsForStage = ({ dispatch }, stage = {}) => {
};
export
const
receiveJobsForStageSuccess
=
({
commit
},
data
)
=>
commit
(
types
.
RECEIVE_JOBS_FOR_STAGE_SUCCESS
,
data
);
export
const
receiveJobsForStageError
=
({
commit
})
=>
{
commit
(
types
.
RECEIVE_JOBS_FOR_STAGE_ERROR
);
createFlash
({
...
...
app/assets/javascripts/jobs/store/getters.js
View file @
41d44191
...
...
@@ -21,11 +21,12 @@ export const shouldRenderTriggeredLabel = (state) => isString(state.job.started)
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
* @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
'
);
export
const
emptyStateIllustration
=
(
state
)
=>
state
?.
job
?.
status
?.
illustration
||
{};
...
...
@@ -43,7 +44,7 @@ export const shouldRenderSharedRunnerLimitWarning = (state) =>
!
isEmpty
(
state
.
job
.
runners
.
quota
)
&&
state
.
job
.
runners
.
quota
.
used
>=
state
.
job
.
runners
.
quota
.
limit
;
export
const
isScrollingDown
=
(
state
)
=>
isScrolledToBottom
()
&&
!
state
.
is
Trace
Complete
;
export
const
isScrollingDown
=
(
state
)
=>
isScrolledToBottom
()
&&
!
state
.
is
JobLog
Complete
;
export
const
hasRunnersForProject
=
(
state
)
=>
state
?.
job
?.
runners
?.
available
&&
!
state
?.
job
?.
runners
?.
online
;
app/assets/javascripts/jobs/store/mutation_types.js
View file @
41d44191
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
SHOW_SIDEBAR
=
'
SHOW_SIDEBAR
'
;
...
...
@@ -12,17 +12,17 @@ export const ENABLE_SCROLL_BOTTOM = 'ENABLE_SCROLL_BOTTOM';
export
const
ENABLE_SCROLL_TOP
=
'
ENABLE_SCROLL_TOP
'
;
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
RECEIVE_JOB_SUCCESS
=
'
RECEIVE_JOB_SUCCESS
'
;
export
const
RECEIVE_JOB_ERROR
=
'
RECEIVE_JOB_ERROR
'
;
export
const
REQUEST_
TRACE
=
'
REQUEST_TRACE
'
;
export
const
SET_
TRACE_TIMEOUT
=
'
SET_TRACE
_TIMEOUT
'
;
export
const
STOP_POLLING_
TRACE
=
'
STOP_POLLING_TRACE
'
;
export
const
RECEIVE_
TRACE_SUCCESS
=
'
RECEIVE_TRACE
_SUCCESS
'
;
export
const
RECEIVE_
TRACE_ERROR
=
'
RECEIVE_TRACE
_ERROR
'
;
export
const
REQUEST_
JOB_LOG
=
'
REQUEST_JOB_LOG
'
;
export
const
SET_
JOB_LOG_TIMEOUT
=
'
SET_JOB_LOG
_TIMEOUT
'
;
export
const
STOP_POLLING_
JOB_LOG
=
'
STOP_POLLING_JOB_LOG
'
;
export
const
RECEIVE_
JOB_LOG_SUCCESS
=
'
RECEIVE_JOB_LOG
_SUCCESS
'
;
export
const
RECEIVE_
JOB_LOG_ERROR
=
'
RECEIVE_JOB_LOG
_ERROR
'
;
export
const
TOGGLE_COLLAPSIBLE_LINE
=
'
TOGGLE_COLLAPSIBLE_LINE
'
;
export
const
SET_SELECTED_STAGE
=
'
SET_SELECTED_STAGE
'
;
...
...
app/assets/javascripts/jobs/store/mutations.js
View file @
41d44191
import
Vue
from
'
vue
'
;
import
{
INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF
}
from
'
../constants
'
;
import
*
as
types
from
'
./mutation_types
'
;
import
{
logLinesParser
,
logLinesParserLegacy
,
updateIncremental
Trace
}
from
'
./utils
'
;
import
{
logLinesParser
,
logLinesParserLegacy
,
updateIncremental
JobLog
}
from
'
./utils
'
;
export
default
{
[
types
.
SET_JOB_ENDPOINT
](
state
,
endpoint
)
{
state
.
jobEndpoint
=
endpoint
;
},
[
types
.
SET_
TRACE
_OPTIONS
](
state
,
options
=
{})
{
state
.
trace
Endpoint
=
options
.
pagePath
;
state
.
trace
State
=
options
.
logState
;
[
types
.
SET_
JOB_LOG
_OPTIONS
](
state
,
options
=
{})
{
state
.
jobLog
Endpoint
=
options
.
pagePath
;
state
.
jobLog
State
=
options
.
logState
;
},
[
types
.
HIDE_SIDEBAR
](
state
)
{
...
...
@@ -20,11 +20,11 @@ export default {
state
.
isSidebarOpen
=
true
;
},
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
state
,
log
=
{})
{
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
state
,
log
=
{})
{
const
infinitelyCollapsibleSectionsFlag
=
gon
.
features
?.[
INFINITELY_NESTED_COLLAPSIBLE_SECTIONS_FF
];
if
(
log
.
state
)
{
state
.
trace
State
=
log
.
state
;
state
.
jobLog
State
=
log
.
state
;
}
if
(
log
.
append
)
{
...
...
@@ -32,52 +32,52 @@ export default {
if
(
log
.
lines
)
{
const
parsedResult
=
logLinesParser
(
log
.
lines
,
state
.
auxiliaryPartial
Trace
Helpers
,
state
.
trace
,
state
.
auxiliaryPartial
JobLog
Helpers
,
state
.
jobLog
,
);
state
.
trace
=
parsedResult
.
parsedLines
;
state
.
auxiliaryPartial
TraceHelpers
=
parsedResult
.
auxiliaryPartialTrace
Helpers
;
state
.
jobLog
=
parsedResult
.
parsedLines
;
state
.
auxiliaryPartial
JobLogHelpers
=
parsedResult
.
auxiliaryPartialJobLog
Helpers
;
}
}
else
{
state
.
trace
=
log
.
lines
?
updateIncrementalTrace
(
log
.
lines
,
state
.
trace
)
:
state
.
trace
;
state
.
jobLog
=
log
.
lines
?
updateIncrementalJobLog
(
log
.
lines
,
state
.
jobLog
)
:
state
.
jobLog
;
}
state
.
trace
Size
+=
log
.
size
;
state
.
jobLog
Size
+=
log
.
size
;
}
else
{
// When the job still does not have a
trace
// the
trace
response will not have a defined
// When the job still does not have a
log
// the
job log
response will not have a defined
// html or size. We keep the old value otherwise these
// will be set to `null`
if
(
infinitelyCollapsibleSectionsFlag
)
{
const
parsedResult
=
logLinesParser
(
log
.
lines
);
state
.
trace
=
parsedResult
.
parsedLines
;
state
.
auxiliaryPartial
TraceHelpers
=
parsedResult
.
auxiliaryPartialTrace
Helpers
;
state
.
jobLog
=
parsedResult
.
parsedLines
;
state
.
auxiliaryPartial
JobLogHelpers
=
parsedResult
.
auxiliaryPartialJobLog
Helpers
;
}
else
{
state
.
trace
=
log
.
lines
?
logLinesParserLegacy
(
log
.
lines
)
:
state
.
trace
;
state
.
jobLog
=
log
.
lines
?
logLinesParserLegacy
(
log
.
lines
)
:
state
.
jobLog
;
}
state
.
traceSize
=
log
.
size
||
state
.
trace
Size
;
state
.
jobLogSize
=
log
.
size
||
state
.
jobLog
Size
;
}
if
(
state
.
trace
Size
<
log
.
total
)
{
state
.
is
Trace
SizeVisible
=
true
;
if
(
state
.
jobLog
Size
<
log
.
total
)
{
state
.
is
JobLog
SizeVisible
=
true
;
}
else
{
state
.
is
Trace
SizeVisible
=
false
;
state
.
is
JobLog
SizeVisible
=
false
;
}
state
.
is
TraceComplete
=
log
.
complete
||
state
.
isTrace
Complete
;
state
.
is
JobLogComplete
=
log
.
complete
||
state
.
isJobLog
Complete
;
},
[
types
.
SET_
TRACE
_TIMEOUT
](
state
,
id
)
{
state
.
trace
Timeout
=
id
;
[
types
.
SET_
JOB_LOG
_TIMEOUT
](
state
,
id
)
{
state
.
jobLog
Timeout
=
id
;
},
/**
* Will remove loading animation
*/
[
types
.
STOP_POLLING_
TRACE
](
state
)
{
state
.
is
Trace
Complete
=
true
;
[
types
.
STOP_POLLING_
JOB_LOG
](
state
)
{
state
.
is
JobLog
Complete
=
true
;
},
/**
...
...
@@ -137,8 +137,8 @@ export default {
state
.
isScrollingDown
=
toggle
;
},
[
types
.
TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_
TRACE
](
state
,
toggle
)
{
state
.
isScrolledToBottomBeforeReceiving
Trace
=
toggle
;
[
types
.
TOGGLE_IS_SCROLL_IN_BOTTOM_BEFORE_UPDATING_
JOB_LOG
](
state
,
toggle
)
{
state
.
isScrolledToBottomBeforeReceiving
JobLog
=
toggle
;
},
[
types
.
REQUEST_JOBS_FOR_STAGE
](
state
,
stage
=
{})
{
...
...
app/assets/javascripts/jobs/store/state.js
View file @
41d44191
export
default
()
=>
({
jobEndpoint
:
null
,
trace
Endpoint
:
null
,
jobLog
Endpoint
:
null
,
// sidebar
isSidebarOpen
:
true
,
...
...
@@ -14,16 +14,16 @@ export default () => ({
isScrollTopDisabled
:
true
,
// Used to check if we should keep the automatic scroll
isScrolledToBottomBeforeReceiving
Trace
:
true
,
isScrolledToBottomBeforeReceiving
JobLog
:
true
,
trace
:
[],
is
Trace
Complete
:
false
,
trace
Size
:
0
,
is
Trace
SizeVisible
:
false
,
trace
Timeout
:
0
,
jobLog
:
[],
is
JobLog
Complete
:
false
,
jobLog
Size
:
0
,
is
JobLog
SizeVisible
:
false
,
jobLog
Timeout
:
0
,
// used as a query parameter to fetch the
trace
trace
State
:
null
,
// used as a query parameter to fetch the
job log
jobLog
State
:
null
,
// sidebar dropdown & list of jobs
isLoadingJobs
:
false
,
...
...
@@ -32,5 +32,5 @@ export default () => ({
jobs
:
[],
// to parse partial logs
auxiliaryPartial
Trace
Helpers
:
{},
auxiliaryPartial
JobLog
Helpers
:
{},
});
app/assets/javascripts/jobs/store/utils.js
View file @
41d44191
...
...
@@ -131,17 +131,17 @@ export const logLinesParserLegacy = (lines = [], accumulator = []) =>
[...
accumulator
],
);
export
const
logLinesParser
=
(
lines
=
[],
previous
Trace
State
=
{},
prevParsedLines
=
[])
=>
{
let
currentLineCount
=
previous
Trace
State
?.
prevLineCount
??
0
;
let
currentHeader
=
previous
Trace
State
?.
currentHeader
;
let
isPreviousLineHeader
=
previous
Trace
State
?.
isPreviousLineHeader
??
false
;
export
const
logLinesParser
=
(
lines
=
[],
previous
JobLog
State
=
{},
prevParsedLines
=
[])
=>
{
let
currentLineCount
=
previous
JobLog
State
?.
prevLineCount
??
0
;
let
currentHeader
=
previous
JobLog
State
?.
currentHeader
;
let
isPreviousLineHeader
=
previous
JobLog
State
?.
isPreviousLineHeader
??
false
;
const
parsedLines
=
prevParsedLines
.
length
>
0
?
prevParsedLines
:
[];
const
sectionsQueue
=
previous
Trace
State
?.
sectionsQueue
??
[];
const
sectionsQueue
=
previous
JobLog
State
?.
sectionsQueue
??
[];
for
(
let
i
=
0
;
i
<
lines
.
length
;
i
+=
1
)
{
const
line
=
lines
[
i
];
// First run we can use the current index, later runs we have to retrieve the last number of lines
currentLineCount
=
previous
Trace
State
?.
prevLineCount
?
currentLineCount
+
1
:
i
+
1
;
currentLineCount
=
previous
JobLog
State
?.
prevLineCount
?
currentLineCount
+
1
:
i
+
1
;
if
(
line
.
section_header
&&
!
isPreviousLineHeader
)
{
// 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
return
{
parsedLines
,
auxiliaryPartial
Trace
Helpers
:
{
auxiliaryPartial
JobLog
Helpers
:
{
isPreviousLineHeader
,
currentHeader
,
sectionsQueue
,
...
...
@@ -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.
*
* We need to check if that is the case by looking for the offset property
...
...
@@ -250,7 +250,7 @@ export const findOffsetAndRemove = (newLog = [], oldParsed = []) => {
* @param array oldLog
* @param array newLog
*/
export
const
updateIncremental
Trace
=
(
newLog
=
[],
oldParsed
=
[])
=>
{
export
const
updateIncremental
JobLog
=
(
newLog
=
[],
oldParsed
=
[])
=>
{
const
parsedLog
=
findOffsetAndRemove
(
newLog
,
oldParsed
);
return
logLinesParserLegacy
(
newLog
,
parsedLog
);
...
...
spec/frontend/jobs/components/job_log_controllers_spec.js
View file @
41d44191
...
...
@@ -18,7 +18,7 @@ describe('Job log controllers', () => {
isScrollTopDisabled
:
false
,
isScrollBottomDisabled
:
false
,
isScrollingDown
:
true
,
is
Trace
SizeVisible
:
true
,
is
JobLog
SizeVisible
:
true
,
};
const
createWrapper
=
(
props
)
=>
{
...
...
@@ -38,7 +38,7 @@ describe('Job log controllers', () => {
const
findScrollBottom
=
()
=>
wrapper
.
find
(
'
[data-testid="job-controller-scroll-bottom"]
'
);
describe
(
'
Truncate information
'
,
()
=>
{
describe
(
'
with is
Trace
SizeVisible
'
,
()
=>
{
describe
(
'
with is
JobLog
SizeVisible
'
,
()
=>
{
beforeEach
(()
=>
{
createWrapper
();
});
...
...
spec/frontend/jobs/components/log/collapsible_section_spec.js
View file @
41d44191
...
...
@@ -6,7 +6,7 @@ describe('Job Log Collapsible Section', () => {
let
wrapper
;
let
origGon
;
const
trace
Endpoint
=
'
jobs/335
'
;
const
jobLog
Endpoint
=
'
jobs/335
'
;
const
findCollapsibleLine
=
()
=>
wrapper
.
find
(
'
.collapsible-line
'
);
const
findCollapsibleLineSvg
=
()
=>
wrapper
.
find
(
'
.collapsible-line svg
'
);
...
...
@@ -35,7 +35,7 @@ describe('Job Log Collapsible Section', () => {
beforeEach
(()
=>
{
createComponent
({
section
:
collapsibleSectionClosed
,
trace
Endpoint
,
jobLog
Endpoint
,
});
});
...
...
@@ -52,7 +52,7 @@ describe('Job Log Collapsible Section', () => {
beforeEach
(()
=>
{
createComponent
({
section
:
collapsibleSectionOpened
,
trace
Endpoint
,
jobLog
Endpoint
,
});
});
...
...
@@ -72,7 +72,7 @@ describe('Job Log Collapsible Section', () => {
it
(
'
emits onClickCollapsibleLine on click
'
,
()
=>
{
createComponent
({
section
:
collapsibleSectionOpened
,
trace
Endpoint
,
jobLog
Endpoint
,
});
findCollapsibleLine
().
trigger
(
'
click
'
);
...
...
spec/frontend/jobs/components/log/log_spec.js
View file @
41d44191
...
...
@@ -31,8 +31,8 @@ describe('Job Log', () => {
window
.
gon
=
{
features
:
{
infinitelyCollapsibleSections
:
false
}
};
state
=
{
trace
:
logLinesParserLegacy
(
jobLog
),
trace
Endpoint
:
'
jobs/id
'
,
jobLog
:
logLinesParserLegacy
(
jobLog
),
jobLog
Endpoint
:
'
jobs/id
'
,
};
store
=
new
Vuex
.
Store
({
...
...
@@ -59,7 +59,7 @@ describe('Job Log', () => {
});
it
(
'
links to the provided path and correct line number
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
#L1
'
).
attributes
(
'
href
'
)).
toBe
(
`
${
state
.
trace
Endpoint
}
#L1`
);
expect
(
wrapper
.
find
(
'
#L1
'
).
attributes
(
'
href
'
)).
toBe
(
`
${
state
.
jobLog
Endpoint
}
#L1`
);
});
});
...
...
@@ -111,8 +111,8 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => {
window
.
gon
=
{
features
:
{
infinitelyCollapsibleSections
:
true
}
};
state
=
{
trace
:
logLinesParser
(
jobLog
).
parsedLines
,
trace
Endpoint
:
'
jobs/id
'
,
jobLog
:
logLinesParser
(
jobLog
).
parsedLines
,
jobLog
Endpoint
:
'
jobs/id
'
,
};
store
=
new
Vuex
.
Store
({
...
...
@@ -139,7 +139,7 @@ describe('Job Log, infinitelyCollapsibleSections feature flag enabled', () => {
});
it
(
'
links to the provided path and correct line number
'
,
()
=>
{
expect
(
wrapper
.
find
(
'
#L1
'
).
attributes
(
'
href
'
)).
toBe
(
`
${
state
.
trace
Endpoint
}
#L1`
);
expect
(
wrapper
.
find
(
'
#L1
'
).
attributes
(
'
href
'
)).
toBe
(
`
${
state
.
jobLog
Endpoint
}
#L1`
);
});
});
...
...
spec/frontend/jobs/store/actions_spec.js
View file @
41d44191
...
...
@@ -3,7 +3,7 @@ import { TEST_HOST } from 'helpers/test_constants';
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
setJobEndpoint
,
set
Trace
Options
,
set
JobLog
Options
,
clearEtagPoll
,
stopPolling
,
requestJob
,
...
...
@@ -12,12 +12,12 @@ import {
receiveJobError
,
scrollTop
,
scrollBottom
,
request
Trace
,
fetch
Trace
,
startPolling
Trace
,
stopPolling
Trace
,
receive
Trace
Success
,
receive
Trace
Error
,
request
JobLog
,
fetch
JobLog
,
startPolling
JobLog
,
stopPolling
JobLog
,
receive
JobLog
Success
,
receive
JobLog
Error
,
toggleCollapsibleLine
,
requestJobsForStage
,
fetchJobsForStage
,
...
...
@@ -51,13 +51,13 @@ describe('Job State actions', () => {
});
});
describe
(
'
set
Trace
Options
'
,
()
=>
{
it
(
'
should commit SET_
TRACE
_OPTIONS mutation
'
,
(
done
)
=>
{
describe
(
'
set
JobLog
Options
'
,
()
=>
{
it
(
'
should commit SET_
JOB_LOG
_OPTIONS mutation
'
,
(
done
)
=>
{
testAction
(
set
Trace
Options
,
set
JobLog
Options
,
{
pagePath
:
'
job/872324/trace.json
'
},
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
,
);
...
...
@@ -191,17 +191,17 @@ describe('Job State actions', () => {
});
});
describe
(
'
request
Trace
'
,
()
=>
{
it
(
'
should commit REQUEST_
TRACE
mutation
'
,
(
done
)
=>
{
testAction
(
request
Trace
,
null
,
mockedState
,
[{
type
:
types
.
REQUEST_TRACE
}],
[],
done
);
describe
(
'
request
JobLog
'
,
()
=>
{
it
(
'
should commit REQUEST_
JOB_LOG
mutation
'
,
(
done
)
=>
{
testAction
(
request
JobLog
,
null
,
mockedState
,
[{
type
:
types
.
REQUEST_JOB_LOG
}],
[],
done
);
});
});
describe
(
'
fetch
Trace
'
,
()
=>
{
describe
(
'
fetch
JobLog
'
,
()
=>
{
let
mock
;
beforeEach
(()
=>
{
mockedState
.
trace
Endpoint
=
`
${
TEST_HOST
}
/endpoint`
;
mockedState
.
jobLog
Endpoint
=
`
${
TEST_HOST
}
/endpoint`
;
mock
=
new
MockAdapter
(
axios
);
});
...
...
@@ -212,14 +212,14 @@ describe('Job State actions', () => {
});
describe
(
'
success
'
,
()
=>
{
it
(
'
dispatches request
Trace, receiveTraceSuccess and stopPollingTrace
when job is complete
'
,
(
done
)
=>
{
it
(
'
dispatches request
JobLog, receiveJobLogSuccess and stopPollingJobLog
when job is complete
'
,
(
done
)
=>
{
mock
.
onGet
(
`
${
TEST_HOST
}
/endpoint/trace.json`
).
replyOnce
(
200
,
{
html
:
'
I, [2018-08-17T22:57:45.707325 #1841] INFO -- :
'
,
complete
:
true
,
});
testAction
(
fetch
Trace
,
fetch
JobLog
,
null
,
mockedState
,
[],
...
...
@@ -233,10 +233,10 @@ describe('Job State actions', () => {
html
:
'
I, [2018-08-17T22:57:45.707325 #1841] INFO -- :
'
,
complete
:
true
,
},
type
:
'
receive
Trace
Success
'
,
type
:
'
receive
JobLog
Success
'
,
},
{
type
:
'
stopPolling
Trace
'
,
type
:
'
stopPolling
JobLog
'
,
},
],
done
,
...
...
@@ -255,32 +255,32 @@ describe('Job State actions', () => {
mock
.
onGet
(
`
${
TEST_HOST
}
/endpoint/trace.json`
).
replyOnce
(
200
,
tracePayload
);
});
it
(
'
dispatches startPolling
Trace
'
,
(
done
)
=>
{
it
(
'
dispatches startPolling
JobLog
'
,
(
done
)
=>
{
testAction
(
fetch
Trace
,
fetch
JobLog
,
null
,
mockedState
,
[],
[
{
type
:
'
toggleScrollisInBottom
'
,
payload
:
true
},
{
type
:
'
receive
Trace
Success
'
,
payload
:
tracePayload
},
{
type
:
'
startPolling
Trace
'
},
{
type
:
'
receive
JobLog
Success
'
,
payload
:
tracePayload
},
{
type
:
'
startPolling
JobLog
'
},
],
done
,
);
});
it
(
'
does not dispatch startPolling
Trace
when timeout is non-empty
'
,
(
done
)
=>
{
mockedState
.
trace
Timeout
=
1
;
it
(
'
does not dispatch startPolling
JobLog
when timeout is non-empty
'
,
(
done
)
=>
{
mockedState
.
jobLog
Timeout
=
1
;
testAction
(
fetch
Trace
,
fetch
JobLog
,
null
,
mockedState
,
[],
[
{
type
:
'
toggleScrollisInBottom
'
,
payload
:
true
},
{
type
:
'
receive
Trace
Success
'
,
payload
:
tracePayload
},
{
type
:
'
receive
JobLog
Success
'
,
payload
:
tracePayload
},
],
done
,
);
...
...
@@ -293,15 +293,15 @@ describe('Job State actions', () => {
mock
.
onGet
(
`
${
TEST_HOST
}
/endpoint/trace.json`
).
reply
(
500
);
});
it
(
'
dispatches request
Trace and receiveTrace
Error
'
,
(
done
)
=>
{
it
(
'
dispatches request
JobLog and receiveJobLog
Error
'
,
(
done
)
=>
{
testAction
(
fetch
Trace
,
fetch
JobLog
,
null
,
mockedState
,
[],
[
{
type
:
'
receive
Trace
Error
'
,
type
:
'
receive
JobLog
Error
'
,
},
],
done
,
...
...
@@ -310,7 +310,7 @@ describe('Job State actions', () => {
});
});
describe
(
'
startPolling
Trace
'
,
()
=>
{
describe
(
'
startPolling
JobLog
'
,
()
=>
{
let
dispatch
;
let
commit
;
...
...
@@ -318,18 +318,18 @@ describe('Job State actions', () => {
dispatch
=
jest
.
fn
();
commit
=
jest
.
fn
();
startPolling
Trace
({
dispatch
,
commit
});
startPolling
JobLog
({
dispatch
,
commit
});
});
afterEach
(()
=>
{
jest
.
clearAllTimers
();
});
it
(
'
should save the timeout id but not call fetch
Trace
'
,
()
=>
{
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
SET_
TRACE
_TIMEOUT
,
expect
.
any
(
Number
));
it
(
'
should save the timeout id but not call fetch
JobLog
'
,
()
=>
{
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
SET_
JOB_LOG
_TIMEOUT
,
expect
.
any
(
Number
));
expect
(
commit
.
mock
.
calls
[
0
][
1
]).
toBeGreaterThan
(
0
);
expect
(
dispatch
).
not
.
toHaveBeenCalledWith
(
'
fetch
Trace
'
);
expect
(
dispatch
).
not
.
toHaveBeenCalledWith
(
'
fetch
JobLog
'
);
});
describe
(
'
after timeout has passed
'
,
()
=>
{
...
...
@@ -337,14 +337,14 @@ describe('Job State actions', () => {
jest
.
advanceTimersByTime
(
4000
);
});
it
(
'
should clear the timeout id and fetch
Trace
'
,
()
=>
{
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
SET_
TRACE
_TIMEOUT
,
0
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
fetch
Trace
'
);
it
(
'
should clear the timeout id and fetch
JobLog
'
,
()
=>
{
expect
(
commit
).
toHaveBeenCalledWith
(
types
.
SET_
JOB_LOG
_TIMEOUT
,
0
);
expect
(
dispatch
).
toHaveBeenCalledWith
(
'
fetch
JobLog
'
);
});
});
});
describe
(
'
stopPolling
Trace
'
,
()
=>
{
describe
(
'
stopPolling
JobLog
'
,
()
=>
{
let
origTimeout
;
beforeEach
(()
=>
{
...
...
@@ -358,40 +358,40 @@ describe('Job State actions', () => {
window
.
clearTimeout
=
origTimeout
;
});
it
(
'
should commit STOP_POLLING_
TRACE
mutation
'
,
(
done
)
=>
{
const
trace
Timeout
=
7
;
it
(
'
should commit STOP_POLLING_
JOB_LOG
mutation
'
,
(
done
)
=>
{
const
jobLog
Timeout
=
7
;
testAction
(
stopPolling
Trace
,
stopPolling
JobLog
,
null
,
{
...
mockedState
,
trace
Timeout
},
[{
type
:
types
.
SET_
TRACE_TIMEOUT
,
payload
:
0
},
{
type
:
types
.
STOP_POLLING_TRACE
}],
{
...
mockedState
,
jobLog
Timeout
},
[{
type
:
types
.
SET_
JOB_LOG_TIMEOUT
,
payload
:
0
},
{
type
:
types
.
STOP_POLLING_JOB_LOG
}],
[],
)
.
then
(()
=>
{
expect
(
window
.
clearTimeout
).
toHaveBeenCalledWith
(
trace
Timeout
);
expect
(
window
.
clearTimeout
).
toHaveBeenCalledWith
(
jobLog
Timeout
);
})
.
then
(
done
)
.
catch
(
done
.
fail
);
});
});
describe
(
'
receive
Trace
Success
'
,
()
=>
{
it
(
'
should commit RECEIVE_
TRACE
_SUCCESS mutation
'
,
(
done
)
=>
{
describe
(
'
receive
JobLog
Success
'
,
()
=>
{
it
(
'
should commit RECEIVE_
JOB_LOG
_SUCCESS mutation
'
,
(
done
)
=>
{
testAction
(
receive
Trace
Success
,
receive
JobLog
Success
,
'
hello world
'
,
mockedState
,
[{
type
:
types
.
RECEIVE_
TRACE
_SUCCESS
,
payload
:
'
hello world
'
}],
[{
type
:
types
.
RECEIVE_
JOB_LOG
_SUCCESS
,
payload
:
'
hello world
'
}],
[],
done
,
);
});
});
describe
(
'
receive
Trace
Error
'
,
()
=>
{
describe
(
'
receive
JobLog
Error
'
,
()
=>
{
it
(
'
should commit stop polling trace
'
,
(
done
)
=>
{
testAction
(
receive
TraceError
,
null
,
mockedState
,
[],
[{
type
:
'
stopPollingTrace
'
}],
done
);
testAction
(
receive
JobLogError
,
null
,
mockedState
,
[],
[{
type
:
'
stopPollingJobLog
'
}],
done
);
});
});
...
...
spec/frontend/jobs/store/getters_spec.js
View file @
41d44191
...
...
@@ -102,13 +102,13 @@ describe('Job Store Getters', () => {
});
});
describe
(
'
has
Trace
'
,
()
=>
{
describe
(
'
has
JobLog
'
,
()
=>
{
describe
(
'
when has_trace is true
'
,
()
=>
{
it
(
'
returns true
'
,
()
=>
{
localState
.
job
.
has_trace
=
true
;
localState
.
job
.
status
=
{};
expect
(
getters
.
has
Trace
(
localState
)).
toEqual
(
true
);
expect
(
getters
.
has
JobLog
(
localState
)).
toEqual
(
true
);
});
});
...
...
@@ -117,7 +117,7 @@ describe('Job Store Getters', () => {
localState
.
job
.
has_trace
=
false
;
localState
.
job
.
status
=
{
group
:
'
running
'
};
expect
(
getters
.
has
Trace
(
localState
)).
toEqual
(
true
);
expect
(
getters
.
has
JobLog
(
localState
)).
toEqual
(
true
);
});
});
...
...
@@ -126,7 +126,7 @@ describe('Job Store Getters', () => {
localState
.
job
.
has_trace
=
false
;
localState
.
job
.
status
=
{
group
:
'
pending
'
};
expect
(
getters
.
has
Trace
(
localState
)).
toEqual
(
false
);
expect
(
getters
.
has
JobLog
(
localState
)).
toEqual
(
false
);
});
});
});
...
...
spec/frontend/jobs/store/mutations_spec.js
View file @
41d44191
...
...
@@ -45,39 +45,39 @@ describe('Jobs Store Mutations', () => {
});
});
describe
(
'
RECEIVE_
TRACE
_SUCCESS
'
,
()
=>
{
describe
(
'
RECEIVE_
JOB_LOG
_SUCCESS
'
,
()
=>
{
describe
(
'
when trace has state
'
,
()
=>
{
it
(
'
sets
trace
State
'
,
()
=>
{
it
(
'
sets
jobLog
State
'
,
()
=>
{
const
stateLog
=
'
eyJvZmZzZXQiOjczNDQ1MSwibl9vcGVuX3RhZ3MiOjAsImZnX2NvbG9yIjpudWxsLCJiZ19jb2xvciI6bnVsbCwic3R5bGVfbWFzayI6MH0=
'
;
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
state
:
stateLog
,
});
expect
(
stateCopy
.
trace
State
).
toEqual
(
stateLog
);
expect
(
stateCopy
.
jobLog
State
).
toEqual
(
stateLog
);
});
});
describe
(
'
when
trace
Size is smaller than the total size
'
,
()
=>
{
it
(
'
sets is
Trace
SizeVisible to true
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
total
:
51184600
,
size
:
1231
});
describe
(
'
when
jobLog
Size is smaller than the total size
'
,
()
=>
{
it
(
'
sets is
JobLog
SizeVisible to true
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
total
:
51184600
,
size
:
1231
});
expect
(
stateCopy
.
is
Trace
SizeVisible
).
toEqual
(
true
);
expect
(
stateCopy
.
is
JobLog
SizeVisible
).
toEqual
(
true
);
});
});
describe
(
'
when
trace
Size is bigger than the total size
'
,
()
=>
{
it
(
'
sets is
Trace
SizeVisible to false
'
,
()
=>
{
const
copy
=
{
...
stateCopy
,
trace
Size
:
5118460
,
size
:
2321312
};
describe
(
'
when
jobLog
Size is bigger than the total size
'
,
()
=>
{
it
(
'
sets is
JobLog
SizeVisible to false
'
,
()
=>
{
const
copy
=
{
...
stateCopy
,
jobLog
Size
:
5118460
,
size
:
2321312
};
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
copy
,
{
total
:
511846
});
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
copy
,
{
total
:
511846
});
expect
(
copy
.
is
Trace
SizeVisible
).
toEqual
(
false
);
expect
(
copy
.
is
JobLog
SizeVisible
).
toEqual
(
false
);
});
});
it
(
'
sets trace, trace size and is
Trace
Complete
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
it
(
'
sets trace, trace size and is
JobLog
Complete
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
true
,
html
,
size
:
511846
,
...
...
@@ -85,15 +85,15 @@ describe('Jobs Store Mutations', () => {
lines
:
[],
});
expect
(
stateCopy
.
trace
Size
).
toEqual
(
511846
);
expect
(
stateCopy
.
is
Trace
Complete
).
toEqual
(
true
);
expect
(
stateCopy
.
jobLog
Size
).
toEqual
(
511846
);
expect
(
stateCopy
.
is
JobLog
Complete
).
toEqual
(
true
);
});
describe
(
'
with new job log
'
,
()
=>
{
describe
(
'
log.lines
'
,
()
=>
{
describe
(
'
when append is true
'
,
()
=>
{
it
(
'
sets the parsed log
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
true
,
size
:
511846
,
complete
:
true
,
...
...
@@ -105,7 +105,7 @@ describe('Jobs Store Mutations', () => {
],
});
expect
(
stateCopy
.
trace
).
toEqual
([
expect
(
stateCopy
.
jobLog
).
toEqual
([
{
offset
:
1
,
content
:
[{
text
:
'
Running with gitlab-runner 11.12.1 (5a147c92)
'
}],
...
...
@@ -117,7 +117,7 @@ describe('Jobs Store Mutations', () => {
describe
(
'
when it is defined
'
,
()
=>
{
it
(
'
sets the parsed log
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
false
,
size
:
511846
,
complete
:
true
,
...
...
@@ -126,7 +126,7 @@ describe('Jobs Store Mutations', () => {
],
});
expect
(
stateCopy
.
trace
).
toEqual
([
expect
(
stateCopy
.
jobLog
).
toEqual
([
{
offset
:
0
,
content
:
[{
text
:
'
Running with gitlab-runner 11.11.1 (5a147c92)
'
}],
...
...
@@ -138,7 +138,7 @@ describe('Jobs Store Mutations', () => {
describe
(
'
when it is null
'
,
()
=>
{
it
(
'
sets the default value
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
true
,
html
,
size
:
511846
,
...
...
@@ -146,30 +146,30 @@ describe('Jobs Store Mutations', () => {
lines
:
null
,
});
expect
(
stateCopy
.
trace
).
toEqual
([]);
expect
(
stateCopy
.
jobLog
).
toEqual
([]);
});
});
});
});
});
describe
(
'
SET_
TRACE
_TIMEOUT
'
,
()
=>
{
it
(
'
sets the
trace
Timeout id
'
,
()
=>
{
describe
(
'
SET_
JOB_LOG
_TIMEOUT
'
,
()
=>
{
it
(
'
sets the
jobLog
Timeout id
'
,
()
=>
{
const
id
=
7
;
expect
(
stateCopy
.
trace
Timeout
).
not
.
toEqual
(
id
);
expect
(
stateCopy
.
jobLog
Timeout
).
not
.
toEqual
(
id
);
mutations
[
types
.
SET_
TRACE
_TIMEOUT
](
stateCopy
,
id
);
mutations
[
types
.
SET_
JOB_LOG
_TIMEOUT
](
stateCopy
,
id
);
expect
(
stateCopy
.
trace
Timeout
).
toEqual
(
id
);
expect
(
stateCopy
.
jobLog
Timeout
).
toEqual
(
id
);
});
});
describe
(
'
STOP_POLLING_
TRACE
'
,
()
=>
{
it
(
'
sets is
Trace
Complete to true
'
,
()
=>
{
mutations
[
types
.
STOP_POLLING_
TRACE
](
stateCopy
);
describe
(
'
STOP_POLLING_
JOB_LOG
'
,
()
=>
{
it
(
'
sets is
JobLog
Complete to true
'
,
()
=>
{
mutations
[
types
.
STOP_POLLING_
JOB_LOG
](
stateCopy
);
expect
(
stateCopy
.
is
Trace
Complete
).
toEqual
(
true
);
expect
(
stateCopy
.
is
JobLog
Complete
).
toEqual
(
true
);
});
});
...
...
@@ -296,12 +296,12 @@ describe('Job Store mutations, feature flag ON', () => {
window
.
gon
=
origGon
;
});
describe
(
'
RECEIVE_
TRACE
_SUCCESS
'
,
()
=>
{
describe
(
'
RECEIVE_
JOB_LOG
_SUCCESS
'
,
()
=>
{
describe
(
'
with new job log
'
,
()
=>
{
describe
(
'
log.lines
'
,
()
=>
{
describe
(
'
when append is true
'
,
()
=>
{
it
(
'
sets the parsed log
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
true
,
size
:
511846
,
complete
:
true
,
...
...
@@ -313,7 +313,7 @@ describe('Job Store mutations, feature flag ON', () => {
],
});
expect
(
stateCopy
.
trace
).
toEqual
([
expect
(
stateCopy
.
jobLog
).
toEqual
([
{
offset
:
1
,
content
:
[{
text
:
'
Running with gitlab-runner 11.12.1 (5a147c92)
'
}],
...
...
@@ -325,7 +325,7 @@ describe('Job Store mutations, feature flag ON', () => {
describe
(
'
when lines are defined
'
,
()
=>
{
it
(
'
sets the parsed log
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
false
,
size
:
511846
,
complete
:
true
,
...
...
@@ -334,7 +334,7 @@ describe('Job Store mutations, feature flag ON', () => {
],
});
expect
(
stateCopy
.
trace
).
toEqual
([
expect
(
stateCopy
.
jobLog
).
toEqual
([
{
offset
:
0
,
content
:
[{
text
:
'
Running with gitlab-runner 11.11.1 (5a147c92)
'
}],
...
...
@@ -346,7 +346,7 @@ describe('Job Store mutations, feature flag ON', () => {
describe
(
'
when lines are null
'
,
()
=>
{
it
(
'
sets the default value
'
,
()
=>
{
mutations
[
types
.
RECEIVE_
TRACE
_SUCCESS
](
stateCopy
,
{
mutations
[
types
.
RECEIVE_
JOB_LOG
_SUCCESS
](
stateCopy
,
{
append
:
true
,
html
,
size
:
511846
,
...
...
@@ -354,7 +354,7 @@ describe('Job Store mutations, feature flag ON', () => {
lines
:
null
,
});
expect
(
stateCopy
.
trace
).
toEqual
([]);
expect
(
stateCopy
.
jobLog
).
toEqual
([]);
});
});
});
...
...
spec/frontend/jobs/store/utils_spec.js
View file @
41d44191
import
{
logLinesParser
,
logLinesParserLegacy
,
updateIncremental
Trace
,
updateIncremental
JobLog
,
parseHeaderLine
,
parseLine
,
addDurationToHeader
,
...
...
@@ -487,11 +487,11 @@ describe('Jobs Store Utils', () => {
});
});
describe
(
'
updateIncremental
Trace
'
,
()
=>
{
describe
(
'
updateIncremental
JobLog
'
,
()
=>
{
describe
(
'
without repeated section
'
,
()
=>
{
it
(
'
concats and parses both arrays
'
,
()
=>
{
const
oldLog
=
logLinesParserLegacy
(
originalTrace
);
const
result
=
updateIncremental
Trace
(
regularIncremental
,
oldLog
);
const
result
=
updateIncremental
JobLog
(
regularIncremental
,
oldLog
);
expect
(
result
).
toEqual
([
{
...
...
@@ -519,7 +519,7 @@ describe('Jobs Store Utils', () => {
describe
(
'
with regular line repeated offset
'
,
()
=>
{
it
(
'
updates the last line and formats with the incremental part
'
,
()
=>
{
const
oldLog
=
logLinesParserLegacy
(
originalTrace
);
const
result
=
updateIncremental
Trace
(
regularIncrementalRepeated
,
oldLog
);
const
result
=
updateIncremental
JobLog
(
regularIncrementalRepeated
,
oldLog
);
expect
(
result
).
toEqual
([
{
...
...
@@ -538,7 +538,7 @@ describe('Jobs Store Utils', () => {
describe
(
'
with header line repeated
'
,
()
=>
{
it
(
'
updates the header line and formats with the incremental part
'
,
()
=>
{
const
oldLog
=
logLinesParserLegacy
(
headerTrace
);
const
result
=
updateIncremental
Trace
(
headerTraceIncremental
,
oldLog
);
const
result
=
updateIncremental
JobLog
(
headerTraceIncremental
,
oldLog
);
expect
(
result
).
toEqual
([
{
...
...
@@ -564,7 +564,7 @@ describe('Jobs Store Utils', () => {
describe
(
'
with collapsible line repeated
'
,
()
=>
{
it
(
'
updates the collapsible line and formats with the incremental part
'
,
()
=>
{
const
oldLog
=
logLinesParserLegacy
(
collapsibleTrace
);
const
result
=
updateIncremental
Trace
(
collapsibleTraceIncremental
,
oldLog
);
const
result
=
updateIncremental
JobLog
(
collapsibleTraceIncremental
,
oldLog
);
expect
(
result
).
toEqual
([
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment