Skip to content

Commit

Permalink
add stream attrs to GetContainerContents output (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
assaf758 authored Feb 2, 2022
1 parent c1b8561 commit ca33b7b
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 8 deletions.
49 changes: 49 additions & 0 deletions pkg/dataplane/test/sync_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,55 @@ func (suite *syncContainerTestSuite) TestGetContainerContentsDirsWithAllAttrs()
}
}

func (suite *syncContainerTestSuite) TestGetContainerContentsStreamDirsWithAllAttrs() {
path := fmt.Sprintf("tmp/test/sync_test/TestGetContainerContentsStreamDirsWithAllAttrs/%d/", time.Now().Unix())

const (
shard_count = 12
retention_period_hours = 2
)

// Create some stream content (stream directory and shards)
createStreamInput := &v3io.CreateStreamInput{}
for i := 1; i <= 10; i++ {
createStreamInput.Path = fmt.Sprintf("%sstream-%d/", path, i)
createStreamInput.ShardCount = shard_count
createStreamInput.RetentionPeriodHours = retention_period_hours

// when run against a context
suite.populateDataPlaneInput(&createStreamInput.DataPlaneInput)
err := suite.container.CreateStreamSync(createStreamInput)
suite.Require().NoError(err, "Failed to create test content")
}

getContainerContentsInput := v3io.GetContainerContentsInput{
Path: path,
GetAllAttributes: true,
DirectoriesOnly: true,
Limit: 10,
}

// when run against a context
suite.populateDataPlaneInput(&getContainerContentsInput.DataPlaneInput)

// get container contents
response, err := suite.container.GetContainerContentsSync(&getContainerContentsInput)
suite.Require().NoError(err, "Failed to get container contents")
response.Release()

getContainerContentsOutput := response.Output.(*v3io.GetContainerContentsOutput)
suite.Require().Empty(len(getContainerContentsOutput.Contents))
suite.Require().Equal(10, len(getContainerContentsOutput.CommonPrefixes))
suite.Require().Equal(path+"stream-9", getContainerContentsOutput.NextMarker)
suite.Require().Equal(false, getContainerContentsOutput.IsTruncated)

for _, prefix := range getContainerContentsOutput.CommonPrefixes {
validateCommonPrefix(suite, &prefix, true)
suite.Require().Equal(shard_count, prefix.ShardCount)
suite.Require().Equal(retention_period_hours, prefix.RetentionPeriodHours)
}
}

// TODO: fix. Broken with:
// Messages: Failed to update test directory
// due to:
Expand Down
19 changes: 11 additions & 8 deletions pkg/dataplane/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,17 @@ type Content struct {
}

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

type FileMode string
Expand Down

0 comments on commit ca33b7b

Please sign in to comment.