MCPcopy
hub / github.com/NVIDIA/aistore / PrepareObjects

Function PrepareObjects

devtools/tutils/file.go:126–217  ·  view source on GitHub ↗
(t *testing.T, desc ObjectsDesc)

Source from the content-addressed store, hash-verified

124}
125
126func PrepareObjects(t *testing.T, desc ObjectsDesc) *ObjectsOut {
127 var (
128 buf = make([]byte, desc.ObjectSize)
129 fqns = make(map[string][]string, len(desc.CTs))
130 mpathCnts = make(map[string]int, desc.MountpathsCnt)
131
132 bck = cmn.Bck{
133 Name: cos.RandString(10),
134 Provider: apc.ProviderAIS,
135 Ns: cmn.NsGlobal,
136 Props: &cmn.BucketProps{
137 Cksum: cmn.CksumConf{Type: cos.ChecksumXXHash},
138 BID: 0xa5b6e7d8,
139 },
140 }
141 bmd = mock.NewBaseBownerMock((*cluster.Bck)(&bck))
142 tMock cluster.Target
143 )
144
145 mios := mock.NewIOStater()
146 fs.TestNew(mios)
147 fs.TestDisableValidation()
148
149 _ = fs.CSM.Reg(fs.WorkfileType, &fs.WorkfileContentResolver{})
150 _ = fs.CSM.Reg(fs.ObjectType, &fs.ObjectContentResolver{})
151 _ = fs.CSM.Reg(fs.ECSliceType, &fs.ECSliceContentResolver{})
152 _ = fs.CSM.Reg(fs.ECMetaType, &fs.ECMetaContentResolver{})
153
154 dir := t.TempDir()
155
156 for i := 0; i < desc.MountpathsCnt; i++ {
157 mpath, err := os.MkdirTemp(dir, "")
158 tassert.CheckFatal(t, err)
159 mp, err := fs.Add(mpath, "daeID")
160 tassert.CheckFatal(t, err)
161 mpathCnts[mp.Path] = 0
162 }
163
164 if len(desc.CTs) == 0 {
165 return nil
166 }
167
168 tMock = mock.NewTarget(bmd)
169
170 errs := fs.CreateBucket("testing", &bck, false /*nilbmd*/)
171 if len(errs) > 0 {
172 tassert.CheckFatal(t, errs[0])
173 }
174
175 for _, ct := range desc.CTs {
176 for i := 0; i < ct.ContentCnt; i++ {
177 fqn, _, err := cluster.HrwFQN(&bck, ct.Type, cos.RandString(15))
178 tassert.CheckFatal(t, err)
179
180 fqns[ct.Type] = append(fqns[ct.Type], fqn)
181
182 f, err := cos.CreateFile(fqn)
183 tassert.CheckFatal(t, err)

Callers 9

prepareObjectFunction · 0.92
TestWorkerGroupFunction · 0.92
TestJoggerGroupFunction · 0.92
TestJoggerGroupParallelFunction · 0.92
TestJoggerGroupLoadFunction · 0.92
TestJoggerGroupErrorFunction · 0.92
PrepareMountPathsFunction · 0.85

Calls 15

InitFQNMethod · 0.95
SetSizeMethod · 0.95
SetAtimeUnixMethod · 0.95
PersistMethod · 0.95
RandStringFunction · 0.92
NewBaseBownerMockFunction · 0.92
NewIOStaterFunction · 0.92
TestNewFunction · 0.92
TestDisableValidationFunction · 0.92
CheckFatalFunction · 0.92
AddFunction · 0.92
NewTargetFunction · 0.92

Tested by 8

prepareObjectFunction · 0.74
TestWorkerGroupFunction · 0.74
TestJoggerGroupFunction · 0.74
TestJoggerGroupParallelFunction · 0.74
TestJoggerGroupLoadFunction · 0.74
TestJoggerGroupErrorFunction · 0.74