Commit Graph

33 Commits

Author SHA1 Message Date
John Mulligan 7dea1f728f cephfs: add function ParseDefaultConfigEnv to set ceph config from env
Similar to the rados function of the same name, ParseDefaultConfigEnv
uses the environment to configure the cephfs mount.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
John Mulligan c34501fc6a cephfs: add a ParseConfigArgv function
The ParseConfigArgv behaves similarly to the same named function in
rados. The command line argv value is parsed by ceph libs and used to
configure the mount object.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-07-24 09:54:04 -04:00
muagarwa fa7300fff8 cephfs: Validate mount.mount usage in cephfs/path.go
ceph MountInfo pointer is being passed in the functions without a validation check, if it is nil there may be a crash. Fixed the functions to first validate mount.mount

Signed-off-by: Mudit Agarwal muagarwa@redhat.com
2020-05-06 10:04:43 -04:00
John Mulligan 5aadca02bf cephfs: split basic permissions related funcs into new files
Continue organizing the cephfs functionality by creating new files
for chmod and chown functionality.
Similarly, the dedicated test functions for those items are moved
into a new file as well.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-17 13:40:01 -04:00
John Mulligan bbf5fecf90 cephfs: split basic path management funcs into new files
Continue organizing the cephfs functionality by creating new files
for the most basic path management functions:
  MakeDir, RemoveDir, ChangeDir, CurrentDir
Similarly, the dedicated test functions for those items are moved into
a new file as well.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-17 13:40:01 -04:00
John Mulligan ce64ef536a cephfs: split (mds) command functions and tests into new files
Start organizing some of the cephfs functionality into functions grouped
by files by moving the MDS command functions into a new file. Move the
tests dedicated to those functions into a new matching file too.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-17 13:40:01 -04:00
John Mulligan 673c60bc51 cephfs: have test cases remove dirs they create
To prevent test failures re-reunning the suite against the same fs we
need to make sure tests clean up after themselves.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-15 14:22:30 +02:00
John Mulligan f584aef60f cephfs: consolidate error types & values in an errors.go file
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 17:10:09 -04:00
John Mulligan 2ad8361692 cephfs: make the Release function more idempotent to callers
Previously, calling Release more than once for the same MountInfo would
abort due to a double free in the ceph libs. As this is somewhat user
hostile we add some simple state tracking in our wrapper type such that
one can make redundant calls to Release without crashing the
application.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan 4277d40137 cephfs: remove directory created in the ChangeDir test
The test function that exercises ChangeDir was creating a directory
and leaving it behind. Add some basic cleanup to the test to try
and avoid leaking stuff between test runs.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan 36196c5e60 cephfs: release fs resources in remaining test cases
In a previous commit we added fsDisconnect to match with fsConnect.  For
tests that do not use fsConnect but still acquire resources we need to
free up those resources with direct calls to the appropriate functions.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan 1842ad248d cephfs: pair fsConnect with a fsDisconnect function
For every (most?) call to fsConnect we should pair it with a (deferred)
call to fsDisconnect to close connection and release resources
associated with the mount object we have created for the test.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan bdee9f4aab cephfs: TestMountWithRoot should only try unmounting after mounting
The defer function in TestMountWithRoot was always trying to call
unmount before release. This is not correct if the fs was not mounted
so we reorganize this code to more closely match what should be done
in normal practice.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan 6a08124775 cephfs: TestCreateMount should not try to mount twice
Somehow we managed to introduce extra code into TestCreateMount that
had it create two mounts. This is undesirable for this test so this
change eliminates the extra unwanted invocation.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan ab178bc7ed cephfs: allow passing mds name into test through env var
Previously, the mds name was hardcoded in the tests to match that set up
by "micro-osd.sh". We continue to default to that value, but allow the
test to be supplied a custom value by the environment.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan 0b658baebf cephfs: restrict running of tests that need a mounted fs instance
Add a utility function to test cases that expect the cephfs file system
to be mounted locally and accessible.
Add environment vars to configure the location of the mount point as
well whether the function causes the test to be skipped (the default)
or force an early but clear failure.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-04-06 16:29:26 -04:00
John Mulligan 33422fc2cb cephfs: add SetConfigOption and GetConfigOption functions
These are implemented similarly to the rados equivalents.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-03-10 08:15:16 +01:00
John Mulligan 8948b20f5a cephfs: add MountWithRoot to implement the root arg to ceph_mount
The existing Mount() method did not provide a way to access the root
path argument to ceph_mount. This new function allows the caller to
specify an alternate root dir for the mount.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-24 10:18:48 +01:00
John Mulligan 2240c56614 cephfs: update TestCreateMountWithId to check custom id is used
Now that we have mds command function, we can use it to check for the id
we passed to CreateMountWithId appears in the session list.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 14:01:33 +01:00
John Mulligan 34f1507992 cephfs: add wrapper funcs for ceph_mds_command
Adding a wrapper for ceph_mds_command allows the client to make
queries against the mds server.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-02-11 14:01:33 +01:00
John Mulligan c433abf787 cephfs: allow creating mount with an id
The ceph api function supports passing a string to identify the
client doing the mount. Expose that aspect of the api with a
new function CreateMountWithId.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-28 08:52:51 +01:00
John Mulligan 296c551613 cephfs: test creating a cephfs mount from a rados Conn
Verify the cephfs CreateFromRados function.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-27 18:30:10 +01:00
John Mulligan b177121473 cephfs: replace tests mount setup boilerplate with func
In the cephfs tests the setup of the mount/connection was largely being
done as a copy-n-paste. This change adds a common setup function for
most of the test cases that need an active connection.
Similar to other recent changes this also adds a timeout such that
if the test fails to get a connection it will fail quickly rather
than block forever.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2020-01-20 16:52:45 +01:00
John Mulligan 4589af9dfd cephfs: fix linting errors found in cephfs_test.go
Now that cephfs_test.go is part of the cephfs package, the linter is
checking it and finding errors. Fix them.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 16:59:25 +01:00
John Mulligan 73753d5482 cephfs: test error type and error handling functions
Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 16:59:25 +01:00
John Mulligan 9f46b4621b cephfs: include cephfs_test.go in cephfs package
This will allow us to test private functions from the cephfs package
int our test file.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
2019-12-16 16:59:25 +01:00
Sven Anderson 472f6dd5bb Tests: avoid segmentation faults in tests
This change replaces a couple of functions from the "assert" package
with the corresponding functions from the "require", where the
following code relies on a non-nil object.

