(t *testing.T)
| 51 | ) |
| 52 | |
| 53 | func 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") |
nothing calls this directly
no test coverage detected