|
4 | 4 | package e2etest |
5 | 5 |
|
6 | 6 | import ( |
| 7 | + "os" |
| 8 | + "strings" |
7 | 9 | "testing" |
8 | 10 | "time" |
9 | 11 |
|
@@ -45,35 +47,79 @@ func TestPOSIX_SpecialFilesToBlob(t *testing.T) { |
45 | 47 | ) |
46 | 48 | } |
47 | 49 |
|
48 | | -// Test that AMLFS style props are correctly uploaded to Blob storage |
| 50 | +// Test that AMLFS style props are correctly uploaded to & downloaded from Blob storage |
49 | 51 | func TestPOSIX_UploadAMLFSStyle(t *testing.T) { |
50 | 52 | ptr := func(u uint32) *uint32 { |
51 | 53 | return &u |
52 | 54 | } |
53 | | - modTime, err := time.Parse(common.AMLFS_MOD_TIME_LAYOUT, "2026-01-02 15:04:05 -0700") |
| 55 | + timeStr := "2026-01-02 15:04:05 -0700" |
| 56 | + modTime, err := time.Parse(common.AMLFS_MOD_TIME_LAYOUT, timeStr) |
54 | 57 | a := assert.New(t) |
55 | 58 | a.NoError(err) |
56 | 59 |
|
57 | 60 | RunScenarios( |
58 | 61 | t, |
59 | 62 | eOperation.Copy(), |
60 | | - eTestFromTo.Other(common.EFromTo.LocalBlob(), common.EFromTo.BlobLocal()), // no blobblob since that's just metadata and we already test that |
| 63 | + eTestFromTo.Other(common.EFromTo.LocalBlob(), common.EFromTo.BlobLocal(), |
| 64 | + common.EFromTo.BlobBlob()), |
61 | 65 | eValidate.Auto(), |
62 | | - allCredentialTypes, // this relies upon a working source info provider; this validates appropriate creds are supplied to it. |
| 66 | + allCredentialTypes, |
63 | 67 | anonymousAuthOnly, |
64 | 68 | params{ |
65 | 69 | recursive: true, |
66 | 70 | preservePOSIXProperties: true, |
67 | | - symlinkHandling: common.ESymlinkHandlingType.Preserve(), |
68 | 71 | posixPropertiesStyle: common.AMLFSPosixPropertiesStyle, |
69 | 72 | }, |
70 | | - nil, |
| 73 | + // Hook to validate AMLFS style is persisted to Blob |
| 74 | + &hooks{ |
| 75 | + afterValidation: func(h hookHelper) { |
| 76 | + if h.FromTo().To() != common.ELocation.Blob() { |
| 77 | + return // Local destinations use native formatting |
| 78 | + } |
| 79 | + c := h.GetAsserter() |
| 80 | + objects := h.GetDestination().getAllProperties(c) |
| 81 | + |
| 82 | + var props *objectProperties |
| 83 | + for key, p := range objects { |
| 84 | + if strings.HasSuffix(key, "/b") || strings.HasSuffix(key, "b") { |
| 85 | + props = p |
| 86 | + break |
| 87 | + } |
| 88 | + } |
| 89 | + a.NotNil(props, "could not find properties for file") |
| 90 | + |
| 91 | + // check modtime format |
| 92 | + mt, ok := props.nameValueMetadata[common.POSIXModTimeMeta] |
| 93 | + c.Assert(ok, equals(), true, "mod time metadata is missing") |
| 94 | + if ok { |
| 95 | + _, err := time.Parse(common.AMLFS_MOD_TIME_LAYOUT, *mt) |
| 96 | + c.AssertNoErr(err, "mod time is not in expected AMLFS format.") |
| 97 | + } |
| 98 | + |
| 99 | + _, ok = props.nameValueMetadata[common.AMLFSOwnerMeta] |
| 100 | + c.Assert(ok, equals(), true, "AMLFS owner is missing") |
| 101 | + |
| 102 | + _, ok = props.nameValueMetadata[common.AMLFSGroupMeta] |
| 103 | + c.Assert(ok, equals(), true, "AMLFS group is missing") |
| 104 | + |
| 105 | + val, ok := props.nameValueMetadata[common.POSIXModeMeta] |
| 106 | + c.Assert(ok, equals(), true, "permissions metadata is missing.") |
| 107 | + if ok { |
| 108 | + c.Assert(strings.HasPrefix(*val, "0"), equals(), true, "permissions not in octal format") |
| 109 | + } |
| 110 | + }, |
| 111 | + }, |
71 | 112 | testFiles{ |
72 | 113 | defaultSize: "1K", |
73 | 114 | shouldTransfer: []interface{}{ |
74 | 115 | folder(""), |
75 | | - f("a", with{posixProperties: objectUnixStatContainer{mode: ptr(common.S_IFREG | common.DEFAULT_FILE_PERM)}}), |
76 | | - f("b", with{posixProperties: objectUnixStatContainer{modTime: &modTime}}), |
| 116 | + f("a", with{posixProperties: objectUnixStatContainer{ |
| 117 | + mode: ptr(common.S_IFREG | common.DEFAULT_FILE_PERM)}}), |
| 118 | + f("b", with{posixProperties: objectUnixStatContainer{ |
| 119 | + modTime: &modTime, |
| 120 | + owner: ptr(uint32(os.Getuid())), |
| 121 | + group: ptr(uint32(os.Getgid())), |
| 122 | + mode: ptr(common.S_IFREG | common.DEFAULT_FILE_PERM)}}), |
77 | 123 | }, |
78 | 124 | }, |
79 | 125 | EAccountType.Standard(), EAccountType.Standard(), "", |
|
0 commit comments