New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tests: new test for cifs-mount interface #5714
tests: new test for cifs-mount interface #5714
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good. Some comments inline.
snap install test-snapd-cifs-mount | ||
|
||
# Create linux and samba users | ||
sudo useradd -s /bin/true test-cifs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The tests are executed by root anyway, no need to use sudo.
|
||
# Configure samba | ||
cp /etc/samba/smb.conf /etc/samba/smb.conf.back | ||
echo "[data]" >> /etc/samba/smb.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should work too:
[data]
path=$(pwd)/local_share
writable=yes
browsable=yes
shellcheck will probably suggest something like this:
(echo "[data]"
echo "path=$(pwd)/local_share"
echo "writable=yes"
echo "browsable=yes" ) > /etc/samba/smb.conf
echo "browsable=yes" >> /etc/samba/smb.conf | ||
|
||
systemctl restart smbd.service | ||
systemctl restart nmbd.service |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need to touch nmbd
, IIRC it's only used for NetBIOS name resolution and shouldn't matter here.
snap connect test-snapd-cifs-mount:cifs-mount | ||
|
||
echo "Then the snap is able to mount and umount a cifs fs" | ||
test-snapd-cifs-mount.sh -c "mount -t cifs //127.0.0.1/data /var/snap/test-snapd-cifs-mount/current/local_mount -o user=test-cifs,passowrd=test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thin this line and ones below should use $SNAP_DATA
, eg:
test-snapd-cifs-mount.sh -c "mount -t cifs //127.0.0.1/data \$SNAP_DATA/local_mount -o user=test-cifs,passowrd=test"
snap connect test-snapd-cifs-mount:cifs-mount | ||
|
||
echo "Then the snap is able to mount and umount a cifs fs" | ||
test-snapd-cifs-mount.sh -c "mount -t cifs //127.0.0.1/data /var/snap/test-snapd-cifs-mount/current/local_mount -o user=test-cifs,passowrd=test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And you probably need to mkdir the mount point first too:
test-snapd-cifs-mount.sh -c "mkdir \$SNAP_DATA/local_mount"
@bboozzoo thanks for reviewing this, all the commest have been addressed. |
Maybe the interface should add (u)mount to the interface?
Otherwise when you have for eg. a simple Python app, you cannot really use the interface unless you poke the libc via ctypes or somesuch. @zyga @jdstrand wdyt? |
@bboozzoo This interface is paired with mount-observe to have access to reading the current mounts. @sergiocazzolato You'll probably need that too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments, and LGTM once you're happy about their consideration.
|
||
# Configure samba | ||
cp /etc/samba/smb.conf /etc/samba/smb.conf.back | ||
{ echo "[data]"; echo "path=$(pwd)/local_share"; echo "writable=yes"; echo "browsable=yes"; } >> /etc/samba/smb.conf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ echo -e "foo\nbar"
foo
bar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
apps: | ||
sh: | ||
command: sh | ||
plugs: [cifs-mount] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably needs mount-observe, per comments.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@niemeyer , thanks for reviewing this. I tried by adding the mount-observe plug but still having the same denial. testlog: https://paste.ubuntu.com/p/X56wt4CHrw/
The cifs-mount interface allows mounting and unmounting CIFS filesystems. | ||
|
||
prepare: | | ||
snap install test-snapd-cifs-mount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be installing the local snap?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I need some dependencies as part of this snap, I had to create a snap and upload it to the store.
|
||
execute: | | ||
echo "The interface is not connected by default" | ||
snap interfaces -i cifs-mount | MATCH -- '^- +test-snapd-cifs-mount:cifs-mount' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the --?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not strictly needed here because '^..
will be detected as part of the pattern and handled porperly. However, the pattern MATCH '- +test..'
will fail because '-
will be seen as a -foo
switch. So it's either MATCH -- <pattern>
. We could use grep .. -e
switch which makes grep expec <pattern>
as the next argument.
We're not even getting that far. The problem is that currently the only way of doing the mount is via
Edit: and sorry for accidentally closing the PR, I've clicked the wrong button. |
Can't we call |
@chipaca, in the test we are already using mount.cifs.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
It looks like we need to patch the test to install another package @sergiocazzolato |
|
This is now failing on:
@sergiocazzolato can you look at this next week please. Feels like we are missing something :) |
It is blocked until we find a solution for the denial trying to access to /run/mount/utab |
Closeing the PR until a solution to the denial is found |
No description provided.