Skip to content

Commit ca33b7b

Browse files
authored
add stream attrs to GetContainerContents output (#124)
1 parent c1b8561 commit ca33b7b

File tree

2 files changed

+60
-8
lines changed

2 files changed

+60
-8
lines changed

pkg/dataplane/test/sync_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,55 @@ func (suite *syncContainerTestSuite) TestGetContainerContentsDirsWithAllAttrs()
212212
}
213213
}
214214

215+
func (suite *syncContainerTestSuite) TestGetContainerContentsStreamDirsWithAllAttrs() {
216+
path := fmt.Sprintf("tmp/test/sync_test/TestGetContainerContentsStreamDirsWithAllAttrs/%d/", time.Now().Unix())
217+
218+
const (
219+
shard_count = 12
220+
retention_period_hours = 2
221+
)
222+
223+
// Create some stream content (stream directory and shards)
224+
createStreamInput := &v3io.CreateStreamInput{}
225+
for i := 1; i <= 10; i++ {
226+
createStreamInput.Path = fmt.Sprintf("%sstream-%d/", path, i)
227+
createStreamInput.ShardCount = shard_count
228+
createStreamInput.RetentionPeriodHours = retention_period_hours
229+
230+
// when run against a context
231+
suite.populateDataPlaneInput(&createStreamInput.DataPlaneInput)
232+
err := suite.container.CreateStreamSync(createStreamInput)
233+
suite.Require().NoError(err, "Failed to create test content")
234+
}
235+
236+
getContainerContentsInput := v3io.GetContainerContentsInput{
237+
Path: path,
238+
GetAllAttributes: true,
239+
DirectoriesOnly: true,
240+
Limit: 10,
241+
}
242+
243+
// when run against a context
244+
suite.populateDataPlaneInput(&getContainerContentsInput.DataPlaneInput)
245+
246+
// get container contents
247+
response, err := suite.container.GetContainerContentsSync(&getContainerContentsInput)
248+
suite.Require().NoError(err, "Failed to get container contents")
249+
response.Release()
250+
251+
getContainerContentsOutput := response.Output.(*v3io.GetContainerContentsOutput)
252+
suite.Require().Empty(len(getContainerContentsOutput.Contents))
253+
suite.Require().Equal(10, len(getContainerContentsOutput.CommonPrefixes))
254+
suite.Require().Equal(path+"stream-9", getContainerContentsOutput.NextMarker)
255+
suite.Require().Equal(false, getContainerContentsOutput.IsTruncated)
256+
257+
for _, prefix := range getContainerContentsOutput.CommonPrefixes {
258+
validateCommonPrefix(suite, &prefix, true)
259+
suite.Require().Equal(shard_count, prefix.ShardCount)
260+
suite.Require().Equal(retention_period_hours, prefix.RetentionPeriodHours)
261+
}
262+
}
263+
215264
// TODO: fix. Broken with:
216265
// Messages: Failed to update test directory
217266
// due to:

pkg/dataplane/types.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,17 @@ type Content struct {
9494
}
9595

9696
type CommonPrefix struct {
97-
Prefix string `xml:"Prefix"` // directory name
98-
LastModified string `xml:"LastModified"` // Date in format time.RFC3339: "2019-06-02T14:30:39.18Z"
99-
AccessTime string `xml:"AccessTime"` // Date in format time.RFC3339: "2019-06-02T14:30:39.18Z"
100-
CreatingTime string `xml:"CreatingTime"` // Date in format time.RFC3339: "2019-06-02T14:30:39.18Z"
101-
Mode FileMode `xml:"Mode"` // octal number, e.g. 040775
102-
GID string `xml:"GID"` // Hexadecimal representation of GID (e.g. "3e8" -> i.e. "0x3e8" == 1000)
103-
UID string `xml:"UID"` // Hexadecimal representation of UID (e.g. "3e8" -> i.e. "0x3e8" == 1000)
104-
InodeNumber *uint64 `xml:"InodeNumber"` // iNode number
97+
Prefix string `xml:"Prefix"` // directory name
98+
LastModified string `xml:"LastModified"` // Date in format time.RFC3339: "2019-06-02T14:30:39.18Z"
99+
AccessTime string `xml:"AccessTime"` // Date in format time.RFC3339: "2019-06-02T14:30:39.18Z"
100+
CreatingTime string `xml:"CreatingTime"` // Date in format time.RFC3339: "2019-06-02T14:30:39.18Z"
101+
Mode FileMode `xml:"Mode"` // octal number, e.g. 040775
102+
GID string `xml:"GID"` // Hexadecimal representation of GID (e.g. "3e8" -> i.e. "0x3e8" == 1000)
103+
UID string `xml:"UID"` // Hexadecimal representation of UID (e.g. "3e8" -> i.e. "0x3e8" == 1000)
104+
InodeNumber *uint64 `xml:"InodeNumber"` // iNode number
105+
ShardCount int `xml:"ShardCount"` // For stream-dirs only - the number of shards in the stream
106+
RetentionPeriodHours int `xml:"RetentionPeriodHours"` // For stream-dirs only - the shard retention (in hours)
107+
RetentionPeriodSeconds int `xml:"RetentionPeriodSec"` // For stream-dirs only - the shard retention (in seconds)
105108
}
106109

107110
type FileMode string

0 commit comments

Comments
 (0)