summaryrefslogtreecommitdiffstats
path: root/src/script/gen-corpus.sh
blob: ad2ef09f1a17f5515358ec52734cd1a6bf246c39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env bash
# -*- mode:sh; tab-width:4; sh-basic-offset:4; indent-tabs-mode:nil -*-
# vim: softtabstop=4 shiftwidth=4 expandtab

set -ex

function get_jobs() {
    local jobs=$(nproc)
    if [ $jobs -ge 8 ] ; then
        echo 8
    else
        echo $jobs
    fi
}

[ -z "$BUILD_DIR" ] && BUILD_DIR=build

function build() {
    local encode_dump_path=$1
    shift

    ./do_cmake.sh \
        -DWITH_MGR_DASHBOARD_FRONTEND=OFF \
        -DWITH_DPDK=OFF \
        -DWITH_SPDK=OFF \
        -DCMAKE_CXX_FLAGS="-DENCODE_DUMP_PATH=${encode_dump_path}"
    cd ${BUILD_DIR}
    cmake --build . -- -j$(get_jobs)
}

function run() {
    MON=3 MGR=2 OSD=3 MDS=3 RGW=1 ../src/vstart.sh -n -x

    local old_path="$PATH"
    export PATH="bin:$PATH"
    ceph osd pool create mypool
    rados -p mypool bench 10 write -b 123
    ceph osd out 0
    ceph osd in 0
    init-ceph restart osd.1
    for f in ../qa/workunits/cls/*.sh ; do
        $f
    done
    ../qa/workunits/rados/test.sh
    ceph_test_librbd
    ceph_test_libcephfs
    init-ceph restart mds.a
    ../qa/workunits/rgw/run-s3tests.sh
    PATH="$old_path"

    ../src/stop.sh
}

function import_corpus() {
    local encode_dump_path=$1
    shift
    local version=$1
    shift

    # import the corpus
    ../src/test/encoding/import.sh \
        ${encode_dump_path} \
        ${version} \
        ../ceph-object-corpus/archive
    ../src/test/encoding/import-generated.sh \
        ../ceph-object-corpus/archive
    # prune it
    pushd ../ceph-object-corpus
    bin/prune-archive.sh
    popd
}

function verify() {
    ctest -R readable.sh
}

function commit_and_push() {
    local version=$1
    shift

    pushd ../ceph-object-corpus
    git checkout -b wip-${version}
    git add archive/${version}
    git commit --signoff --message=${version}
    git remote add cc git@github.com:ceph/ceph-object-corpus.git
    git push cc wip-${version}
    popd
}

encode_dump_path=$(mktemp -d)
build $encode_dump_path
echo "generating corpus objects.."
run
version=$(bin/ceph-dencoder version)
echo "importing corpus. it may take over 30 minutes.."
import_corpus $encode_dump_path $version
echo "verifying imported corpus.."
verify
echo "all good, pushing to remote repo.."
commit_and_push ${version}
rm -rf encode_dump_path