summaryrefslogtreecommitdiffstats
path: root/src/test/osd/scrubber_test_datasets.cc
blob: 478fd25fe9531d3f2b42d9cc49de47a0c633575c (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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab

/// \file data-sets used by the scrubber unit tests

#include "./scrubber_test_datasets.h"


using namespace ScrubGenerator;
using namespace std::string_literals;

namespace ScrubDatasets {

static RealObj corrupt_object_size(const RealObj& s, [[maybe_unused]] int osdn)
{
  RealObj ret = s;
  ret.data.size = s.data.size + 1;
  return ret;
}

static RealObj corrupt_nothing(const RealObj& s, int osdn)
{
  return s;
}


static CorruptFuncList crpt_funcs_set0 = {{0, &corrupt_nothing}};

CorruptFuncList crpt_funcs_set1 = {{0, &corrupt_object_size},
				   {1, &corrupt_nothing}};


// object with head & two snaps

static hobject_t hobj_ms1{object_t{"hobj_ms1"},
			  "keykey",	// key
			  CEPH_NOSNAP,	// snap_id
			  0,		// hash
			  0,		// pool
			  ""s};		// nspace

SnapsetMockData::CookedCloneSnaps ms1_fn()
{
  std::map<snapid_t, uint64_t> clnsz;
  clnsz[0x20] = 222;
  clnsz[0x30] = 333;

  std::map<snapid_t, std::vector<snapid_t>> clnsn;
  clnsn[0x20] = {0x20};
  clnsn[0x30] = {0x30};

  std::map<snapid_t, interval_set<uint64_t>> overlaps;
  overlaps[0x20] = {};
  overlaps[0x30] = {};
  return {clnsz, clnsn, overlaps};
}

static SnapsetMockData hobj_ms1_snapset{/* seq */ 0x40,
					/* snaps */ {0x30, 0x20},
					/* clones */ {0x20, 0x30},
					ms1_fn};

hobject_t hobj_ms1_snp30{object_t{"hobj_ms1"},
			 "keykey",  // key
			 0x30,	    // snap_id
			 0,	    // hash
			 0,	    // pool
			 ""s};	    // nspace

static hobject_t hobj_ms1_snp20{object_t{"hobj_ms1"},
				"keykey",  // key
				0x20,	   // snap_id
				0,	   // hash
				0,	   // pool
				""s};	   // nspace


ScrubGenerator::RealObjsConf minimal_snaps_configuration{
  /* RealObjsConf::objs */ {

    /* Clone 30  */ {
      ghobject_t{hobj_ms1_snp30, 0, shard_id_t{0}},
      RealData{
	333,
	0x17,
	17,
	21,
	attr_t{/*{"_om1k", "om1v"}, {"om1k", "om1v"},*/ {"om3k", "om3v"}},
	attr_t{{"_at1k", "_at1v"}, {"_at2k", "at2v"}, {"at3k", "at3v"}}},
      &crpt_funcs_set0,
      nullptr},

    /* Clone 20  */
    {ghobject_t{hobj_ms1_snp20, 0, shard_id_t{0}},
     RealData{222,
	      0x17,
	      17,
	      21,
	      attr_t{/*{"_om1k", "om1v"}, {"om1k", "om1v"},*/ {"om3k", "om3v"}},
	      attr_t{{"_at1k", "_at1v"}, {"_at2k", "at2v"}, {"at3k", "at3v"}}},
     &crpt_funcs_set0,
     nullptr},

    /* Head  */
    {ghobject_t{hobj_ms1, 0, shard_id_t{0}},
     RealData{100,
	      0x17,
	      17,
	      21,
	      attr_t{{"_om1k", "om1v"}, {"om1k", "om1v"}, {"om3k", "om3v"}},
	      attr_t{{"_at1k", "_at1v"}, {"_at2k", "at2v"}, {"at3k", "at3v"}}


     },
     &crpt_funcs_set0,
     &hobj_ms1_snapset}}

};

}  // namespace ScrubDatasets