Skip to content

Commit

Permalink
Merge pull request #3 from ECP-VeloC/github_greg_branch
Browse files Browse the repository at this point in the history
added gitlab testing infrastructure to the test
  • Loading branch information
CamStan authored Jul 27, 2019
2 parents 4c1bd39 + 6c448b8 commit 4a70534
Show file tree
Hide file tree
Showing 8 changed files with 364 additions and 13 deletions.
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
job:
tags:
- quartz
- shell
script:
- module load cmake/3.9.2
- cmake -DWITH_KVTREE_PREFIX=$HOME/kvtree/KVTree.git/install -DWITH_SPATH_PREFIX=$HOME/spath/install -DWITH_AXL_PREFIX=$HOME/axl/AXL.git/install -DMPI=ON
- make VERBOSE=1
- make check
114 changes: 114 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
langauge: c
dist: trusty

compiler:
- gcc
- clang

matrix:
include:
- name: "GCC 4.9"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libopenmpi-dev
- openmpi-bin
- g++-4.9
env :
- MATRIX_EVAL="CC=gcc-4.9 && CXX=g++-4.9"

- name: "GCC 6"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libopenmpi-dev
- openmpi-bin
- g++-6
env :
- MATRIX_EVAL="CC=gcc-6 && CXX=g++-6"

- name: "GCC 7"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libopenmpi-dev
- openmpi-bin
- g++-7
env :
- MATRIX_EVAL="CC=gcc-7 && CXX=g++-7"

- name: "GCC 8"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libopenmpi-dev
- openmpi-bin
- g++-8
env :
- MATRIX_EVAL="CC=gcc-8 && CXX=g++-8"

- name: "Clang 4.0"
addons:
apt:
sources:
- llvm-toolchain-trusty-4.0
packages:
- libopenmpi-dev
- openmpi-bin
- clang-4.0
env :
- MATRIX_EVAL="CC=clang-4.0 && CXX=clang++-4.0"

- name: "Clang 6.0"
addons:
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-trusty-6.0
packages:
- libopenmpi-dev
- openmpi-bin
- clang-6.0
env :
- MATRIX_EVAL="CC=clang-6.0 && CXX=clang++-6.0"

before_install:
- eval "${MATRIX_EVAL}"
- mkdir $HOME/deps-install
- git clone https://github.com/ECP-VeloC/KVTree.git $HOME/KVTree
- mkdir $HOME/KVTree/kvtree-build
- cd $HOME/KVTree/kvtree-build
- cmake .. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$HOME/deps-install -DMPI=ON
- make
- make install
- git clone https://github.com/ECP-VeloC/AXL.git $HOME/AXL
- mkdir $HOME/AXL/axl-build
- cd $HOME/AXL/axl-build
- cmake .. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$HOME/deps-install -DMPI=ON -DWITH_KVTREE_PREFIX=$HOME/deps-install
- make
- make install
- git clone https://github.com/ECP-VeloC/spath.git $HOME/spath
- mkdir $HOME/spath/spath-build
- cd $HOME/spath/spath-build
- cmake .. -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_INSTALL_PREFIX=$HOME/deps-install -DMPI=ON
- make
- make install

script:
- cd $TRAVIS_BUILD_DIR
- cmake -DCMAKE_C_COMPILER=$CC -DCMAKE_CXX_COMPILER=$CXX -DCMAKE_C_FLAGS="-Wall -coverage" -DMPI=ON -DWITH_KVTREE_PREFIX=$HOME/deps-install -DWITH_AXL_PREFIX=$HOME/deps-install -DWITH_SPATH_PREFIX=$HOME/deps-install
- make -k VERBOSE=1
- make check

after_failure:
- find . -type f -name "CMakeOutput.log" -execdir cat {} \;
- find . -type f -name "CMakeError.log" -execdir cat {} \;
- find . -type f -name "CMakeCache.txt" -execdir cat {} \;
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ INCLUDE(GNUInstallDirs)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/src)
ADD_SUBDIRECTORY(src)

# INCLUDE(CTest)
# ADD_SUBDIRECTORY(test)
INCLUDE(CTest)
ADD_SUBDIRECTORY(test)

# Generate config.h with all our build #defs
CONFIGURE_FILE(${PROJECT_SOURCE_DIR}/cmake/config.h.in ${PROJECT_BINARY_DIR}/config.h)
Expand Down
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Filo

