github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/ais/test/target_test.go (about) 1 // Package integration_test. 2 /* 3 * Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved. 4 */ 5 package integration_test 6 7 import ( 8 "testing" 9 10 "github.com/NVIDIA/aistore/api" 11 "github.com/NVIDIA/aistore/api/apc" 12 "github.com/NVIDIA/aistore/cmn" 13 "github.com/NVIDIA/aistore/tools" 14 "github.com/NVIDIA/aistore/tools/readers" 15 "github.com/NVIDIA/aistore/tools/tassert" 16 "github.com/NVIDIA/aistore/tools/tlog" 17 ) 18 19 func TestPutObjectNoDaemonID(t *testing.T) { 20 const ( 21 objName = "someObject" 22 ) 23 var ( 24 sid string 25 objDummyData = []byte("testing is so much fun") 26 proxyURL = tools.RandomProxyURL() 27 smap = tools.GetClusterMap(t, proxyURL) 28 bck = cmn.Bck{ 29 Name: testBucketName, 30 Provider: apc.AIS, 31 } 32 ) 33 34 si, err := smap.GetRandTarget() 35 tassert.CheckFatal(t, err) 36 sid = si.ID() 37 38 url := smap.Tmap[sid].URL(cmn.NetPublic) 39 baseParams := tools.BaseAPIParams(url) 40 reader := readers.NewBytes(objDummyData) 41 putArgs := api.PutArgs{ 42 BaseParams: baseParams, 43 Bck: bck, 44 ObjName: objName, 45 Cksum: reader.Cksum(), 46 Reader: reader, 47 } 48 if _, err := api.PutObject(&putArgs); err == nil { 49 t.Errorf("Error is nil, expected Bad Request error on a PUT to target with no daemon ID query string") 50 } 51 } 52 53 func TestDeleteInvalidDaemonID(t *testing.T) { 54 val := &apc.ActValRmNode{ 55 DaemonID: "abcde:abcde", 56 SkipRebalance: true, 57 KeepInitialConfig: true, 58 } 59 tlog.Logf("Decommission invalid node %s (expecting to fail)\n", val.DaemonID) 60 if _, err := api.DecommissionNode(tools.BaseAPIParams(), val); err == nil { 61 t.Errorf("Error is nil, expected NotFound error on a delete of a non-existing target") 62 } 63 }