Skip to content

Commit

Permalink
review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sanyamsinghal committed Mar 5, 2025
1 parent cdae1ec commit 9ca3a7f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 64 deletions.
24 changes: 0 additions & 24 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,6 @@ jobs:
with:
go-version: "1.23.1"

# - name: Build
# run: |
# cd yb-voyager
# go build -v ./...

# # required by godror driver used in the tests
# - name: Install Oracle Instant Clients
# run: |
# # Download and install the YB APT repository package
# wget https://s3.us-west-2.amazonaws.com/downloads.yugabyte.com/repos/reporpms/yb-apt-repo_1.0.0_all.deb
# sudo apt-get install -y ./yb-apt-repo_1.0.0_all.deb
# sudo apt-get update -y

# # Install Oracle Instant Client packages using the defined version
# sudo apt-get install -y oracle-instantclient-tools=${{ env.ORACLE_INSTANT_CLIENT_VERSION }}
# sudo apt-get install -y oracle-instantclient-basic=${{ env.ORACLE_INSTANT_CLIENT_VERSION }}
# sudo apt-get install -y oracle-instantclient-devel=${{ env.ORACLE_INSTANT_CLIENT_VERSION }}
# sudo apt-get install -y oracle-instantclient-jdbc=${{ env.ORACLE_INSTANT_CLIENT_VERSION }}
# sudo apt-get install -y oracle-instantclient-sqlplus=${{ env.ORACLE_INSTANT_CLIENT_VERSION }}

# # Clean up the YB APT repository package
# sudo apt-get remove -y yb-apt-repo
# rm -f yb-apt-repo_1.0.0_all.deb

- name: Run installer script to setup voyager and dependencies for running integration tests
run: |
cd installer_scripts
Expand Down
47 changes: 7 additions & 40 deletions yb-voyager/test/utils/cmdutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,10 @@ package testutils

import (
"fmt"
"io"
"log"
"os"
"os/exec"
"strconv"
"strings"
"sync"
"time"

"github.com/yugabyte/yb-voyager/yb-voyager/src/utils"
Expand Down Expand Up @@ -69,62 +66,32 @@ func RunVoyagerCommmand(container testcontainers.TestContainer,
}
}

// 1) Build the command to run.
// Build the command to run.
cmdArgs = append(connectionArgs, cmdArgs...)
cmdStr := fmt.Sprintf("yb-voyager %s %s", cmdName, strings.Join(cmdArgs, " "))
cmd := exec.Command("/bin/bash", "-c", cmdStr)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

// don't send to callhome for tests
cmd.Env = append(os.Environ(), "YB_VOYAGER_SEND_DIAGNOSTICS=false")

// 2) Get the stdout and stderr pipes.
stdoutPipe, err := cmd.StdoutPipe()
if err != nil {
return fmt.Errorf("failed to get stdout pipe: %w", err)
}
stderrPipe, err := cmd.StderrPipe()
if err != nil {
return fmt.Errorf("failed to get stderr pipe: %w", err)
}

// 3) Start the voyager command asynchronously.
// Start the voyager command asynchronously.
if err = cmd.Start(); err != nil {
return fmt.Errorf("failed to start voyager command: %w", err)
}

// 4) Launch goroutines to stream output live to console.
var wg sync.WaitGroup
wg.Add(2)

go func() {
defer wg.Done()
// Copy stdout to os.Stdout.
if _, err := io.Copy(os.Stdout, stdoutPipe); err != nil {
log.Printf("Error copying stdout: %v", err)
}
}()

go func() {
defer wg.Done()
// Copy stderr to os.Stderr.
if _, err := io.Copy(os.Stderr, stderrPipe); err != nil {
log.Printf("Error copying stderr: %v", err)
}
}()

// 5) Execute the during-command function (if provided).
// Execute the during command function (if provided).
if doDuringCmd != nil {
// delay for 2 seconds to ensure the command has started.
time.Sleep(2 * time.Second)
doDuringCmd()
}

// 6) Wait for the voyager command to finish.
// Wait for the voyager command to finish.
if err := cmd.Wait(); err != nil {
return fmt.Errorf("voyager command exited with error: %w", err)
}

// 7) Wait for the output goroutines to complete.
wg.Wait()

return nil
}

0 comments on commit 9ca3a7f

Please sign in to comment.