[![Build Status](https://api.travis-ci.org/ECP-VeloC/filo.png?branch=master)](https://travis-ci.org/ECP-VeloC/filo)

This module uses AXL to transfer files between local storage and a global file system.
The transfer from local storage to global storage is called a "flush" and the reverse transfer is called a "fetch".
During a flush, filo associates each file with its owner MPI rank, and it records this association in a metadata file.
Expand Down Expand Up @@ -47,13 +50,17 @@ To build dependencies:

To build filo:

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=./install -DWITH_KVTREE_PREFIX=`pwd`/install -DWITH_AXL_PREFIX=`pwd`/install .
cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=./install -DWITH_KVTREE_PREFIX=`pwd`/install -DWITH_AXL_PREFIX=`pwd`/install -DWITH_SPATH_PREFIX=`pwd`/install .
make
make install

# Testing
Some simple test programs exist in the test directory.

All the tests can be run with:

make check

To build a test for the filo API:

mpicc -g -O0 -o test_filo test_filo.c -I../install/include -L../install/lib64 -I../src -L../src -lkvtree -laxl -lspath -lfilo
Expand Down
25 changes: 25 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
###############
# Build tests
###############

################
# Add tests to ctest
################

ADD_EXECUTABLE(filo_test test_filo.c)
TARGET_LINK_LIBRARIES(filo_test ${SPATH_EXTERNAL_LIBS} filo)
ADD_TEST(NAME filo_test COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ./filo_test)

ADD_EXECUTABLE(filo_corrupt_fetch_test test_filo_corrupt_fetch.c)
TARGET_LINK_LIBRARIES(filo_corrupt_fetch_test ${SPATH_EXTERNAL_LIBS} filo)
ADD_TEST(NAME filo_corrupt_fetch_test COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ./filo_corrupt_fetch_test)

ADD_EXECUTABLE(filo_async_test test_filo_async.c)
TARGET_LINK_LIBRARIES(filo_async_test ${SPATH_EXTERNAL_LIBS} filo)
ADD_TEST(NAME filo_async_test COMMAND ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} 3 ./filo_async_test)

####################
# make a verbose "test" target named "check"
####################

ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND} --verbose)
47 changes: 37 additions & 10 deletions test/test_filo.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,59 +12,86 @@
#include "mpi.h"
#include "filo.h"

#define TEST_PASS (0)
#define TEST_FAIL (1)

int main(int argc, char* argv[])
{
int rc = TEST_PASS;
MPI_Init(&argc, &argv);

int rank, ranks;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &ranks);

char buf[256];
sprintf(buf, "data from rank %d\n", rank);

char proc_specific_file_content[256];
sprintf(proc_specific_file_content, "data from rank %d\n", rank);
char filename[256];
sprintf(filename, "/dev/shm/testfile_%d.out", rank);
int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
if (fd != -1) {
write(fd, buf, strlen(buf));
write(fd, proc_specific_file_content, strlen(proc_specific_file_content));
close(fd);
} else {
rc = TEST_FAIL;
printf("Error opening file %s: %d %s\n", filename, errno, strerror(errno));
}

char dest_filename[256];
sprintf(dest_filename, "./testfile_%d.out", rank);

Filo_Init();
rc = Filo_Init();

const char* filelist[1] = { filename };
const char* dest_filelist[1] = { dest_filename };

Filo_Flush("mapfile", NULL, 1, filelist, dest_filelist, MPI_COMM_WORLD);
/* base path for storage is NULL, so destination files will be written to the local dir*/
rc = Filo_Flush("mapfile", NULL, 1, filelist, dest_filelist, MPI_COMM_WORLD);

unlink(filename);

/* fetch list of files recorded in mapfile to /dev/shm */
int num_files;
char** src_filelist;
char** dst_filelist;
Filo_Fetch("mapfile", NULL, "/dev/shm", &num_files, &src_filelist, &dst_filelist, MPI_COMM_WORLD);
/* src base path is still NULL (consistent with Filo_Flush), but the dest base path is /dev/shm*/
rc = Filo_Fetch("mapfile", NULL, "/dev/shm", &num_files, &src_filelist, &dst_filelist, MPI_COMM_WORLD);

