-
Notifications
You must be signed in to change notification settings - Fork 440
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump rexml from 3.2.8 to 3.3.2 in /tools/gem_dependency (#2205)
* move files (#2157) * Refactor dirs test for hns (#2194) * adds stretchr testify mock bucket for hns dirs test * adds stretchr testify mock bucket for hns dirs test * fix PR comments * fix PR comments * fix PR comments * Migrate goo.gl links to TinyURL. (#2193) Google is [shutting down](https://developers.googleblog.com/en/google-url-shortener-links-will-no-longer-be-available/) `goo.gl` short link redirects (after [previously announcing](https://developers.googleblog.com/en/transitioning-google-url-shortener-to-firebase-dynamic-links/) that they'll continue to work). Google also previously announced that you could export your links from "the `goo.gl` console", but I can't find that anywhere (the site is now just a redirect to their stupid blog post), so I had to do this by hand. There may be some errors. * Bump Dependabot PRs (#2195) * Bump golang.org/x/sys from 0.21.0 to 0.22.0 (#2123) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.21.0 to 0.22.0. - [Commits](golang/sys@v0.21.0...v0.22.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump cloud.google.com/go/storage from 1.42.0 to 1.43.0 (#2127) Bumps [cloud.google.com/go/storage](https://github.com/googleapis/google-cloud-go) from 1.42.0 to 1.43.0. - [Release notes](https://github.com/googleapis/google-cloud-go/releases) - [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md) - [Commits](googleapis/google-cloud-go@spanner/v1.42.0...spanner/v1.43.0) --- updated-dependencies: - dependency-name: cloud.google.com/go/storage dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang from 1.22.4-alpine to 1.22.5-alpine (#2130) Bumps golang from 1.22.4-alpine to 1.22.5-alpine. --- updated-dependencies: - dependency-name: golang dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump golang.org/x/net from 0.26.0 to 0.27.0 (#2124) Bumps [golang.org/x/net](https://github.com/golang/net) from 0.26.0 to 0.27.0. - [Commits](golang/net@v0.26.0...v0.27.0) --- updated-dependencies: - dependency-name: golang.org/x/net dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump google.golang.org/grpc from 1.64.0 to 1.65.0 (#2125) Bumps [google.golang.org/grpc](https://github.com/grpc/grpc-go) from 1.64.0 to 1.65.0. - [Release notes](https://github.com/grpc/grpc-go/releases) - [Commits](grpc/grpc-go@v1.64.0...v1.65.0) --- updated-dependencies: - dependency-name: google.golang.org/grpc dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tulsi Shah <46474643+Tulsishah@users.noreply.github.com> * Bump google.golang.org/api from 0.186.0 to 0.188.0 (#2168) Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.186.0 to 0.188.0. - [Release notes](https://github.com/googleapis/google-api-go-client/releases) - [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md) - [Commits](googleapis/google-api-go-client@v0.186.0...v0.188.0) --- updated-dependencies: - dependency-name: google.golang.org/api dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tulsi Shah <46474643+Tulsishah@users.noreply.github.com> * Bump cloud.google.com/go/compute/metadata from 0.3.0 to 0.5.0 (#2166) Bumps [cloud.google.com/go/compute/metadata](https://github.com/googleapis/google-cloud-go) from 0.3.0 to 0.5.0. - [Release notes](https://github.com/googleapis/google-cloud-go/releases) - [Changelog](https://github.com/googleapis/google-cloud-go/blob/main/CHANGES.md) - [Commits](googleapis/google-cloud-go@v0.3.0...v0.5.0) --- updated-dependencies: - dependency-name: cloud.google.com/go/compute/metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tulsi Shah <46474643+Tulsishah@users.noreply.github.com> * fix merge conflict * upgrade grpc --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump rexml from 3.2.8 to 3.3.2 in /tools/gem_dependency Bumps [rexml](https://github.com/ruby/rexml) from 3.2.8 to 3.3.2. - [Release notes](https://github.com/ruby/rexml/releases) - [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md) - [Commits](ruby/rexml@v3.2.8...v3.3.2) --- updated-dependencies: - dependency-name: rexml dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Ashmeen Kaur <57195160+ashmeenkaur@users.noreply.github.com> Co-authored-by: Ankita Luthra <lankita@google.com> Co-authored-by: Aaron Jacobs <aaronjjacobs@gmail.com> Co-authored-by: Tulsi Shah <46474643+Tulsishah@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
40a857a
commit c68e8d3
Showing
14 changed files
with
238 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
// Copyright 2024 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package inode | ||
|
||
import ( | ||
"errors" | ||
"path" | ||
"testing" | ||
"time" | ||
|
||
"github.com/googlecloudplatform/gcsfuse/v2/internal/config" | ||
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage" | ||
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/gcs" | ||
"github.com/jacobsa/fuse/fuseops" | ||
"github.com/jacobsa/timeutil" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/mock" | ||
"github.com/stretchr/testify/suite" | ||
|
||
"golang.org/x/net/context" | ||
|
||
"github.com/googlecloudplatform/gcsfuse/v2/internal/gcsx" | ||
) | ||
|
||
type HNSDirTest struct { | ||
suite.Suite | ||
ctx context.Context | ||
bucket gcsx.SyncerBucket | ||
in DirInode | ||
mockBucket *storage.TestifyMockBucket | ||
} | ||
|
||
func TestHNSDirSuite(testSuite *testing.T) { suite.Run(testSuite, new(HNSDirTest)) } | ||
|
||
func (t *HNSDirTest) SetupTest() { | ||
t.ctx = context.Background() | ||
t.mockBucket = new(storage.TestifyMockBucket) | ||
t.bucket = gcsx.NewSyncerBucket( | ||
1, | ||
".gcsfuse_tmp/", | ||
t.mockBucket) | ||
t.resetDirInode(false, false, true) | ||
} | ||
|
||
func (t *HNSDirTest) resetDirInode(implicitDirs, enableNonexistentTypeCache, enableManagedFoldersListing bool) { | ||
t.resetDirInodeWithTypeCacheConfigs(implicitDirs, enableNonexistentTypeCache, enableManagedFoldersListing, config.DefaultTypeCacheMaxSizeMB, typeCacheTTL) | ||
} | ||
|
||
func (t *HNSDirTest) resetDirInodeWithTypeCacheConfigs(implicitDirs, enableNonexistentTypeCache, enableManagedFoldersListing bool, typeCacheMaxSizeMB int, typeCacheTTL time.Duration) { | ||
var anyPastTime timeutil.SimulatedClock | ||
anyPastTime.SetTime(time.Date(2015, 4, 5, 2, 15, 0, 0, time.Local)) | ||
|
||
t.in = NewDirInode( | ||
dirInodeID, | ||
NewDirName(NewRootName(""), dirInodeName), | ||
fuseops.InodeAttributes{ | ||
Uid: uid, | ||
Gid: gid, | ||
Mode: dirMode, | ||
}, | ||
implicitDirs, | ||
enableManagedFoldersListing, | ||
enableNonexistentTypeCache, | ||
typeCacheTTL, | ||
&t.bucket, | ||
&anyPastTime, | ||
&anyPastTime, | ||
typeCacheMaxSizeMB, | ||
false, | ||
) | ||
|
||
d := t.in.(*dirInode) | ||
assert.NotEqual(t.T(), nil, d) | ||
t.in.Lock() | ||
} | ||
|
||
func (t *HNSDirTest) TearDownTest() { | ||
t.in.Unlock() | ||
} | ||
|
||
func (t *HNSDirTest) TestShouldFindExplicitHNSFolder() { | ||
const name = "qux" | ||
dirName := path.Join(dirInodeName, name) + "/" | ||
folder := &gcs.Folder{ | ||
Name: dirName, | ||
MetaGeneration: int64(1), | ||
} | ||
t.mockBucket.On("GetFolder", mock.Anything, mock.Anything).Return(folder, nil) | ||
|
||
// Look up with the name. | ||
result, err := findExplicitFolder(t.ctx, &t.bucket, NewDirName(t.in.Name(), name)) | ||
|
||
assert.Nil(t.T(), err) | ||
assert.NotEqual(t.T(), nil, result.MinObject) | ||
assert.Equal(t.T(), dirName, result.FullName.GcsObjectName()) | ||
assert.Equal(t.T(), dirName, result.MinObject.Name) | ||
assert.Equal(t.T(), int64(1), result.MinObject.MetaGeneration) | ||
|
||
} | ||
|
||
func (t *HNSDirTest) TestShouldReturnNilWhenGCSFolderNotFoundForInHNS() { | ||
notFoundErr := &gcs.NotFoundError{Err: errors.New("storage: object doesn't exist")} | ||
t.mockBucket.On("GetFolder", mock.Anything, mock.Anything).Return(nil, notFoundErr) | ||
|
||
// Look up with the name. | ||
result, err := findExplicitFolder(t.ctx, &t.bucket, NewDirName(t.in.Name(), "not-present")) | ||
|
||
assert.Nil(t.T(), err) | ||
assert.Nil(t.T(), result) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// Copyright 2024 Google Inc. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
package storage | ||
|
||
import ( | ||
"context" | ||
"io" | ||
|
||
"github.com/googlecloudplatform/gcsfuse/v2/internal/storage/gcs" | ||
"github.com/stretchr/testify/mock" | ||
) | ||
|
||
// TODO: Rename to mock bucket once deprecated ogle mock bucket is removed from all usages in unit tests | ||
type TestifyMockBucket struct { | ||
mock.Mock | ||
} | ||
|
||
func (m *TestifyMockBucket) Name() string { | ||
args := m.Called() | ||
return args.String(0) | ||
} | ||
|
||
func (m *TestifyMockBucket) BucketType() gcs.BucketType { | ||
args := m.Called() | ||
return args.Get(0).(gcs.BucketType) | ||
} | ||
|
||
func (m *TestifyMockBucket) NewReader(ctx context.Context, req *gcs.ReadObjectRequest) (io.ReadCloser, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(io.ReadCloser), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) CreateObject(ctx context.Context, req *gcs.CreateObjectRequest) (*gcs.Object, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(*gcs.Object), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) CopyObject(ctx context.Context, req *gcs.CopyObjectRequest) (*gcs.Object, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(*gcs.Object), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) ComposeObjects(ctx context.Context, req *gcs.ComposeObjectsRequest) (*gcs.Object, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(*gcs.Object), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) StatObject(ctx context.Context, req *gcs.StatObjectRequest) (*gcs.MinObject, *gcs.ExtendedObjectAttributes, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(*gcs.MinObject), args.Get(1).(*gcs.ExtendedObjectAttributes), args.Error(2) | ||
} | ||
|
||
func (m *TestifyMockBucket) ListObjects(ctx context.Context, req *gcs.ListObjectsRequest) (*gcs.Listing, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(*gcs.Listing), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) UpdateObject(ctx context.Context, req *gcs.UpdateObjectRequest) (*gcs.Object, error) { | ||
args := m.Called(ctx, req) | ||
return args.Get(0).(*gcs.Object), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) DeleteObject(ctx context.Context, req *gcs.DeleteObjectRequest) error { | ||
args := m.Called(ctx, req) | ||
return args.Error(0) | ||
} | ||
|
||
func (m *TestifyMockBucket) DeleteFolder(ctx context.Context, folderName string) error { | ||
args := m.Called(ctx, folderName) | ||
return args.Error(0) | ||
} | ||
|
||
func (m *TestifyMockBucket) GetFolder(ctx context.Context, folderName string) (*gcs.Folder, error) { | ||
args := m.Called(ctx, folderName) | ||
if args.Get(0) != nil { | ||
return args.Get(0).(*gcs.Folder), nil | ||
} | ||
return nil, args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) RenameFolder(ctx context.Context, folderName string, destinationFolderId string) (*gcs.Folder, error) { | ||
args := m.Called(ctx, folderName, destinationFolderId) | ||
return args.Get(0).(*gcs.Folder), args.Error(1) | ||
} | ||
|
||
func (m *TestifyMockBucket) CreateFolder(ctx context.Context, folderName string) (*gcs.Folder, error) { | ||
args := m.Called(ctx, folderName) | ||
return args.Get(0).(*gcs.Folder), args.Error(1) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters