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

Function TestLocalListObjectsGetTargetURL

ais/tests/regression_test.go:53–136  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51)
52
53func TestLocalListObjectsGetTargetURL(t *testing.T) {
54 var (
55 m = ioContext{
56 t: t,
57 num: 1000,
58 fileSize: cos.KiB,
59 fixedSize: true,
60 }
61
62 targets = make(map[string]struct{})
63 proxyURL = tutils.RandomProxyURL(t)
64 baseParams = tutils.BaseAPIParams(proxyURL)
65 smap = tutils.GetClusterMap(t, proxyURL)
66 )
67
68 m.initWithCleanupAndSaveState()
69 m.expectTargets(1)
70
71 tutils.CreateBucketWithCleanup(t, proxyURL, m.bck, nil)
72
73 m.puts()
74
75 msg := &apc.ListObjsMsg{Props: apc.GetTargetURL}
76 bl, err := api.ListObjects(baseParams, m.bck, msg, uint(m.num))
77 tassert.CheckFatal(t, err)
78
79 if len(bl.Entries) != m.num {
80 t.Errorf("Expected %d bucket list entries, found %d\n", m.num, len(bl.Entries))
81 }
82
83 j := 10
84 if len(bl.Entries) >= 200 {
85 j = 100
86 }
87 for i, e := range bl.Entries {
88 if e.TargetURL == "" {
89 t.Error("Target URL in response is empty")
90 }
91 if _, ok := targets[e.TargetURL]; !ok {
92 targets[e.TargetURL] = struct{}{}
93 }
94 baseParams := tutils.BaseAPIParams(e.TargetURL)
95
96 l, err := api.GetObject(baseParams, m.bck, e.Name)
97 tassert.CheckFatal(t, err)
98 if uint64(l) != m.fileSize {
99 t.Errorf("Expected filesize: %d, actual filesize: %d\n", m.fileSize, l)
100 }
101
102 if i%j == 0 {
103 if i == 0 {
104 tlog.Logln("Modifying config to enforce intra-cluster access, expecting errors...\n")
105 }
106 tutils.SetClusterConfig(t, cos.SimpleKVs{"features": feat.EnforceIntraClusterAccess.Value()})
107 _, err = api.GetObject(baseParams, m.bck, e.Name)
108
109 // TODO -- FIXME: see cmn.ConfigRestartRequired and cmn.Features
110 // tassert.Errorf(t, err != nil, "expected intra-cluster access enforced")

Callers

nothing calls this directly

Calls 15

RandomProxyURLFunction · 0.92
BaseAPIParamsFunction · 0.92
GetClusterMapFunction · 0.92
CreateBucketWithCleanupFunction · 0.92
ListObjectsFunction · 0.92
CheckFatalFunction · 0.92
GetObjectFunction · 0.92
LoglnFunction · 0.92
SetClusterConfigFunction · 0.92
LogfFunction · 0.92
expectTargetsMethod · 0.80

Tested by

no test coverage detected