// examine situation where a blob has the same name as virtual dir
// trailing slash is used to disambiguate the path as a vdir
examine situation where a blob has the same name as virtual dir
trailing slash is used to disambiguate the path as a vdir
// examine situation where a blob has the same name as virtual dir // trailing slash is used to disambiguate the path as a vdir
func (s *cmdIntegrationSuite) TestSyncS2SBetweenVirtualDirsWithConflictingBlob(c *chk.C) {
	bsu := getBSU()
	srcContainerURL, srcContainerName := createNewContainer(c, bsu)
	dstContainerURL, dstContainerName := createNewContainer(c, bsu)
	defer deleteContainer(c, srcContainerURL)
	defer deleteContainer(c, dstContainerURL)
	vdirName := "vdir"
	blobList := scenarioHelper{}.generateCommonRemoteScenarioForBlob(c, srcContainerURL,
		vdirName+common.AZCOPY_PATH_SEPARATOR_STRING)
	c.Assert(len(blobList), chk.Not(chk.Equals), 0)
	scenarioHelper{}.generateBlobsFromList(c, dstContainerURL, blobList, blockBlobDefaultData)
	scenarioHelper{}.generateBlobsFromList(c, dstContainerURL, []string{vdirName}, blockBlobDefaultData)
	mockedRPC := interceptor{}
	Rpc = mockedRPC.intercept
	mockedRPC.init()
	srcContainerURLWithSAS := scenarioHelper{}.getRawContainerURLWithSAS(c, srcContainerName)
	dstContainerURLWithSAS := scenarioHelper{}.getRawContainerURLWithSAS(c, dstContainerName)
	srcContainerURLWithSAS.Path += common.AZCOPY_PATH_SEPARATOR_STRING + vdirName
	dstContainerURLWithSAS.Path += common.AZCOPY_PATH_SEPARATOR_STRING + vdirName
	raw := getDefaultSyncRawInput(srcContainerURLWithSAS.String(), dstContainerURLWithSAS.String())
	runSyncAndVerify(c, raw, func(err error) {
		c.Assert(err, chk.NotNil)
		c.Assert(len(mockedRPC.transfers), chk.Equals, 0)
	})
	raw = getDefaultSyncRawInput(dstContainerURLWithSAS.String(), srcContainerURLWithSAS.String())
	runSyncAndVerify(c, raw, func(err error) {
		c.Assert(err, chk.NotNil)
		c.Assert(len(mockedRPC.transfers), chk.Equals, 0)
	})
	scenarioHelper{}.generateBlobsFromList(c, srcContainerURL, []string{vdirName}, blockBlobDefaultData)
	raw = getDefaultSyncRawInput(srcContainerURLWithSAS.String(), dstContainerURLWithSAS.String())
	runSyncAndVerify(c, raw, func(err error) {
		c.Assert(err, chk.IsNil)
		validateS2SSyncTransfersAreScheduled(c, "", "", []string{""}, mockedRPC)
	})
	scenarioHelper{}.generateBlobsFromList(c, srcContainerURL, blobList, blockBlobDefaultData)
	mockedRPC.reset()
	srcContainerURLWithSAS.Path += common.AZCOPY_PATH_SEPARATOR_STRING
	dstContainerURLWithSAS.Path += common.AZCOPY_PATH_SEPARATOR_STRING
	raw = getDefaultSyncRawInput(srcContainerURLWithSAS.String(), dstContainerURLWithSAS.String())
	expectedList := scenarioHelper{}.shaveOffPrefix(blobList, vdirName+common.AZCOPY_PATH_SEPARATOR_STRING)
	runSyncAndVerify(c, raw, func(err error) {
		c.Assert(err, chk.IsNil)
		validateS2SSyncTransfersAreScheduled(c, "", "", expectedList, mockedRPC)
	})
}
func ( s * cmdIntegrationSuite ) TestSyncS2SBetweenVirtualDirsWithConflictingBlob ( c * chk . C ) { bsu := getBSU ( ) srcContainerURL , srcContainerName := createNewContainer ( c , bsu ) dstContainerURL , dstContainerName := createNewContainer ( c , bsu ) defer deleteContainer ( c , srcContainerURL ) defer deleteContainer ( c , dstContainerURL ) vdirName := " " blobList := scenarioHelper { } . generateCommonRemoteScenarioForBlob ( c , srcContainerURL , vdirName + common . AZCOPY_PATH_SEPARATOR_STRING ) c . Assert ( len ( blobList ) , chk . Not ( chk . Equals ) , 0 ) scenarioHelper { } . generateBlobsFromList ( c , dstContainerURL , blobList , blockBlobDefaultData ) scenarioHelper { } . generateBlobsFromList ( c , dstContainerURL , [ ] string { vdirName } , blockBlobDefaultData ) mockedRPC := interceptor { } Rpc = mockedRPC . intercept mockedRPC . init ( ) srcContainerURLWithSAS := scenarioHelper { } . getRawContainerURLWithSAS ( c , srcContainerName ) dstContainerURLWithSAS := scenarioHelper { } . getRawContainerURLWithSAS ( c , dstContainerName ) srcContainerURLWithSAS . Path += common . AZCOPY_PATH_SEPARATOR_STRING + vdirName dstContainerURLWithSAS . Path += common . AZCOPY_PATH_SEPARATOR_STRING + vdirName raw := getDefaultSyncRawInput ( srcContainerURLWithSAS . String ( ) , dstContainerURLWithSAS . String ( ) ) runSyncAndVerify ( c , raw , func ( err error ) { c . Assert ( err , chk . NotNil ) c . Assert ( len ( mockedRPC . transfers ) , chk . Equals , 0 ) } ) raw = getDefaultSyncRawInput ( dstContainerURLWithSAS . String ( ) , srcContainerURLWithSAS . String ( ) ) runSyncAndVerify ( c , raw , func ( err error ) { c . Assert ( err , chk . NotNil ) c . Assert ( len ( mockedRPC . transfers ) , chk . Equals , 0 ) } ) scenarioHelper { } . generateBlobsFromList ( c , srcContainerURL , [ ] string { vdirName } , blockBlobDefaultData ) raw = getDefaultSyncRawInput ( srcContainerURLWithSAS . String ( ) , dstContainerURLWithSAS . String ( ) ) runSyncAndVerify ( c , raw , func ( err error ) { c . Assert ( err , chk . IsNil ) validateS2SSyncTransfersAreScheduled ( c , " " , " " , [ ] string { " " } , mockedRPC ) } ) scenarioHelper { } . generateBlobsFromList ( c , srcContainerURL , blobList , blockBlobDefaultData ) mockedRPC . reset ( ) srcContainerURLWithSAS . Path += common . AZCOPY_PATH_SEPARATOR_STRING dstContainerURLWithSAS . Path += common . AZCOPY_PATH_SEPARATOR_STRING raw = getDefaultSyncRawInput ( srcContainerURLWithSAS . String ( ) , dstContainerURLWithSAS . String ( ) ) expectedList := scenarioHelper { } . shaveOffPrefix ( blobList , vdirName + common . AZCOPY_PATH_SEPARATOR_STRING ) runSyncAndVerify ( c , raw , func ( err error ) { c . Assert ( err , chk . IsNil ) validateS2SSyncTransfersAreScheduled ( c , " " , " " , expectedList , mockedRPC ) } ) }
examine situation where a blob has the same name as virtual dir
trailing slash is used to disambiguate the path as a vdir
examine situation where a blob has the same name as virtual dir trailing slash is used to disambiguate the path as a vdir
// set up the source container with numerous blobs // set up the destination with the exact same files // create a blob at the destination with the exact same name as the vdir // set up interceptor // case 1: vdir -> blob sync: should fail // construct the raw input to simulate user input // validate that the right number of transfers were scheduled // case 2: blob -> vdir sync: simply swap src and dst, should fail too // validate that the right number of transfers were scheduled // case 3: blob -> blob: if source is also a blob, then single blob to blob sync happens // create a blob at the source with the exact same name as the vdir // refresh the dst blobs' last modified time so that they are newer // case 4: vdir -> vdir: adding a trailing slash helps to clarify it should be treated as virtual dir