Signed-off-by: Sven Anderson <sven@redhat.com>
2019-12-06 11:12:34 -05:00
Lincoln Thurlow ecf9a99249 cephfs: add unmount, release, chmod, chown, etc
This commit adds the following cephfs functions:

* Unmount // Unmounting is necessary to cleanup mounts
* Release // Release destroys the cmount ~ end of transaction
* RemoveDir // inverse of MakeDir
* Chown // change ownership of file or directory
* Chmod // change permissions of file or directory

Tests are included for each function.

In addition to these changes modifications to:

.travis.yml, Dockerfile, and Makefile

were made to accomodate tests to mount the ceph volume.  Tests use
fuse to mount the volume which requires adding:

--device /dev/fuse --cap-add SYS_ADMIN --security-opt \
apparmor:unconfined

to the docker container (alternatively --privileged works but adds
additional permissions).

Changes to README add the above docker changes as well as point
users to the necessary ceph development libraries.
2018-10-11 11:09:16 -07:00
Lincoln Thurlow f3df337fab cephfs: add cephfs commands, expand logging
* CephError uses syscall for string version of error
* Add error logging for every function
* Add RemoveDir() function
* Add Unmount() function
* Add Release() function
* Add Chown() function
* Add Chmod() function
2018-10-11 11:09:16 -07:00
Noah Watkins 3f52ea219a repo: update new repo path
noahdesu -> ceph

Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2015-08-31 07:34:42 -07:00
Abhishek Lekshmanan d63c6698c2 gofmt all the source files
Running gofmt ./... on the repository

Signed-off-by: Abhishek Lekshmanan <abhishek.lekshmanan@gmail.com>
2015-07-08 14:04:54 +05:30
Noah Watkins 0f4cf26919 cephfs: add mkdir
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2015-05-01 12:57:07 -07:00
Noah Watkins 1efdf980f0 cephfs: begin cephfs wrappers
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
2015-05-01 12:41:47 -07:00