Skip to content

Commit

Permalink
Fix testing
Browse files Browse the repository at this point in the history
  • Loading branch information
adreed-msft committed Jan 18, 2023
1 parent 1fc7047 commit 621ff0a
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 17 deletions.
4 changes: 2 additions & 2 deletions cmd/zt_sync_comparator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *syncComparatorSuite) TestSyncSourceComparator(c *chk.C) {

// set up the indexer as well as the source comparator
indexer := newObjectIndexer()
sourceComparator := newSyncSourceComparator(indexer, dummyCopyScheduler.process, false)
sourceComparator := newSyncSourceComparator(indexer, dummyCopyScheduler.process, false, false)

// create a sample destination object
sampleDestinationObject := StoredObject{name: "test", relativePath: "/usr/test", lastModifiedTime: time.Now(), md5: destMD5}
Expand Down Expand Up @@ -88,7 +88,7 @@ func (s *syncComparatorSuite) TestSyncSrcCompDisableComparator(c *chk.C) {

// set up the indexer as well as the source comparator
indexer := newObjectIndexer()
sourceComparator := newSyncSourceComparator(indexer, dummyCopyScheduler.process, true)
sourceComparator := newSyncSourceComparator(indexer, dummyCopyScheduler.process, false, true)

// test the comparator in case a given source object is not present at the destination
// meaning no entry in the index, so the comparator should pass the given object to schedule a transfer
Expand Down
2 changes: 1 addition & 1 deletion e2etest/declarativeHelpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ type params struct {
cancelFromStdin bool
backupMode bool
preserveSMBPermissions bool
preserveSMBInfo bool
preserveSMBInfo *bool
preservePOSIXProperties bool
relativeSourcePath string
blobTags string
Expand Down
6 changes: 6 additions & 0 deletions e2etest/pointers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package e2etest

// todo: upgrade to go 1.18 and use generics
func BoolPointer(b bool) *bool {
return &b
}
14 changes: 13 additions & 1 deletion e2etest/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"os"
"os/exec"
"path/filepath"
"reflect"
"strconv"
"strings"

Expand Down Expand Up @@ -59,6 +60,17 @@ func (t *TestRunner) SetAllFlags(p params, o Operation) {
return // nothing to do. The flag is not supposed to be set
}

reflectVal := reflect.ValueOf(value) // check for pointer
if reflectVal.Kind() == reflect.Pointer {
result := reflectVal.Elem() // attempt to deref

if !result.IsZero() && result.CanInterface() { // can we grab the underlying value?
value = result.Interface()
} else {
return // nothing to use
}
}

format := "%v"
if len(formats) > 0 {
format = formats[0]
Expand All @@ -83,7 +95,7 @@ func (t *TestRunner) SetAllFlags(p params, o Operation) {
set("s2s-detect-source-changed", p.s2sSourceChangeValidation, false)
set("metadata", p.metadata, "")
set("cancel-from-stdin", p.cancelFromStdin, false)
set("preserve-smb-info", p.preserveSMBInfo, true)
set("preserve-smb-info", p.preserveSMBInfo, nil)
set("preserve-smb-permissions", p.preserveSMBPermissions, false)
set("backup", p.backupMode, false)
set("blob-tags", p.blobTags, "")
Expand Down
5 changes: 3 additions & 2 deletions e2etest/zt_basic_copy_sync_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ func TestBasic_SyncLMTSwitch_PreferServiceLMT(t *testing.T) {
anonymousAuthOnly,
anonymousAuthOnly,
params{
preserveSMBInfo: false,
preserveSMBInfo: BoolPointer(false),
},
&hooks{
beforeRunJob: func(h hookHelper) {
Expand Down Expand Up @@ -394,7 +394,8 @@ func TestBasic_SyncLMTSwitch_PreferSMBLMT(t *testing.T) {
anonymousAuthOnly,
anonymousAuthOnly,
params{
preserveSMBInfo: true,
// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
},
&hooks{
beforeRunJob: func(h hookHelper) {
Expand Down
6 changes: 4 additions & 2 deletions e2etest/zt_copy_file_smb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ import (
func TestSMB_FromShareSnapshot(t *testing.T) {
RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.FileFile()), eValidate.AutoPlusContent(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true,
preserveSMBPermissions: true,

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, &hooks{
// create a snapshot for the source share
beforeRunJob: func(h hookHelper) {
Expand Down Expand Up @@ -39,7 +41,7 @@ func TestSMB_ToDevNull(t *testing.T) {
params{
recursive: true,
preserveSMBPermissions: isWindows,
preserveSMBInfo: isWindows,
preserveSMBInfo: BoolPointer(isWindows),
checkMd5: common.EHashValidationOption.FailIfDifferent(),
destNull: true,
},
Expand Down
28 changes: 21 additions & 7 deletions e2etest/zt_preserve_smb_properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ func TestProperties_SMBPermissionsSDDLPreserved(t *testing.T) {
common.EFromTo.FileFile(),
), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true,
preserveSMBPermissions: true,

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, nil, testFiles{
defaultSize: "1K",
shouldTransfer: []interface{}{
Expand All @@ -88,7 +90,9 @@ func TestProperties_SMBPermissionsSDDLPreserved(t *testing.T) {
func TestProperties_SMBDates(t *testing.T) {
RunScenarios(t, eOperation.CopyAndSync(), eTestFromTo.Other(common.EFromTo.LocalFile(), common.EFromTo.FileLocal()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true,

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, &hooks{
beforeRunJob: func(h hookHelper) {
// Pause then re-write all the files, so that their LastWriteTime is different from their creation time
Expand Down Expand Up @@ -118,7 +122,9 @@ func TestProperties_SMBDates(t *testing.T) {
func TestProperties_SMBFlags(t *testing.T) {
RunScenarios(t, eOperation.CopyAndSync(), eTestFromTo.Other(common.EFromTo.LocalFile(), common.EFromTo.FileFile(), common.EFromTo.FileLocal()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true,

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, nil, testFiles{
defaultSize: "1K",
shouldTransfer: []interface{}{
Expand All @@ -143,7 +149,9 @@ func TestProperties_SMBPermsAndFlagsWithIncludeAfter(t *testing.T) {

RunScenarios(t, eOperation.Copy(), eTestFromTo.Other(common.EFromTo.FileLocal()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true, // this wasn't compatible with time-sensitive filtering prior.

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
// includeAfter: SET LATER
}, &hooks{
beforeRunJob: func(h hookHelper) {
Expand Down Expand Up @@ -190,7 +198,9 @@ func TestProperties_SMBPermsAndFlagsWithSync(t *testing.T) {

RunScenarios(t, eOperation.Sync(), eTestFromTo.Other(common.EFromTo.LocalFile(), common.EFromTo.FileLocal()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true, // this wasn't compatible with time-sensitive filtering prior.

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, &hooks{
beforeRunJob: func(h hookHelper) {
// Pause then re-write all the files, so that their LastWriteTime is different from their creation time
Expand Down Expand Up @@ -244,7 +254,9 @@ func TestProperties_SMBWithCopyWithShareRoot(t *testing.T) {
recursive: true,
invertedAsSubdir: true,
preserveSMBPermissions: true,
preserveSMBInfo: true,

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
},
nil,
testFiles{
Expand Down Expand Up @@ -276,7 +288,9 @@ func TestProperties_SMBTimes(t *testing.T) {
anonymousAuthOnly,
params{
recursive: true,
preserveSMBInfo: true,

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
},
nil,
testFiles{
Expand Down
8 changes: 6 additions & 2 deletions e2etest/zt_resume_windows_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ func TestResume_FolderState(t *testing.T) {
// Create a child file before the folder itself, then persist the properties of the folder upon resume, knowing that we created the folder.
RunScenarios(t, eOperation.CopyAndSync()|eOperation.Resume(), eTestFromTo.Other(common.EFromTo.LocalFile(), common.EFromTo.FileFile(), common.EFromTo.FileLocal()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true,
debugSkipFiles: []string{
"a",
},

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, nil, testFiles{
defaultSize: "1K",

Expand All @@ -29,11 +31,13 @@ func TestResume_NoCreateFolder(t *testing.T) {
// Don't create the folder "ourselves", and let AzCopy find that out on a resume.
RunScenarios(t, eOperation.Copy()|eOperation.Resume(), eTestFromTo.Other(common.EFromTo.LocalFile(), common.EFromTo.FileFile(), common.EFromTo.FileLocal()), eValidate.Auto(), anonymousAuthOnly, anonymousAuthOnly, params{
recursive: true,
preserveSMBInfo: true,
debugSkipFiles: []string{
"a",
"a/b",
},

// default, but present for clarity
//preserveSMBInfo: BoolPointer(true),
}, &hooks{
beforeResumeHook: func(h hookHelper) {
// Create the folder in the middle of the transfer
Expand Down

0 comments on commit 621ff0a

Please sign in to comment.