Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
Add second optional argument to "dbdeployer use"
Browse files Browse the repository at this point in the history
Add second optional argument to "dbdeployer use" to indicate the executable to run within the sandbox.

e.g.: dbdeployer use rsandbox_8_0_22 s1
  • Loading branch information
datacharmer committed Oct 11, 2020
1 parent c36213b commit 6c64381
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .build/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.54.1
1.55.0
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 1.55.0 10-Oct-2020

### NEW FEATURES

* Add second optional argument to `dbdeployer use` to indicate the executable to run within the sandbox.

## 1.54.1 27-Sep-2020

### BUGS FIXED
Expand Down
22 changes: 17 additions & 5 deletions cmd/use.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func runInteractiveCmd(s string) error {
func useSandbox(cmd *cobra.Command, args []string) error {
sandboxHome, _ := cmd.Flags().GetString(globals.SandboxHomeLabel)
sandbox := ""
executable := ""
sandboxList, err := common.GetSandboxesByDate(sandboxHome)
if len(args) > 0 {
sandbox = args[0]
Expand All @@ -56,12 +57,16 @@ func useSandbox(cmd *cobra.Command, args []string) error {
}
sandbox = sandboxList[len(sandboxList)-1].SandboxName
}
if len(args) > 1 {
executable = args[1]
} else {
executable = "use"
}
for _, sb := range sandboxList {
if sb.SandboxName == sandbox {

sandboxDir := path.Join(sandboxHome, sandbox)
fmt.Printf("using %s\n", sandboxDir)
useSingle := path.Join(sandboxDir, "use")
fmt.Printf("running %s/ %s\n", sandboxDir, executable)
useSingle := path.Join(sandboxDir, executable)
startSingle := path.Join(sandboxDir, "start")
useMulti := path.Join(sandboxDir, "n1")
startMulti := path.Join(sandboxDir, "start_all")
Expand Down Expand Up @@ -89,11 +94,18 @@ func useSandbox(cmd *cobra.Command, args []string) error {
}

var useCmd = &cobra.Command{
Use: "use [sandbox_name]",
Use: "use [sandbox_name [executable]]",
Short: "uses a sandbox",
Long: `Uses a given sandbox.
If a sandbox is indicated, it will be used.
Otherwise, it will use the latest deployed sandbox`,
Otherwise, it will use the latest deployed sandbox.
Optionally, an executable can be set as second argument.`,
Example: `
$ dbdeployer use # runs "use" on the latest deployed sandbox
$ dbdeployer use rsandbox_8_0_22 # runs "m" on replication sandbox rsandbox_8_0_22
$ dbdeployer use rsandbox_8_0_22 s1 # runs "s1" on replication sandbox rsandbox_8_0_22
$ echo 'SELECT @@SERVER_ID' | dbdeployer use # pipes an SQL query to latest deployed sandbox
`,
RunE: useSandbox,
}

Expand Down
4 changes: 2 additions & 2 deletions common/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
package common

// This file was generated during build. Do not edit.
// Build time: 2020-09-26 19:32
// Build time: 2020-10-10 13:53

var VersionDef string = "1.54.1" // 2020-09-26
var VersionDef string = "1.55.0" // 2020-10-10

// Compatible version is the version used to mark compatible archives (templates, configuration).
// It is usually major.minor.0, except when we are at version 0.x, when
Expand Down
13 changes: 12 additions & 1 deletion test/functional-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1302,7 +1302,7 @@ function use_operations {
fi
echo "# use operations deploy $latest_5_6, $latest_5_7 and $latest_8_0"

run dbdeployer deploy single $latest_8_0
run dbdeployer deploy replication $latest_8_0
run dbdeployer deploy single $latest_5_6
run dbdeployer deploy single $latest_5_7

Expand All @@ -1313,6 +1313,7 @@ function use_operations {
sandboxes1=$(dbdeployer sandboxes --by-date | head -n 1)
found_80=$(echo $sandboxes1 | grep "$latest_8_0")
ok "version $latest_8_0 found as oldest sandbox" "$found_80"
sb_80_name=$(echo $found_80 | awk '{print $1}')

sandboxes3=$(dbdeployer sandboxes --by-date | tail -n 1)
found_57=$(echo $sandboxes3 | grep "$latest_5_7")
Expand Down Expand Up @@ -1351,6 +1352,16 @@ function use_operations {

ok_contains "version used is $latest_5_6" "$found_version" "$latest_5_6"

found_version=$(echo 'select version()' | dbdeployer use "$sb_80_name" | tail -n 1)
found_server_id1=$(echo 'select @@server_id' | dbdeployer use "$sb_80_name" | tail -n 1)
found_server_id2=$(echo 'select @@server_id' | dbdeployer use "$sb_80_name" s1 | tail -n 1)
found_server_id3=$(echo 'select @@server_id' | dbdeployer use "$sb_80_name" s2 | tail -n 1)

ok_contains "version used is $latest_8_0" "$found_version" "$latest_8_0"
ok_contains "server ID in node 1 is 100 " "$found_server_id1" "100"
ok_contains "server ID in node 2 is 200 " "$found_server_id2" "200"
ok_contains "server ID in node 3 is 300 " "$found_server_id3" "300"

dbdeployer delete ALL --skip-confirm
results "use $latest_5_6 $latest_5_7 and $latest_8_0 - after deletion"
}
Expand Down

0 comments on commit 6c64381

Please sign in to comment.