Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-fuse
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Platform
Development
swh-fuse
Commits
ac417369
Commit
ac417369
authored
2 months ago
by
Martin Kirchgessner
Browse files
Options
Downloads
Patches
Plain Diff
launch test-fuse in a thread so we can see its potential exceptions
parent
83814b7b
No related branches found
Branches containing commit
No related tags found
1 merge request
!93
New configuration option: use a compressed graph to build the folder structure
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
swh/fuse/tests/conftest.py
+39
-45
39 additions, 45 deletions
swh/fuse/tests/conftest.py
with
39 additions
and
45 deletions
swh/fuse/tests/conftest.py
+
39
−
45
View file @
ac417369
...
...
@@ -3,17 +3,18 @@
# License: GNU General Public License version 3, or any later version
# See top-level LICENSE file for more information
import
asyncio
import
json
from
multiprocessing
import
Process
import
os
from
pathlib
import
Path
from
tempfile
import
NamedTemporaryFile
,
TemporaryDirectory
from
tempfile
import
TemporaryDirectory
import
threading
import
time
from
click.testing
import
CliRunner
import
pytest
import
yaml
from
swh.fuse
import
fuse
import
swh.fuse.cli
as
cli
from
swh.fuse.tests.data.api_data
import
API_URL
,
MOCK_ARCHIVE
...
...
@@ -36,49 +37,42 @@ def web_api_mock(requests_mock):
@pytest.fixture
def
fuse_mntdir
(
web_api_mock
):
tmpdir
=
TemporaryDirectory
(
suffix
=
"
.swh-fuse-test
"
)
with
TemporaryDirectory
(
suffix
=
"
.swh-fuse-test
"
)
as
tmpdir
:
mountpoint
=
Path
(
tmpdir
)
config
=
{
"
cache
"
:
{
"
metadata
"
:
{
"
in-memory
"
:
True
},
"
blob
"
:
{
"
in-memory
"
:
True
},
"
direntry
"
:
{
"
maxram
"
:
"
10%
"
},
},
"
web-api
"
:
{
"
url
"
:
API_URL
,
"
auth-token
"
:
None
},
"
json-indent
"
:
None
,
}
config
=
{
"
cache
"
:
{
"
metadata
"
:
{
"
in-memory
"
:
True
},
"
blob
"
:
{
"
in-memory
"
:
True
},
},
"
web-api
"
:
{
"
url
"
:
API_URL
,
"
auth-token
"
:
None
},
"
json-indent
"
:
None
,
}
def
mount
():
loop
=
asyncio
.
new_event_loop
()
try
:
loop
.
run_until_complete
(
fuse
.
main
([],
mountpoint
,
config
))
finally
:
if
loop
.
is_running
():
loop
.
stop
()
loop
.
close
()
# Run FUSE in foreground mode but in a separate process, so it does not
# block execution and remains easy to kill during teardown
def
fuse_process
(
mntdir
:
Path
):
with
NamedTemporaryFile
(
suffix
=
"
.swh-fuse-test.yml
"
)
as
tmpfile
:
config_path
=
Path
(
tmpfile
.
name
)
config_path
.
write_text
(
yaml
.
dump
(
config
))
CliRunner
().
invoke
(
cli
.
fuse
,
args
=
[
"
--config-file
"
,
str
(
config_path
),
"
mount
"
,
str
(
mntdir
),
"
--foreground
"
,
],
)
mount_thread
=
threading
.
Thread
(
target
=
mount
)
mount_thread
.
start
()
fuse
=
Process
(
target
=
fuse_process
,
args
=
[
Path
(
tmpdir
.
name
)])
fuse
.
start
()
# Wait max 3 seconds for the FUSE to correctly mount
for
i
in
range
(
30
):
try
:
root
=
os
.
listdir
(
tmpdir
.
name
)
if
root
:
break
except
FileNotFoundError
:
pass
time
.
sleep
(
0.1
)
else
:
raise
FileNotFoundError
(
f
"
Could not mount FUSE in
{
tmpdir
.
name
}
"
)
yield
Path
(
tmpdir
.
name
)
for
i
in
range
(
30
):
try
:
root
=
os
.
listdir
(
tmpdir
)
if
root
:
break
except
FileNotFoundError
:
pass
time
.
sleep
(
0.1
)
else
:
raise
FileNotFoundError
(
f
"
Could not mount FUSE in
{
tmpdir
}
"
)
CliRunner
().
invoke
(
cli
.
umount
,
[
tmpdir
.
name
])
fuse
.
join
()
try
:
yield
mountpoint
finally
:
CliRunner
().
invoke
(
cli
.
umount
,
[
tmpdir
])
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