func (s *cmdIntegrationSuite) TestSyncS2SWithMismatchedDestination(c *chk.C) {
	bsu := getBSU()
	srcContainerURL, srcContainerName := createNewContainer(c, bsu)
	dstContainerURL, dstContainerName := createNewContainer(c, bsu)
	defer deleteContainer(c, srcContainerURL)
	defer deleteContainer(c, dstContainerURL)

	// set up the container with numerous blobs
	blobList := scenarioHelper{}.generateCommonRemoteScenarioForBlob(c, srcContainerURL, "")
	c.Assert(len(blobList), chk.Not(chk.Equals), 0)

	// set up the destination with half of the blobs from source
	scenarioHelper{}.generateBlobsFromList(c, dstContainerURL, blobList[0:len(blobList)/2], blockBlobDefaultData)
	expectedOutput := blobList[len(blobList)/2:] // the missing half of source blobs should be transferred

	// add some extra blobs that shouldn't be included
	scenarioHelper{}.generateCommonRemoteScenarioForBlob(c, dstContainerURL, "extra")

	// set up interceptor
	mockedRPC := interceptor{}
	Rpc = mockedRPC.intercept
	mockedRPC.init()

	// construct the raw input to simulate user input
	srcContainerURLWithSAS := scenarioHelper{}.getRawContainerURLWithSAS(c, srcContainerName)
	dstContainerURLWithSAS := scenarioHelper{}.getRawContainerURLWithSAS(c, dstContainerName)
	raw := getDefaultSyncRawInput(srcContainerURLWithSAS.String(), dstContainerURLWithSAS.String())

	runSyncAndVerify(c, raw, func(err error) {
		c.Assert(err, chk.IsNil)
		validateS2SSyncTransfersAreScheduled(c, "", "", expectedOutput, mockedRPC)

		// make sure the extra blobs were deleted
		extraFilesFound := false
		for marker := (azblob.Marker{}); marker.NotDone(); {
			listResponse, err := dstContainerURL.ListBlobsFlatSegment(ctx, marker, azblob.ListBlobsSegmentOptions{})
			c.Assert(err, chk.IsNil)
			marker = listResponse.NextMarker

			// if ever the extra blobs are found, note it down
			for _, blob := range listResponse.Segment.BlobItems {
				if strings.Contains(blob.Name, "extra") {
					extraFilesFound = true
				}
			}
		}

		c.Assert(extraFilesFound, chk.Equals, false)
	})
}
// regular container->container sync where destination is missing some files from source, and also has some extra files
regular container->container sync where destination is missing some files from source, and also has some extra files
// regular container - > container sync where destination is missing some files from source and also has some extra files
func (s *cmdIntegrationSuite) TestSyncS2SWithMismatchedDestination(c *chk.C) {
	bsu := getBSU()
	srcContainerURL, srcContainerName := createNewContainer(c, bsu)
	dstContainerURL, dstContainerName := createNewContainer(c, bsu)
	defer deleteContainer(c, srcContainerURL)
	defer deleteContainer(c, dstContainerURL)
	blobList := scenarioHelper{}.generateCommonRemoteScenarioForBlob(c, srcContainerURL, "")
	c.Assert(len(blobList), chk.Not(chk.Equals), 0)
	scenarioHelper{}.generateBlobsFromList(c, dstContainerURL, blobList[0:len(blobList)/2], blockBlobDefaultData)
	expectedOutput := blobList[len(blobList)/2:] 
	scenarioHelper{}.generateCommonRemoteScenarioForBlob(c, dstContainerURL, "extra")
	mockedRPC := interceptor{}
	Rpc = mockedRPC.intercept
	mockedRPC.init()
	srcContainerURLWithSAS := scenarioHelper{}.getRawContainerURLWithSAS(c, srcContainerName)
	dstContainerURLWithSAS := scenarioHelper{}.getRawContainerURLWithSAS(c, dstContainerName)
	raw := getDefaultSyncRawInput(srcContainerURLWithSAS.String(), dstContainerURLWithSAS.String())
	runSyncAndVerify(c, raw, func(err error) {
		c.Assert(err, chk.IsNil)
		validateS2SSyncTransfersAreScheduled(c, "", "", expectedOutput, mockedRPC)
		extraFilesFound := false
		for marker := (azblob.Marker{}); marker.NotDone(); {
			listResponse, err := dstContainerURL.ListBlobsFlatSegment(ctx, marker, azblob.ListBlobsSegmentOptions{})
			c.Assert(err, chk.IsNil)
			marker = listResponse.NextMarker
			for _, blob := range listResponse.Segment.BlobItems {
				if strings.Contains(blob.Name, "extra") {
					extraFilesFound = true
				}
			}
		}
		c.Assert(extraFilesFound, chk.Equals, false)
	})
}
func ( s * cmdIntegrationSuite ) TestSyncS2SWithMismatchedDestination ( c * chk . C ) { bsu := getBSU ( ) srcContainerURL , srcContainerName := createNewContainer ( c , bsu ) dstContainerURL , dstContainerName := createNewContainer ( c , bsu ) defer deleteContainer ( c , srcContainerURL ) defer deleteContainer ( c , dstContainerURL ) blobList := scenarioHelper { } . generateCommonRemoteScenarioForBlob ( c , srcContainerURL , " " ) c . Assert ( len ( blobList ) , chk . Not ( chk . Equals ) , 0 ) scenarioHelper { } . generateBlobsFromList ( c , dstContainerURL , blobList [ 0 : len ( blobList ) / 2 ] , blockBlobDefaultData ) expectedOutput := blobList [ len ( blobList ) / 2 : ] scenarioHelper { } . generateCommonRemoteScenarioForBlob ( c , dstContainerURL , " " ) mockedRPC := interceptor { } Rpc = mockedRPC . intercept mockedRPC . init ( ) srcContainerURLWithSAS := scenarioHelper { } . getRawContainerURLWithSAS ( c , srcContainerName ) dstContainerURLWithSAS := scenarioHelper { } . getRawContainerURLWithSAS ( c , dstContainerName ) raw := getDefaultSyncRawInput ( srcContainerURLWithSAS . String ( ) , dstContainerURLWithSAS . String ( ) ) runSyncAndVerify ( c , raw , func ( err error ) { c . Assert ( err , chk . IsNil ) validateS2SSyncTransfersAreScheduled ( c , " " , " " , expectedOutput , mockedRPC ) extraFilesFound := false for marker := ( azblob . Marker { } ) ; marker . NotDone ( ) ; { listResponse , err := dstContainerURL . ListBlobsFlatSegment ( ctx , marker , azblob . ListBlobsSegmentOptions { } ) c . Assert ( err , chk . IsNil ) marker = listResponse . NextMarker for _ , blob := range listResponse . Segment . BlobItems { if strings . Contains ( blob . Name , " " ) { extraFilesFound = true } } } c . Assert ( extraFilesFound , chk . Equals , false ) } ) }
regular container->container sync where destination is missing some files from source, and also has some extra files
regular container - > container sync where destination is missing some files from source and also has some extra files
// set up the container with numerous blobs // set up the destination with half of the blobs from source // the missing half of source blobs should be transferred // add some extra blobs that shouldn't be included // set up interceptor // construct the raw input to simulate user input // make sure the extra blobs were deleted // if ever the extra blobs are found, note it down