private/testplanet: add DeleteBucket method for uplink

New method added to be able to delete easily bucket during tests.

Change-Id: Iaae89618cc676ddbbbd4b0df2eeacd143ea6f3c2
This commit is contained in:
Michal Niewrzal 2020-02-10 13:18:18 +01:00
parent bd9cebda5b
commit 426c8eb31a
7 changed files with 23 additions and 8 deletions

View File

@ -269,8 +269,8 @@ func (client *Uplink) DownloadStreamRange(ctx context.Context, satellite *Satell
return downloader, cleanup, err
}
// Delete deletes an object at the path in a bucket
func (client *Uplink) Delete(ctx context.Context, satellite *SatelliteSystem, bucketName string, path storj.Path) error {
// DeleteObject deletes an object at the path in a bucket
func (client *Uplink) DeleteObject(ctx context.Context, satellite *SatelliteSystem, bucketName string, path storj.Path) error {
project, bucket, err := client.GetProjectAndBucket(ctx, satellite, bucketName, client.GetConfig(satellite))
if err != nil {
return err
@ -306,6 +306,21 @@ func (client *Uplink) CreateBucket(ctx context.Context, satellite *SatelliteSyst
return nil
}
// DeleteBucket deletes a bucket.
func (client *Uplink) DeleteBucket(ctx context.Context, satellite *SatelliteSystem, bucketName string) error {
project, err := client.GetProject(ctx, satellite)
if err != nil {
return err
}
defer func() { err = errs.Combine(err, project.Close()) }()
err = project.DeleteBucket(ctx, bucketName)
if err != nil {
return err
}
return nil
}
// GetConfig returns a default config for a given satellite.
func (client *Uplink) GetConfig(satellite *SatelliteSystem) cmd.Config {
config := getDefaultConfig()

View File

@ -284,7 +284,7 @@ func TestDeleteWithOfflineStoragenode(t *testing.T) {
require.NoError(t, err)
}
err = planet.Uplinks[0].Delete(ctx, planet.Satellites[0], "test-bucket", "test-file")
err = planet.Uplinks[0].DeleteObject(ctx, planet.Satellites[0], "test-bucket", "test-file")
require.NoError(t, err)
_, err = planet.Uplinks[0].Download(ctx, planet.Satellites[0], "test-bucket", "test-file")

View File

@ -535,7 +535,7 @@ func TestReverifyDeletedSegment(t *testing.T) {
require.NoError(t, err)
// delete the file
err = ul.Delete(ctx, satellite, "testbucket", "test/path1")
err = ul.DeleteObject(ctx, satellite, "testbucket", "test/path1")
require.NoError(t, err)
// call reverify on the deleted file and expect a segment deleted error

View File

@ -644,7 +644,7 @@ func TestVerifierDeletedSegment(t *testing.T) {
require.NoError(t, err)
// delete the file
err = ul.Delete(ctx, satellite, "testbucket", "test/path")
err = ul.DeleteObject(ctx, satellite, "testbucket", "test/path")
require.NoError(t, err)
report, err := audits.Verifier.Verify(ctx, path, nil)

View File

@ -1021,7 +1021,7 @@ func TestPointerChangedOrDeleted(t *testing.T) {
// a successful graceful exit instead of a request to transfer pieces since the root piece IDs will have changed.
err = uplinkPeer.Upload(ctx, satellite, "testbucket", "test/path0", testrand.Bytes(5*memory.KiB))
require.NoError(t, err)
err = uplinkPeer.Delete(ctx, satellite, "testbucket", "test/path1")
err = uplinkPeer.DeleteObject(ctx, satellite, "testbucket", "test/path1")
require.NoError(t, err)
// reconnect to the satellite.

View File

@ -451,7 +451,7 @@ func TestRemoveDeletedSegmentFromQueue(t *testing.T) {
satellite.Repair.Checker.Loop.Pause()
// Delete segment from the satellite database
err = uplinkPeer.Delete(ctx, satellite, "testbucket", "test/path")
err = uplinkPeer.DeleteObject(ctx, satellite, "testbucket", "test/path")
require.NoError(t, err)
// Verify that the segment is on the repair queue

View File

@ -75,7 +75,7 @@ func TestUploadAndPartialDownload(t *testing.T) {
totalBandwidthUsage.Add(usage)
}
err = planet.Uplinks[0].Delete(ctx, planet.Satellites[0], "testbucket", "test/path")
err = planet.Uplinks[0].DeleteObject(ctx, planet.Satellites[0], "testbucket", "test/path")
require.NoError(t, err)
_, err = planet.Uplinks[0].Download(ctx, planet.Satellites[0], "testbucket", "test/path")
require.Error(t, err)