-
Notifications
You must be signed in to change notification settings - Fork 0
Minio testing #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Minio testing #26
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
43b7252
add local minio testing
jackschonherr 33de857
added minio tests
jackschonherr 9787b48
add minio service to dotnet.yml
jackschonherr 0115518
remove redundant port mapping
jackschonherr 9989900
add wait check for minio
jackschonherr 22e9039
add logging statement
jackschonherr dc49dc5
remove services, run simple docker command instead
jackschonherr 2938461
single line command
jackschonherr 8b84c7c
remove ubuntu branch trigger, change to dotnet 8.0.x
jackschonherr 40ce2f2
remove commented code, simplify credentials
jackschonherr ce211a4
Merge branch 'minio-testing' of https://github.com/USACE/cc-dotnet-sd…
jackschonherr d9f3a87
change credentials in workflow
jackschonherr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -5,9 +5,9 @@ name: .NET | |
|
|
||
| on: | ||
| push: | ||
| branches: [ "main", "ubuntu" ] | ||
| branches: [ "main" ] | ||
| pull_request: | ||
| branches: [ "main", "ubuntu" ] | ||
| branches: [ "main" ] | ||
|
|
||
| jobs: | ||
| build: | ||
|
|
@@ -19,10 +19,12 @@ jobs: | |
| - name: Setup .NET | ||
| uses: actions/setup-dotnet@v3 | ||
| with: | ||
| dotnet-version: 7.0.x | ||
| dotnet-version: 8.0.x | ||
| - name: Restore dependencies | ||
| run: dotnet restore | ||
| - name: Build | ||
| run: dotnet build --no-restore | ||
| # - name: Test | ||
| # run: dotnet test --no-build --verbosity normal | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bump dotnet to 8.0.x |
||
| - name: Start MinIO container | ||
| run: docker run -d --name minio -p 9000:9000 -e MINIO_ROOT_USER=USERNAME -e MINIO_ROOT_PASSWORD=PASSWORD quay.io/minio/minio server /data | ||
| - name: Test | ||
| run: dotnet test --no-build --verbosity normal | ||
This file contains hidden or 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 |
|---|---|---|
| @@ -1,82 +1,76 @@ | ||
| using System; | ||
| using Amazon.S3; | ||
| using System; | ||
| using System.IO; | ||
| using System.Text; | ||
| using Xunit; | ||
|
|
||
| namespace Usace.CC.Plugin.Test | ||
| { | ||
| public class BucketTesting | ||
| { | ||
|
|
||
| private static void SetEnv(string name, string value) | ||
| public class BucketTesting | ||
| { | ||
| Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Process); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async void CreateBucket() | ||
| { | ||
| string profileName = "KARL"; | ||
| SetEnv(profileName + "_" + EnvironmentVariables.AWS_S3_BUCKET, "test-bucket-983556"); | ||
| var bucket = new AwsBucket(profileName); | ||
| using (bucket) | ||
| { | ||
| await bucket.CreateBucketIfNotExists(); | ||
| } | ||
| } | ||
| private static void SetEnv(string name, string value) | ||
| { | ||
| Environment.SetEnvironmentVariable(name, value, EnvironmentVariableTarget.Process); | ||
| } | ||
|
|
||
| private static string CreateTestData() | ||
| { | ||
| StringBuilder sb = new StringBuilder(); | ||
| for (int i = 0; i < 100; i++) | ||
| { | ||
| sb.Append(i.ToString() + "\n"); | ||
| } | ||
| return sb.ToString(); | ||
| } | ||
| [Fact] | ||
| public async void ObjectLifeCycle() | ||
| { | ||
| string profileName = "KARL"; | ||
| SetEnv(profileName + "_" + EnvironmentVariables.AWS_S3_BUCKET, "thyroid"); | ||
| AwsBucket bucket = new AwsBucket(profileName); | ||
| private static string CreateTestData() | ||
| { | ||
| StringBuilder sb = new StringBuilder(); | ||
| for (int i = 0; i < 100; i++) | ||
| { | ||
| sb.Append(i.ToString() + "\n"); | ||
| } | ||
| return sb.ToString(); | ||
| } | ||
|
|
||
| [Fact] | ||
| public async void ObjectLifeCycle() | ||
| { | ||
| string profileName = "JACK"; | ||
| SetEnv(profileName + "_" + EnvironmentVariables.AWS_S3_BUCKET, "test-bucket-1"); | ||
| SetEnv(profileName + "_" + EnvironmentVariables.AWS_ACCESS_KEY_ID, "USERNAME"); | ||
| SetEnv(profileName + "_" + EnvironmentVariables.AWS_SECRET_ACCESS_KEY, "PASSWORD"); | ||
| SetEnv(profileName + "_" + "S3_MOCK", "true"); | ||
| SetEnv(profileName + "_" + "S3_ENDPOINT", "http://127.0.0.1:9000"); | ||
|
|
||
| await bucket.CreateBucketIfNotExists(); | ||
| using (bucket) | ||
| { | ||
| var txt = CreateTestData(); | ||
| string key = "test-object.txt"; | ||
| var created =await bucket.CreateObject(key, txt); | ||
| Assert.True(created); | ||
| using var bucket = new AwsBucket(profileName); | ||
|
|
||
| var objectExists = await bucket.ObjectExists(key); | ||
| Assert.True(objectExists, "object does not exist"); | ||
| await bucket.CreateBucketIfNotExists(); | ||
| using (bucket) | ||
| { | ||
| var txt = CreateTestData(); | ||
| string key = "test-object.txt"; | ||
| var created = await bucket.CreateObject(key, txt); | ||
| Assert.True(created); | ||
|
|
||
| var txt2 = await bucket.ReadObjectAsText(key); | ||
| Assert.True(string.Equals(txt, txt2),"content different"); | ||
| var objectExists = await bucket.ObjectExists(key); | ||
| Assert.True(objectExists, "object does not exist"); | ||
|
|
||
| var txt2 = await bucket.ReadObjectAsText(key); | ||
| Assert.True(string.Equals(txt, txt2), "content different"); | ||
|
|
||
| var dir = Path.Combine(Path.GetTempPath(), "karl-sub-dir-test"); | ||
| var locaFileName = Path.Combine(dir, "karl.txt"); | ||
| if( File.Exists(locaFileName)) | ||
| File.Delete(locaFileName); | ||
| System.Console.WriteLine("saving to local file: "+locaFileName); | ||
|
|
||
| await bucket.SaveObjectToLocalFile(key, locaFileName); | ||
| var dir = Path.Combine(Path.GetTempPath(), "jack-sub-dir-test"); | ||
| var locaFileName = Path.Combine(dir, "jack.txt"); | ||
| if (File.Exists(locaFileName)) | ||
| File.Delete(locaFileName); | ||
| System.Console.WriteLine("saving to local file: " + locaFileName); | ||
|
|
||
| Assert.True(File.Exists(locaFileName)); | ||
| await bucket.SaveObjectToLocalFile(key, locaFileName); | ||
|
|
||
| var deleted = await bucket.DeleteObject(key); | ||
| Assert.True(deleted, "object was not deleted: " + key); | ||
| bool exists = await bucket.ObjectExists(key); | ||
| Assert.False(exists," object not deleted?"); | ||
| Assert.True(File.Exists(locaFileName)); | ||
|
|
||
| await bucket.DeleteBucket(); | ||
| var deleted = await bucket.DeleteObject(key); | ||
| Assert.True(deleted, "object was not deleted: " + key); | ||
| bool exists = await bucket.ObjectExists(key); | ||
| Assert.False(exists, " object not deleted?"); | ||
|
|
||
| exists = await bucket.BucketExists(); | ||
| Assert.False(exists); | ||
| } | ||
| await bucket.DeleteBucket(); | ||
|
|
||
| exists = await bucket.BucketExists(); | ||
| Assert.False(exists); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Get rid of ubuntu branch trigger