Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
ui-middleware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
OX App Suite
Core
ui-middleware
Commits
cac8dea0
Commit
cac8dea0
authored
1 year ago
by
maik.schaefer
Browse files
Options
Downloads
Patches
Plain Diff
OXUI-1345: Reset version info on cache warmup failure
parent
ddb72692
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
spec/version_mismatches_test.js
+27
-16
27 additions, 16 deletions
spec/version_mismatches_test.js
src/version.js
+4
-3
4 additions, 3 deletions
src/version.js
with
31 additions
and
19 deletions
spec/version_mismatches_test.js
+
27
−
16
View file @
cac8dea0
...
...
@@ -44,8 +44,12 @@ describe('version mismatches', function () {
new
Response
(
'
foo1
'
,
{
headers
:
{
version
:
'
1
'
}
}),
new
Response
(
'
foo2
'
,
{
headers
:
{
version
:
'
2
'
}
})
),
'
/bar.js
'
:
()
=>
new
Response
(
'
bar
'
,
{
headers
:
{
version
:
'
2
'
}
}),
'
/whatever.js
'
:
()
=>
new
Response
(
'
whatever
'
,
{
headers
:
{
version
:
'
2
'
}
}),
'
/bar.js
'
:
td
.
when
(
td
.
func
()(
td
.
matchers
.
anything
(),
td
.
matchers
.
anything
())).
thenReturn
(
new
Response
(
'
bar
'
,
{
headers
:
{
version
:
'
2
'
}
}),
new
Response
(
'
bar
'
,
{
headers
:
{
version
:
'
2
'
}
}),
new
Response
(
'
bar
'
,
{
headers
:
{
version
:
'
3
'
}
})
),
'
/whatever.js
'
:
()
=>
new
Response
(
'
whatever
'
,
{
headers
:
{
version
:
'
3
'
}
}),
'
/meta.json
'
:
td
.
when
(
td
.
func
()(
td
.
matchers
.
anything
(),
td
.
matchers
.
anything
())).
thenReturn
(
new
Response
(
JSON
.
stringify
({
}),
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
version
:
'
1
'
}
}),
new
Response
(
JSON
.
stringify
({
}),
{
headers
:
{
'
Content-Type
'
:
'
application/json
'
,
version
:
'
2
'
}
})
...
...
@@ -68,17 +72,24 @@ describe('version mismatches', function () {
})
it
(
'
detects version mismatches when files are fetched
'
,
async
function
()
{
// get foo.js with initial version
// get foo.js with initial version errors, due to the version mismatch
// no partially complete state should be active (version 1)
let
response
=
await
app
.
inject
({
url
:
'
/foo.js
'
})
expect
(
response
.
statusCode
).
to
.
equal
(
404
)
await
runUpdate
(
pubClient
)
// update the version (version 2)
response
=
await
app
.
inject
({
url
:
'
/foo.js
'
})
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
body
).
to
.
equal
(
'
foo
1
'
)
expect
(
response
.
headers
.
version
).
to
.
equal
(
'
8510
1541
'
)
expect
(
response
.
body
).
to
.
equal
(
'
foo
2
'
)
expect
(
response
.
headers
.
version
).
to
.
equal
(
'
8510
2502
'
)
// get bar.js. This will cause the server to detect the version mismatch
response
=
await
app
.
inject
({
url
:
'
/bar.js
'
})
expect
(
response
.
statusCode
).
to
.
equal
(
404
)
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
body
).
to
.
equal
(
'
bar
'
)
await
runUpdate
(
pubClient
)
await
runUpdate
(
pubClient
)
// version 3 not successful but still version 2 in cache
await
runUpdate
(
pubClient
)
// get foo.js again. Since the versions should coincide now, the client should receive the new file
...
...
@@ -89,23 +100,23 @@ describe('version mismatches', function () {
})
it
(
'
detects version mismatches in files not referenced in manifest.json when files are fetched
'
,
async
function
()
{
// get foo.js with initial version
// get foo.js with initial version
1
let
response
=
await
app
.
inject
({
url
:
'
/foo.js
'
})
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
body
).
to
.
equal
(
'
foo1
'
)
expect
(
response
.
headers
.
version
).
to
.
equal
(
'
85101541
'
)
expect
(
response
.
statusCode
).
to
.
equal
(
404
)
// get bar.js. This will cause the server to detect the version mismatch
// update the version to 2
await
runUpdate
(
pubClient
)
// get whatever.js. This will cause the server to detect the version mismatch
response
=
await
app
.
inject
({
url
:
'
/whatever.js
'
})
expect
(
response
.
statusCode
).
to
.
equal
(
404
)
await
runUpdate
(
pubClient
)
await
runUpdate
(
pubClient
)
// version 3 not successful but still version 2 in cache
await
runUpdate
(
pubClient
)
//
get foo.js again. Since the versions should coincide now, the client should receive the new file
response
=
await
app
.
inject
({
url
:
'
/
foo
.js
'
})
//
bar should still be version 2
response
=
await
app
.
inject
({
url
:
'
/
bar
.js
'
})
expect
(
response
.
statusCode
).
to
.
equal
(
200
)
expect
(
response
.
body
).
to
.
equal
(
'
foo2
'
)
expect
(
response
.
body
).
to
.
equal
(
'
bar
'
)
expect
(
response
.
headers
.
version
).
to
.
equal
(
'
85102502
'
)
})
})
This diff is collapsed.
Click to expand it.
src/version.js
+
4
−
3
View file @
cac8dea0
...
...
@@ -164,7 +164,7 @@ let prevProcessedVersion = null
export
async
function
updateVersionProcessor
(
pubClient
)
{
try
{
logger
.
info
(
'
[Version] Check for new version
'
)
logger
.
debug
(
'
[Version] Check for new version
'
)
await
configMap
.
load
()
const
[
storedVersion
,
fetchedVersionInfo
]
=
await
Promise
.
all
([
...
...
@@ -175,8 +175,7 @@ export async function updateVersionProcessor (pubClient) {
if
(
prevProcessedVersion
&&
storedVersion
===
fetchedVersionInfo
.
version
)
{
// make sure to limit memory consumption and always check redis
cache
.
clear
()
logger
.
info
(
`[Version] No new version has been found. No update needed. Current version:
${
storedVersion
}
`
)
logger
.
debug
(
`[Version] No new version has been found. No update needed. Current version:
${
storedVersion
}
`
)
return
storedVersion
}
logger
.
info
(
`[Version] Found new source version. Current version: '
${
storedVersion
}
', new version: '
${
fetchedVersionInfo
.
version
}
'`
)
...
...
@@ -186,6 +185,7 @@ export async function updateVersionProcessor (pubClient) {
Object
.
assign
(
versionInfo
,
fetchedVersionInfo
)
const
stringifiedVersionInfo
=
JSON
.
stringify
(
versionInfo
)
cache
.
clear
()
await
warmCache
({
version
:
versionInfo
.
version
,
fetchFiles
:
true
})
await
redis
.
client
.
set
(
getRedisKey
({
name
:
'
versionInfo
'
}),
stringifiedVersionInfo
)
await
cache
.
get
(
getRedisKey
({
version
:
versionInfo
.
version
,
name
:
'
mergedMetadata
'
}),
async
()
=>
[
await
fetchMergedMetadata
()])
...
...
@@ -197,6 +197,7 @@ export async function updateVersionProcessor (pubClient) {
prevProcessedVersion
=
fetchedVersionInfo
.
version
}
}
catch
(
err
)
{
versionInfo
.
version
=
null
logger
.
error
(
`[Version] comparing version is not possible. Error:
${
err
.
message
}
`
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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