Skip to content

Commit

Permalink
Used Minio server instead of running here
Browse files Browse the repository at this point in the history
  • Loading branch information
pewssh committed Nov 22, 2024
1 parent bdfa941 commit cb41707
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 73 deletions.
51 changes: 0 additions & 51 deletions internal/cli/util/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package cliutils
import (
"bufio"
"bytes"
"context"
"crypto/rand"
"fmt"
"io"
Expand Down Expand Up @@ -397,44 +396,6 @@ func LogOutput(stdout io.Reader, t *test.SystemTest) {
}
}

func RunMinioServer(accessKey, secretKey string, t *test.SystemTest) (string, error) {
rawOutput, err := RunCommandWithoutRetry("../zbox newallocation --lock 10 --configDir ../config2")
if err != nil {
return "", fmt.Errorf("error running zbox newallocation command: %v", rawOutput)
}
cmdString := "export MINIO_ROOT_USER=" + accessKey + " && export MINIO_ROOT_PASSWORD=" + secretKey + " && ../minio gateway zcn --configDir ../config2 " + " --console-address :8000"

cmdParts, err := SplitCmdString(cmdString)
if err != nil {
return "", fmt.Errorf("error splitting command string: %w", err)
}
ctx := context.Background()

runCmd := exec.CommandContext(ctx, cmdParts[0], cmdParts[1:]...) // #nosec G204: subprocess launched with tainted input

runCmd.SysProcAttr = &syscall.SysProcAttr{
Setpgid: true,
}

var stdout, stderr bytes.Buffer
runCmd.Stdout = io.MultiWriter(os.Stdout, &stdout)
runCmd.Stderr = io.MultiWriter(os.Stderr, &stderr)

log.Printf("Generated command: %s %s", runCmd.Path, runCmd.Args)

// Start the MinIO server command
err = runCmd.Start()
if err != nil {
t.Log("Error starting MinIO server: ", err)
return "", fmt.Errorf("error starting MinIO server: %w", err)
}
t.Logf("Stderr:\n%s", stderr.String())
t.Logf("Stdout:\n%s", stdout.String())

time.Sleep(15 * time.Second)
return stdout.String(), nil
}

func GetAllocationID(path string) string {
file, err := os.Open(path)
if err != nil {
Expand Down Expand Up @@ -524,15 +485,3 @@ func ReadFileMC(testSetup *testing.T) McConfiguration {
config.Concurrent = strconv.FormatInt(int64(concurrent), 10)
return config
}

func SetupMinioConfig(testSetup *testing.T) Configuration {
t := test.NewSystemTest(testSetup)
_, err := RunMinioServer("rootroot", "rootroot", t)
if err != nil {
testSetup.Fatalf("%v", err)
}

config := ReadFile(testSetup)
testSetup.Logf("Minio server Started")
return config
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,6 @@ func TestZs3ServerReplication(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
config := cli_utils.ReadFileMC(testSetup)

if config.UseCommand {
runCmd, err := cli_utils.RunMinioServer(config.AccessKey, config.SecretKey, t)
if err != nil {
testSetup.Fatalf("%v", err)
}
testSetup.Logf(runCmd)
}

t.RunWithTimeout("Test for replication", 4000*time.Second, func(t *test.SystemTest) {
t.Log(config.Server, "server")
command_primary := "../mc alias set primary http://" + config.Server + ":" + config.HostPort + " " + config.AccessKey + " " + config.SecretKey + " --api S3v2"
Expand Down
8 changes: 4 additions & 4 deletions tests/cli_tests/mc_tests/mc_hosts.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
server: localhost
port: 9000
server: 37.27.203.97
port: 8000
# access_key: someminiouser
# secret_key: someminiopassword
concurrent: 900
secondary_server: localhost
secondary_port: 9000
secondary_server: 37.27.203.97
secondary_port: 8000
use_command: True
# server: 65.109.152.43
# port: 9001
Expand Down
4 changes: 1 addition & 3 deletions tests/cli_tests/zs3server_tests/1_mixed_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@ import (
)

func TestZs3serverMixedWarpTests(testSetup *testing.T) {
config := cliutils.ReadFile(testSetup)
t := test.NewSystemTest(testSetup)
config := cliutils.SetupMinioConfig(testSetup)
defer cliutils.KillMinioProcesses()

t.RunSequentiallyWithTimeout("Warp Mixed Benchmark", 40*time.Minute, func(t *test.SystemTest) {
commandGenerated := "../warp mixed --host=" + config.Server + ":" + config.HostPort + " --access-key=" + config.AccessKey + " --secret-key=" + config.SecretKey + " --objects=" + "22" + " --duration=" + "30s" + " --obj.size=" + "256B"

output, err := cliutils.RunCommand(t, commandGenerated, 1, time.Hour*2)
if err != nil {
testSetup.Fatalf("Error running warp mixed: %v\nOutput: %s", err, output)
Expand Down
3 changes: 1 addition & 2 deletions tests/cli_tests/zs3server_tests/2_put_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
)

func TestZs3serverPutWarpTests(testSetup *testing.T) {
config := cliutils.ReadFile(testSetup)
t := test.NewSystemTest(testSetup)
config := cliutils.SetupMinioConfig(testSetup)
defer cliutils.KillMinioProcesses()

commandGenerated := "../warp put --host=" + config.Server + ":" + config.HostPort + " --access-key=" + config.AccessKey + " --secret-key=" + config.SecretKey + " --concurrent " + config.Concurrent + " --duration 30s" + " --obj.size " + config.ObjectSize
output, err := cliutils.RunCommand(t, commandGenerated, 1, time.Hour*2)
Expand Down
3 changes: 1 addition & 2 deletions tests/cli_tests/zs3server_tests/3_fanout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@ func TestZs3serverFanoutTests(testSetup *testing.T) {
log.Printf("Error setting environment variable: %v", err)
}

config := cliutils.ReadFile(testSetup)
t := test.NewSystemTest(testSetup)
config := cliutils.SetupMinioConfig(testSetup)
defer cliutils.KillMinioProcesses()

commandGenerated := "../warp fanout --copies=50 --obj.size=512KiB --host=" + config.Server + ":" + config.HostPort + " --access-key=" + config.AccessKey + " --secret-key=" + config.SecretKey + " --concurrent " + config.Concurrent + " --duration 30s" + " --obj.size " + config.ObjectSize

Expand Down
3 changes: 1 addition & 2 deletions tests/cli_tests/zs3server_tests/4_listing_purge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@ import (
)

func TestZs3serverListTests(testSetup *testing.T) {
config := cliutils.ReadFile(testSetup)
t := test.NewSystemTest(testSetup)
config := cliutils.SetupMinioConfig(testSetup)
defer cliutils.KillMinioProcesses()

t.RunSequentiallyWithTimeout("Warp List Benchmark", 40*time.Minute, func(t *test.SystemTest) {
commandGenerated := "../warp get --host=" + config.Server + ":" + config.HostPort + " --access-key=" + config.AccessKey + " --secret-key=" + config.SecretKey + " --duration 30s" + " --obj.size " + config.ObjectSize + " --objects " + config.ObjectCount
Expand Down
2 changes: 1 addition & 1 deletion tests/cli_tests/zs3server_tests/hosts.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
server: localhost
server: 37.27.203.97
port: 9000
# access_key: someminiouser
# secret_key: someminiopassword
Expand Down

0 comments on commit cb41707

Please sign in to comment.