Skip to content

Commit

Permalink
Perf minio test (#15)
Browse files Browse the repository at this point in the history
  • Loading branch information
slhmy authored Aug 31, 2023
1 parent 3b78500 commit 2c2aac3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

with:
submodules: recursive
- name: Set up Go
uses: actions/setup-go@v3
with:
Expand Down
26 changes: 23 additions & 3 deletions tests/minio_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
package tests

import (
"io/fs"
"log"
"path/filepath"
"strings"
"testing"

"github.com/minio/minio-go/v7"
Expand All @@ -26,10 +29,9 @@ func TestMinio(T *testing.T) {
log.Printf("%#v\n", minioClient) // minioClient is now set up

// Make a new bucket called mymusic.
bucketName := "mymusic"
location := "us-east-1"
bucketName := "oj-lab-problem-packages"

err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{Region: location})
err = minioClient.MakeBucket(ctx, bucketName, minio.MakeBucketOptions{})
if err != nil {
// Check to see if we already own this bucket (which happens if you run this twice)
exists, errBucketExists := minioClient.BucketExists(ctx, bucketName)
Expand All @@ -41,4 +43,22 @@ func TestMinio(T *testing.T) {
} else {
log.Printf("Successfully created %s\n", bucketName)
}

// Upload package files
packagePath := "../test-collection/packages/icpc/hello_world"
filepath.Walk(packagePath, func(path string, info fs.FileInfo, err error) error {
if info.IsDir() {
return nil
}
relativePath := filepath.Join(filepath.Base(packagePath), strings.Replace(path, packagePath, "", 1))
println(relativePath)
_, minioErr := minioClient.FPutObject(ctx, bucketName,
relativePath,
path,
minio.PutObjectOptions{})
if minioErr != nil {
log.Fatalln(minioErr)
}
return minioErr
})
}

0 comments on commit 2c2aac3

Please sign in to comment.