Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
buildstream
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
BuildStream
buildstream
Commits
1d3f74db
Commit
1d3f74db
authored
6 years ago
by
Tristan Van Berkom
Browse files
Options
Downloads
Patches
Plain Diff
tests/artifactcache/expiry.py: Test that expiry happens first
parent
c46af807
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/artifactcache/expiry.py
+64
-0
64 additions, 0 deletions
tests/artifactcache/expiry.py
with
64 additions
and
0 deletions
tests/artifactcache/expiry.py
+
64
−
0
View file @
1d3f74db
...
...
@@ -18,6 +18,7 @@
#
import
os
import
re
from
unittest
import
mock
import
pytest
...
...
@@ -425,3 +426,66 @@ def test_extract_expiry(cli, datafiles, tmpdir):
assert
os
.
path
.
isdir
(
refsdirtarget2
)
assert
not
os
.
path
.
exists
(
refsdirtarget
)
# Ensures that when launching BuildStream with a full artifact cache,
# the cache size and cleanup jobs are run before any other jobs.
#
@pytest.mark.datafiles
(
DATA_DIR
)
def
test_cleanup_first
(
cli
,
datafiles
,
tmpdir
):
project
=
os
.
path
.
join
(
datafiles
.
dirname
,
datafiles
.
basename
)
element_path
=
'
elements
'
cache_location
=
os
.
path
.
join
(
project
,
'
cache
'
,
'
artifacts
'
,
'
ostree
'
)
checkout
=
os
.
path
.
join
(
project
,
'
checkout
'
)
cli
.
configure
({
'
cache
'
:
{
'
quota
'
:
10000000
,
}
})
# Create an element that uses almost the entire cache (an empty
# ostree cache starts at about ~10KiB, so we need a bit of a
# buffer)
create_element_size
(
'
target.bst
'
,
project
,
element_path
,
[],
8000000
)
res
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
'
target.bst
'
])
res
.
assert_success
()
assert
cli
.
get_element_state
(
project
,
'
target.bst
'
)
==
'
cached
'
# Now configure with a smaller quota, create a situation
# where the cache must be cleaned up before building anything else.
#
# Fix the fetchers and builders just to ensure a predictable
# sequence of events (although it does not effect this test)
cli
.
configure
({
'
cache
'
:
{
'
quota
'
:
5000000
,
},
'
scheduler
'
:
{
'
fetchers
'
:
1
,
'
builders
'
:
1
}
})
# Our cache is now more than full, BuildStream
create_element_size
(
'
target2.bst
'
,
project
,
element_path
,
[],
4000000
)
res
=
cli
.
run
(
project
=
project
,
args
=
[
'
build
'
,
'
target2.bst
'
])
res
.
assert_success
()
# Find all of the activity (like push, pull, fetch) lines
results
=
re
.
findall
(
r
'
\[.*\]\[.*\]\[\s*(\S+):.*\]\s*START\s*.*\.log
'
,
res
.
stderr
)
# Don't bother checking the order of 'fetch', it is allowed to start
# before or after the initial cache size job, runs in parallel, and does
# not require ResourceType.CACHE.
results
.
remove
(
'
fetch
'
)
print
(
results
)
# Assert the expected sequence of events
assert
results
==
[
'
size
'
,
'
clean
'
,
'
build
'
]
# Check that the correct element remains in the cache
states
=
cli
.
get_element_states
(
project
,
[
'
target.bst
'
,
'
target2.bst
'
])
assert
states
[
'
target.bst
'
]
!=
'
cached
'
assert
states
[
'
target2.bst
'
]
==
'
cached
'
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