diff options
author | Michael Scherle | 2022-08-04 16:40:28 +0200 |
---|---|---|
committer | Simon Rettberg | 2024-05-13 18:25:14 +0200 |
commit | 300dbe37c5499c98189aad2ab4591840fd5c279c (patch) | |
tree | 1078c1c202faafbde360f3e0b334e6a580d02860 | |
parent | [FUSE] basic cow implementation & rudimentary tests (diff) | |
download | dnbd3-300dbe37c5499c98189aad2ab4591840fd5c279c.tar.gz dnbd3-300dbe37c5499c98189aad2ab4591840fd5c279c.tar.xz dnbd3-300dbe37c5499c98189aad2ab4591840fd5c279c.zip |
added github ci for fuse with cow
-rw-r--r-- | .github/workflows/elefant.yml | 114 | ||||
-rw-r--r-- | src/fuse/cowDoc/readme.md | 2 | ||||
-rw-r--r-- | src/fuse/cowfile.c | 21 |
3 files changed, 131 insertions, 6 deletions
diff --git a/.github/workflows/elefant.yml b/.github/workflows/elefant.yml new file mode 100644 index 0000000..db44a63 --- /dev/null +++ b/.github/workflows/elefant.yml @@ -0,0 +1,114 @@ +name: test fuse cow +on: push +jobs: + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup dotnet + uses: actions/setup-dotnet@v2 + with: + dotnet-version: '5.x.x' + + - name: Install dnbd3 dependencies + working-directory: ${{ github.workspace }} + run: | + sudo apt-get update -y -qq + sudo apt-get install -y -qq make \ + clang-format \ + linux-headers-generic \ + libfuse-dev \ + libjansson-dev \ + libcurl4-openssl-dev \ + rpm + - name: Configure dnbd3 build + run: | + cmake -B ${{ github.workspace }}/build \ + -S ${{ github.workspace }} \ + -D CMAKE_BUILD_TYPE=${{ matrix.config.build-type }} \ + -D DNBD3_KERNEL_MODULE=OFF \ + -D DNBD3_BENCHMARK=OFF \ + -D DNBD3_SERVER_FUSE=OFF \ + -D DNBD3_SERVER=ON \ + -D DNBD3_SERVER_FUSE=ON \ + -D DNBD3_CLIENT_FUSE_COW_TEST=ON \ + -D DNBD3_RELEASE_HARDEN=OFF + + - name: Build dnbd3 artifacts + working-directory: ${{ github.workspace }}/build + run: make + - name: Get cow_merger_service + working-directory: ${{ github.workspace }} + run: git clone --depth 1 --branch "master" "https://github.com/z0Kng/cow_merger_service.git" "../cow_server" + - name: Build cow_merger_service + working-directory: ${{ github.workspace }}/../cow_server/cow_merger_service + run: dotnet build cow_merger_service.csproj --runtime linux-x64 + - name: Setup cow_merger_service + working-directory: ${{ github.workspace }}/../cow_server/ + run: | + mkdir /home/runner/work/WorkingDirectory + mkdir /home/runner/work/OriginalImageDirectory + mkdir /home/runner/work/Output + sed -i 's/^ "WorkingDirectory":.*/ "WorkingDirectory": "\/home\/runner\/work\/WorkingDirectory",/g' cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json + sed -i 's/^ "OriginalImageDirectory":.*/ "OriginalImageDirectory": "\/home\/runner\/work\/OriginalImageDirectory",/g' cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json + sed -i 's/^ "DestinationDirectory":.*/ "DestinationDirectory": "\/home\/runner\/work\/Output",/g' cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json + while read line; do echo $line; done < cow_merger_service/bin/Debug/net5.0/linux-x64/appsettings.json + cd cow_merger_service/bin/Debug/net5.0/linux-x64/ + ./cow_merger_service 2>&1 > log.out & + - name: Generate test file + working-directory: ${{ github.workspace }}/build/src/cowtest + run: ./dnbd3-fuse-cow-test -c /home/runner/work/OriginalImageDirectory/test.r1 + - name: Setup dnbd3 server + working-directory: ${{ github.workspace }} + run: | + mkdir /home/runner/work/dnbd3-server-config/ + cp pkg/config/server.conf /home/runner/work/dnbd3-server-config/ + sed -i "s/^basePath=.*/basePath=\/home\/runner\/work\/OriginalImageDirectory/g" /home/runner/work/dnbd3-server-config/server.conf + cd build/src/server + ./dnbd3-server --config /home/runner/work/dnbd3-server-config/ + sleep 5 + - name: Run standard test + working-directory: ${{ github.workspace }}/build/src + run: | + mkdir /home/runner/work/mount + mkdir /home/runner/work/tmp + ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -c "/home/runner/work/tmp" -C localhost:5000 -y -x 2>&1 > /home/runner/work/tmp/log1.out & + PID=$! + sleep 5 + echo PID: $PID + ./cowtest/dnbd3-fuse-cow-test -t "/home/runner/work/mount/img" + echo unmounting: $PID + sudo umount /home/runner/work/mount + wait $PID + echo unmounted + ./fuse/dnbd3-fuse "/home/runner/work/mount" -f -h localhost -i test -L "/home/runner/work/tmp" -C localhost:5000 -m -y -x 2>&1 > /home/runner/work/tmp/log2.out & + PID=$! + sleep 5 + echo PID: $PID + ./cowtest/dnbd3-fuse-cow-test -v "/home/runner/work/mount/img" + echo unmounting: $PID + sudo umount /home/runner/work/mount + wait $PID + echo unmounted + sleep 30 + echo Output: $(ls /home/runner/work/Output) + ./cowtest/dnbd3-fuse-cow-test -v /home/runner/work/Output/test.r2 + - name: Print logs + if: always() + run: | + echo "====fuse-client status.txt====" + while read line; do echo $line; done < /home/runner/work/tmp/status.txt + echo + echo "====fuse-client log1.out====" + while read line; do echo $line; done < /home/runner/work/tmp/log1.out + echo + echo "====fuse-client log2.out====" + while read line; do echo $line; done < /home/runner/work/tmp/log2.out + echo + echo "====dnbd3-server====" + while read line; do echo $line; done < ${{ github.workspace }}/build/src/server/dnbd3.log + echo + echo "====cow_merger_service====" + while read line; do echo $line; done < ${{ github.workspace }}/../cow_server/cow_merger_service/bin/Debug/net5.0/linux-x64/log.out + + diff --git a/src/fuse/cowDoc/readme.md b/src/fuse/cowDoc/readme.md index 9ad7fa2..27b6bc6 100644 --- a/src/fuse/cowDoc/readme.md +++ b/src/fuse/cowDoc/readme.md @@ -24,7 +24,7 @@ A typical use case is updating or adding software to an existing image. - `- L <path>` Similar to `-c <path>`, but instead of creating a new session, an existing one is loaded from the specified path. - `-m` the client requests a merge after the image has been unmounted and all changes have been uploaded. -- `cowStatFile` creates a status file at the same location as the data and meta file. The file contains information about the current session, for more information see [here](#status). +- `--cowStatFile` creates a status file at the same location as the data and meta file. The file contains information about the current session, for more information see [here](#status). - `--cowStatStdout` similar to `--cowStatFile` but the information will be printed in the stdout. Example parameters for creating a new cow session: diff --git a/src/fuse/cowfile.c b/src/fuse/cowfile.c index 965e6f4..f627f88 100644 --- a/src/fuse/cowfile.c +++ b/src/fuse/cowfile.c @@ -819,9 +819,15 @@ bool cowfile_init( char *path, const char *image_Name, uint16_t imageVersion, at } createCowStatsFile( path ); - pthread_create( &tidCowUploader, NULL, &cowfile_uploader, NULL ); + if( pthread_create( &tidCowUploader, NULL, &cowfile_uploader, NULL ) != 0 ) { + logadd( LOG_ERROR, "Could not create cow uploader thread"); + return false; + } if ( statFile || statStdout ) { - pthread_create( &tidStatUpdater, NULL, &cowfile_statUpdater, NULL ); + if(pthread_create( &tidStatUpdater, NULL, &cowfile_statUpdater, NULL ) != 0 ){ + logadd( LOG_ERROR, "Could not create stat updater thread"); + return false; + } } return true; } @@ -929,10 +935,15 @@ bool cowfile_load( char *path, atomic_uint_fast64_t **imageSizePtr, char *server cow.firstL2 = (l2 *)( ( (char *)cow.l1 ) + cow.l1Size ); pthread_mutex_init( &cow.l2CreateLock, NULL ); createCowStatsFile( path ); - pthread_create( &tidCowUploader, NULL, &cowfile_uploader, NULL ); - + if( pthread_create( &tidCowUploader, NULL, &cowfile_uploader, NULL ) != 0 ) { + logadd( LOG_ERROR, "Could not create cow uploader thread"); + return false; + } if ( statFile || statStdout ) { - pthread_create( &tidStatUpdater, NULL, &cowfile_statUpdater, NULL ); + if(pthread_create( &tidStatUpdater, NULL, &cowfile_statUpdater, NULL ) != 0 ){ + logadd( LOG_ERROR, "Could not create stat updater thread"); + return false; + } } return true; |