/* free file list returned by fetch */
int i;
for (i = 0; i < num_files; i++) {
//in file name, rank precedes ".out" suffix
int rank_from_file_name = *((strstr(dst_filelist[i], ".out"))-1) - '0';
//assertain that the filename with consistant process marker was passed through flush/fetch
if(rank != rank_from_file_name){
rc = TEST_FAIL;
printf("rank = %d, rank_from_file_name = %d\n", rank, rank_from_file_name);
}
//assertain that the file content is consistent with the process
FILE *file = fopen(dst_filelist[i], "r");
char *readContent = NULL;
size_t readContent_size = 0;
if (!file){
rc = TEST_FAIL;
printf("Error opening file %s: %d %s\n", dst_filelist[i], errno, strerror(errno));
}
size_t line_size = getline(&readContent, &readContent_size, file);
if (strcmp(readContent, proc_specific_file_content) != 0){
rc = TEST_FAIL;
printf("flushed file content = %s, fetched file content = %s\n", proc_specific_file_content, readContent);
}

fclose(file);
free(src_filelist[i]);
free(dst_filelist[i]);
}
free(src_filelist);
free(dst_filelist);

Filo_Finalize();
rc = Filo_Finalize();

unlink(filename);

MPI_Finalize();

return 0;
return rc;
}
99 changes: 99 additions & 0 deletions test/test_filo_async.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include <stdlib.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

#include <limits.h>
#include <unistd.h>

#include "mpi.h"
#include "filo.h"

#define TEST_PASS (0)
#define TEST_FAIL (1)

int main(int argc, char* argv[])
{
int rc = TEST_PASS;
MPI_Init(&argc, &argv);
int rank, ranks;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &ranks);

char proc_specific_file_content[256];
sprintf(proc_specific_file_content, "data from rank %d\n", rank);
char filename[256];
sprintf(filename, "/dev/shm/testfile_%d.out", rank);
int fd = open(filename, O_WRONLY | O_TRUNC | O_CREAT, S_IRUSR | S_IWUSR);
if (fd != -1) {
write(fd, proc_specific_file_content, strlen(proc_specific_file_content));
close(fd);
} else {
rc = TEST_FAIL;
printf("Error opening file %s: %d %s\n", filename, errno, strerror(errno));
}

char dest_filename[256];
sprintf(dest_filename, "./testfile_%d.out", rank);

rc = Filo_Init();

const char* filelist[1] = { filename };
const char* dest_filelist[1] = { dest_filename };

/* base path for storage is NULL, so destination files will be written to the local dir*/
rc = Filo_Flush_start("mapfile", NULL, 1, filelist, dest_filelist, MPI_COMM_WORLD);
rc = Filo_Flush_test("mapfile", MPI_COMM_WORLD);
rc = Filo_Flush_wait("mapfile", MPI_COMM_WORLD);

unlink(filename);

/* fetch list of files recorded in mapfile to /dev/shm */
int num_files;
char** src_filelist;
char** dst_filelist;
/* src base path is still NULL (consistent with Filo_Flush), but the dest base path is /dev/shm*/
rc = Filo_Fetch("mapfile", NULL, "/dev/shm", &num_files, &src_filelist, &dst_filelist, MPI_COMM_WORLD);

/* free file list returned by fetch */
int i;
for (i = 0; i < num_files; i++) {
//in file name, rank precedes ".out" suffix
int rank_from_file_name = *((strstr(dst_filelist[i], ".out"))-1) - '0';
//assertain that the filename with consistant process marker was passed through flush/fetch
if(rank != rank_from_file_name){
rc = TEST_FAIL;
printf("rank = %d, rank_from_file_name = %d\n", rank, rank_from_file_name);
}
//assertain that the file content is consistent with the process
FILE *file = fopen(dst_filelist[i], "r");
char *readContent = NULL;
size_t readContent_size = 0;
if (!file){
rc = TEST_FAIL;
printf("Error opening file %s: %d %s\n", dst_filelist[i] , errno, strerror(errno));
}
size_t line_size = getline(&readContent, &readContent_size, file);
if (strcmp(readContent, proc_specific_file_content) != 0){
rc = TEST_FAIL;
printf("flushed file content = %s, fetched file content = %s\n", proc_specific_file_content, readContent);
}
fclose(file);

free(src_filelist[i]);
free(dst_filelist[i]);
}
free(src_filelist);
free(dst_filelist);

rc = Filo_Finalize();

unlink(filename);

MPI_Finalize();

return rc;
}
Loading

0 comments on commit 4a70534

Please sign in to comment.