Skip to content

Commit

Permalink
Merge branch 'dev' into gapra/track2_azblob_migration
Browse files Browse the repository at this point in the history
  • Loading branch information
gapra-msft committed Jul 5, 2023
2 parents adc3b78 + 4509826 commit cba3cdf
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 3 deletions.
15 changes: 14 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,18 +128,27 @@ jobs:
display_name: "Linux"
go_path: '$(go env GOPATH)/bin/'
suffix: ''
run_e2e: 'go test -timeout=1h -v ./e2etest | tee test.txt'
save_exit_code: 'exit_code=${PIPESTATUS[0]}'
return_exit_code: 'exit "$exit_code"'
Windows:
imageName: 'windows-2019'
build_name: 'azcopy_windows_amd64.exe'
display_name: "Windows"
go_path: 'C:\Users\VssAdministrator\go\bin\'
suffix: '.exe'
run_e2e: 'go test -timeout=1h -v ./e2etest > test.txt'
save_exit_code: 'set exit_code=%errorlevel%'
return_exit_code: 'exit %exit_code%'
MacOS:
imageName: 'macos-11'
build_name: 'azcopy_darwin_amd64'
display_name: "MacOS"
go_path: '$(go env GOPATH)/bin/'
suffix: ''
run_e2e: 'go test -timeout=1h -v ./e2etest | tee test.txt'
save_exit_code: 'exit_code=${PIPESTATUS[0]}'
return_exit_code: 'exit "$exit_code"'
pool:
vmImage: $(imageName)

Expand All @@ -160,13 +169,17 @@ jobs:
echo 'Building executable'
go build -cover -o $(build_name)
echo 'Running tests'
go test -timeout=1h -v ./e2etest 2>&1 | $(go_path)go-junit-report$(suffix) > report.xml
$(run_e2e)
$(save_exit_code)
echo "Generating junit report"
cat test.txt | $(go_path)go-junit-report$(suffix) > report.xml
echo 'Formatting coverage directory to legacy txt format'
go tool covdata textfmt -i=coverage -o coverage.txt
echo 'Formatting coverage to json format'
$(go_path)gocov$(suffix) convert coverage.txt > coverage.json
echo 'Formatting coverage to xml format'
$(go_path)gocov-xml$(suffix) < coverage.json > coverage.xml
$(return_exit_code)
env:
AZCOPY_E2E_ACCOUNT_KEY: $(AZCOPY_E2E_ACCOUNT_KEY)
AZCOPY_E2E_ACCOUNT_NAME: $(AZCOPY_E2E_ACCOUNT_NAME)
Expand Down
2 changes: 1 addition & 1 deletion cmd/pathUtils.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ func GetResourceRoot(resource string, location common.Location) (resourceBase st
func SplitResourceString(raw string, loc common.Location) (common.ResourceString, error) {
sasless, sas, err := splitAuthTokenFromResource(raw, loc)
if err != nil {
return common.ResourceString{}, nil
return common.ResourceString{}, err
}
main, query := splitQueryFromSaslessResource(sasless, loc)
return common.ResourceString{
Expand Down
2 changes: 1 addition & 1 deletion cmd/removeEnumerator.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func newRemoveEnumerator(cca *CookedCopyCmdArgs) (enumerator *CopyEnumerator, er
ctx := context.WithValue(context.TODO(), ste.ServiceAPIVersionOverride, ste.DefaultServiceApiVersion)

// Include-path is handled by ListOfFilesChannel.
sourceTraverser, err = InitResourceTraverser(cca.Source, cca.FromTo.From(), &ctx, &cca.credentialInfo, common.ESymlinkHandlingType.Skip(), cca.ListOfFilesChannel, cca.Recursive, false, cca.IncludeDirectoryStubs, cca.permanentDeleteOption, func(common.EntityType) {}, cca.ListOfVersionIDs, false, common.ESyncHashType.None(), common.EPreservePermissionsOption.None(), azcopyLogVerbosity.ToPipelineLogLevel(), cca.CpkOptions, nil, cca.StripTopDir, cca.trailingDot, nil, nil)
sourceTraverser, err = InitResourceTraverser(cca.Source, cca.FromTo.From(), &ctx, &cca.credentialInfo, common.ESymlinkHandlingType.Skip(), cca.ListOfFilesChannel, cca.Recursive, true, cca.IncludeDirectoryStubs, cca.permanentDeleteOption, func(common.EntityType) {}, cca.ListOfVersionIDs, false, common.ESyncHashType.None(), common.EPreservePermissionsOption.None(), azcopyLogVerbosity.ToPipelineLogLevel(), cca.CpkOptions, nil, cca.StripTopDir, cca.trailingDot, nil, nil)

// report failure to create traverser
if err != nil {
Expand Down
68 changes: 68 additions & 0 deletions e2etest/zt_remove_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
// Copyright © Microsoft <[email protected]>
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

package e2etest

import (
"github.com/Azure/azure-storage-file-go/azfile"
"testing"
"time"
)

func TestRemove_IncludeAfter(t *testing.T) {
recreateFiles := []interface{}{
folder(""),
f("filea"),
}

skippedFiles := []interface{}{
folder("fold1"),
f("fold1/fileb"),
}
RunScenarios(t, eOperation.Remove(), eTestFromTo.AllRemove(), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
}, &hooks{
beforeRunJob: func(h hookHelper) {
// Pause for a includeAfter time
time.Sleep(5 * time.Second)
h.GetModifiableParameters().includeAfter = time.Now().Format(azfile.ISO8601)
// Pause then re-write all the files, so that their LastWriteTime is different from their creation time
// So that when validating, our validation can be sure that the right datetime has ended up in the right
// field
time.Sleep(5 * time.Second)
h.CreateFiles(testFiles{
defaultSize: "1K",
shouldTransfer: recreateFiles,
}, true, true, false)

// And pause again, so that that the write times at the destination wont' just _automatically_ match the source times
// (due to there being < 1 sec delay between creation and completion of copy). With this delay, we know they only match
// if AzCopy really did preserve them
time.Sleep(10 * time.Second) // we are assuming here, that the clock skew between source and dest is less than 10 secs
},
}, testFiles{
defaultSize: "1K",
// no need to set specific dates on these. Instead, we just mess with the write times in
// beforeRunJob
// TODO: is that what we really want, or do we want to set write times here?
shouldTransfer: recreateFiles,
shouldIgnore: skippedFiles,
}, EAccountType.Standard(), EAccountType.Standard(), "")
}

0 comments on commit cba3cdf

Please sign in to comment.