Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
siibra-explorer
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiao Gui
siibra-explorer
Commits
cd164c67
Commit
cd164c67
authored
4 years ago
by
Xiao Gui
Browse files
Options
Downloads
Patches
Plain Diff
bugfix: retries on failed saneUrl set
parent
71aa39f1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
deploy/saneUrl/store.js
+13
-1
13 additions, 1 deletion
deploy/saneUrl/store.js
deploy/saneUrl/store.spec.js
+18
-0
18 additions, 0 deletions
deploy/saneUrl/store.spec.js
with
31 additions
and
1 deletion
deploy/saneUrl/store.js
+
13
−
1
View file @
cd164c67
...
...
@@ -43,6 +43,7 @@ class Store {
async
getToken
()
{
this
.
token
=
await
this
.
wrapper
.
getScopedToken
({
projectId
:
OBJ_STORAGE_PROJECT_ID
})
return
this
.
token
}
get
(
id
)
{
...
...
@@ -60,7 +61,7 @@ class Store {
})
}
set
(
id
,
value
)
{
_
set
(
id
,
value
)
{
return
new
Promise
((
rs
,
rj
)
=>
{
request
.
put
(
`
${
this
.
objStorateRootUrl
}
/
${
id
}
`
,
{
headers
:
{
...
...
@@ -75,6 +76,17 @@ class Store {
})
}
async
set
(
id
,
value
)
{
try
{
const
result
=
await
this
.
_set
(
id
,
value
)
return
result
}
catch
(
e
)
{
await
this
.
getToken
()
const
result
=
await
this
.
_set
(
id
,
value
)
return
result
}
}
async
healthCheck
(){
}
...
...
This diff is collapsed.
Click to expand it.
deploy/saneUrl/store.spec.js
+
18
−
0
View file @
cd164c67
...
...
@@ -28,6 +28,10 @@ describe('> store.js', () => {
expect
(
token
).
to
.
equal
(
fakeToken
)
})
it
(
'
> spy gets reset
'
,
async
()
=>
{
expect
(
getTokenSpy
.
notCalled
).
to
.
be
.
true
})
it
(
'
> get works
'
,
async
()
=>
{
const
scope
=
nock
(
objStorateRootUrl
)
.
get
(
`/
${
objName
}
`
)
...
...
@@ -50,8 +54,22 @@ describe('> store.js', () => {
})
await
store
.
set
(
objName
,
objContent
)
expect
(
scope
.
isDone
()).
to
.
be
.
true
})
it
(
'
> set retries if at first fails
'
,
async
()
=>
{
let
index
=
0
const
scope
=
nock
(
objStorateRootUrl
)
.
put
(
`/
${
objName
}
`
)
.
twice
()
.
reply
((
_uri
,
_reqBody
,
cb
)
=>
{
cb
(
null
,
[
index
%
2
===
0
?
401
:
200
])
index
++
})
await
store
.
set
(
objName
,
objContent
)
expect
(
scope
.
isDone
()).
to
.
be
.
true
expect
(
getTokenSpy
.
called
).
to
.
be
.
true
})
})
})
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment