Commit c6dd5ce7 authored by Jean Bez's avatar Jean Bez
Browse files

Include new forwarding test

parent 29fbfd15
Loading
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -52,11 +52,7 @@ constexpr auto use_blocks = false;
} // namespace metadata

namespace rpc {
#ifdef GKFS_ENABLE_FORWARDING
constexpr auto chunksize = 107374182400; // in bytes (e.g., 107374182400 == 100GB)
#else
constexpr auto chunksize = 524288; // in bytes (e.g., 524288 == 512KB)
#endif
//size of preallocated buffer to hold directory entries in rpc call
constexpr auto dirents_buff_size = (8 * 1024 * 1024); // 8 mega
/*
+15 −0
Original line number Diff line number Diff line
@@ -416,11 +416,26 @@ int main(int argc, const char* argv[]) {

    if (vm.count("metadir")) {
        auto metadir = vm["metadir"].as<string>();

        #ifdef GKFS_ENABLE_FORWARDING
        auto metadir_path = bfs::path(metadir) / fmt::format_int(getpid()).str();
        bfs::create_directories(metadir_path);
        GKFS_DATA->metadir(bfs::canonical(metadir_path).native());
        #else
        bfs::create_directories(metadir);
        GKFS_DATA->metadir(bfs::canonical(metadir).native());
        #endif
    } else {
        // use rootdir as metadata dir
        auto metadir = vm["rootdir"].as<string>();

        #ifdef GKFS_ENABLE_FORWARDING
        auto metadir_path = bfs::path(metadir) / fmt::format_int(getpid()).str();
        bfs::create_directories(metadir_path);
        GKFS_DATA->metadir(bfs::canonical(metadir_path).native());
        #else
        GKFS_DATA->metadir(GKFS_DATA->rootdir());
        #endif
    }

    try {
+92 −0
Original line number Diff line number Diff line
@@ -198,3 +198,95 @@ def test_two_io_nodes_remap(gkfwd_daemon_factory, gkfwd_client_factory):
                ion = line.split()[-1]

                assert ion == '1'

def test_two_io_nodes_operations(gkfwd_daemon_factory, gkfwd_client_factory):
    """Write files from one client and read in the other using two daemons"""

    d00 = gkfwd_daemon_factory.create()
    d01 = gkfwd_daemon_factory.create()

    c00 = gkfwd_client_factory.create('c-0')
    c01 = gkfwd_client_factory.create('c-1')

    file = d00.mountdir / "file-c00"

    # create a file in gekkofs
    ret = c00.open(file,
                           os.O_CREAT | os.O_WRONLY,
                           stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

    assert ret.retval == 10000
    assert ret.errno == 115 #FIXME: Should be 0!

    # write a buffer we know
    buf = b'42'
    ret = c00.write(file, buf, len(buf))

    assert ret.retval == len(buf) # Return the number of written bytes
    assert ret.errno == 115 #FIXME: Should be 0!

    # open the file to read
    ret = c00.open(file,
                           os.O_RDONLY,
                           stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

    assert ret.retval == 10000
    assert ret.errno == 115 #FIXME: Should be 0!

    # read the file
    ret = c00.read(file, len(buf))

    assert ret.buf == buf
    assert ret.retval == len(buf) # Return the number of read bytes
    assert ret.errno == 115 #FIXME: Should be 0!

    # open the file to read
    ret = c01.open(file,
                           os.O_RDONLY,
                           stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)

    assert ret.retval == 10000
    assert ret.errno == 115 #FIXME: Should be 0!

    # read the file
    ret = c01.read(file, len(buf))

    assert ret.buf == buf
    assert ret.retval == len(buf) # Return the number of read bytes
    assert ret.errno == 115 #FIXME: Should be 0!

    # the file should be there and accessible by the two clients
    ret = c00.readdir(d00.mountdir)

    assert len(ret.dirents) == 1

    assert ret.dirents[0].d_name == 'file-c00'
    assert ret.dirents[0].d_type == 8 # DT_REG
    assert ret.errno == 115 #FIXME: Should be 0!

    # the file should be there and accessible by the two clients
    ret = c01.readdir(d01.mountdir)

    assert len(ret.dirents) == 1

    assert ret.dirents[0].d_name == 'file-c00'
    assert ret.dirents[0].d_type == 8 # DT_REG
    assert ret.errno == 115 #FIXME: Should be 0!

    with open(c00.log) as f:
        lines = f.readlines()

        for line in lines:
            if 'Forward to' in line:
                ion = line.split()[-1]

                assert ion == '0'

    with open(c01.log) as f:
        lines = f.readlines()

        for line in lines:
            if 'Forward to' in line:
                ion = line.split()[-1]

                assert ion == '1'
 No newline at end of file
+5 −0
Original line number Diff line number Diff line
@@ -619,6 +619,7 @@ class FwdDaemon:
    def run(self):

        args = [ '--mountdir', self.mountdir,
                 '--metadir', self.metadir,
                 '--rootdir', self.rootdir,
                 '-l', self._address ]

@@ -717,6 +718,10 @@ class FwdDaemon:
    def rootdir(self):
        return self._workspace.rootdir

    @property
    def metadir(self):
        return self._workspace.metadir

    @property
    def mountdir(self):
        return self._workspace.mountdir
+5 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ class Workspace:
        self._libdirs = libdirs
        self._logdir = self._twd / 'logs'
        self._rootdir = self._twd / 'root'
        self._metadir = self._twd / 'meta'
        self._mountdir = self._twd / 'mnt'
        self._tmpdir = self._twd / 'tmp'

@@ -76,6 +77,10 @@ class Workspace:
    def rootdir(self):
        return self._rootdir

    @property
    def metadir(self):
        return self._metadir

    @property
    def mountdir(self):
        return self._mountdir