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

Commit

Permalink
Fix bugs and improve code
Browse files Browse the repository at this point in the history
BUGS FIXED
- Add missing error checks
- Clean code that was failing static ckecks
TESTING
- Add export tests
- Add conditional static check to sanity test
  • Loading branch information
datacharmer committed Apr 23, 2019
1 parent b861d05 commit e9f40b7
Show file tree
Hide file tree
Showing 41 changed files with 447 additions and 274 deletions.
2 changes: 1 addition & 1 deletion .build/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.28.1
1.28.2
45 changes: 24 additions & 21 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ Here is a sample of the results at the end:

```
# ----------------------------------------------------------------
# cookbook - tests: 60 - pass: 60 - fail: 0
# defaults-change - tests: 81 - pass: 81 - fail: 0
# direct-paths - tests: 3096 - pass: 3096 - fail: 0
# docker-test - tests: 4870 - pass: 4870 - fail: 0
# expected_ports - tests: 6 - pass: 6 - fail: 0
# functional-test - tests: 4898 - pass: 4898 - fail: 0
# go-unit-tests - tests: 689 - pass: 689 - fail: 0
# docker-test - tests: 4878 - pass: 4878 - fail: 0
# expected_ports - tests: 18 - pass: 18 - fail: 0
# functional-test - tests: 4988 - pass: 4988 - fail: 0
# go-unit-tests - tests: 1046 - pass: 1046 - fail: 0
# ndb_test - tests: 474 - pass: 474 - fail: 0
# port-clash - tests: 180 - pass: 180 - fail: 0
# pxc_test - tests: 148 - pass: 148 - fail: 0
Expand All @@ -152,25 +153,27 @@ Here is a sample of the results at the end:
# short-versions - tests: 42 - pass: 42 - fail: 0
# ----------------------------------------------------------------
sanity_check [] - time: 3s ( 3s) - exit code: 0
go-unit-tests [] - time: 51s ( 51s) - exit code: 0
functional-test [] - time: 1916s ( 31m:56s) - exit code: 0
docker-test [1.23.0] - time: 1941s ( 32m:21s) - exit code: 0
go-unit-tests [] - time: 52s ( 52s) - exit code: 0
functional-test [] - time: 2152s ( 35m:52s) - exit code: 0
docker-test [1.28.2] - time: 2069s ( 34m:29s) - exit code: 0
defaults-change [] - time: 6s ( 6s) - exit code: 0
short-versions [] - time: 5s ( 5s) - exit code: 0
direct-paths [] - time: 16s ( 16s) - exit code: 0
short-versions [] - time: 6s ( 6s) - exit code: 0
direct-paths [] - time: 18s ( 18s) - exit code: 0
expected_ports [] - time: 2s ( 2s) - exit code: 0
read-only-replication [] - time: 17s ( 17s) - exit code: 0
ndb_test [] - time: 3s ( 3s) - exit code: 0
read-only-replication [] - time: 21s ( 21s) - exit code: 0
ndb_test [] - time: 4s ( 4s) - exit code: 0
pxc_test [] - time: 1s ( 1s) - exit code: 0
port-clash [sparse] - time: 129s ( 2m:09s) - exit code: 0
cookbook [] - time: 1s ( 1s) - exit code: 0
port-clash [sparse] - time: 141s ( 2m:21s) - exit code: 0
# Deployed: 111 sandboxes (1143 total ports) - Changed: 0
# ----------------------------------------------------------------
# cookbook - tests: 60 - pass: 60 - fail: 0
# defaults-change - tests: 81 - pass: 81 - fail: 0
# direct-paths - tests: 3096 - pass: 3096 - fail: 0
# docker-test - tests: 4870 - pass: 4870 - fail: 0
# expected_ports - tests: 6 - pass: 6 - fail: 0
# functional-test - tests: 4898 - pass: 4898 - fail: 0
# go-unit-tests - tests: 689 - pass: 689 - fail: 0
# docker-test - tests: 4878 - pass: 4878 - fail: 0
# expected_ports - tests: 18 - pass: 18 - fail: 0
# functional-test - tests: 4988 - pass: 4988 - fail: 0
# go-unit-tests - tests: 1046 - pass: 1046 - fail: 0
# ndb_test - tests: 474 - pass: 474 - fail: 0
# port-clash - tests: 180 - pass: 180 - fail: 0
# pxc_test - tests: 148 - pass: 148 - fail: 0
Expand All @@ -179,14 +182,14 @@ port-clash [sparse] - time: 129s ( 2m:09s) - exit code:
# short-versions - tests: 42 - pass: 42 - fail: 0
# ----------------------------------------------------------------
# ----------------------------------------------------------------
# Total tests: 17544
# pass : 17544
# Total tests: 18071
# pass : 18071
# fail : 0
# ----------------------------------------------------------------
OS: Darwin
Started: Fri Mar 15 21:51:57 CET 2019
Ended : Fri Mar 15 23:00:08 CET 2019
Elapsed: 4091 seconds (1h:8m:11s)
Started: Mon Apr 22 20:49:39 CEST 2019
Ended : Mon Apr 22 22:04:16 CEST 2019
Elapsed: 4477 seconds (1h:14m:37s)
# Exit code: 0
Runs concurrently: yes
```
7 changes: 7 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.28.2 22-Apr-2019
BUGS FIXED
- Add missing error checks
- Clean code that was failing static ckecks
TESTING
- Add export tests
- Add conditional static check to sanity test
1.28.1 14-Apr-2019
BUGS FIXED
Add missing '$' in recipe skip-start-replication
Expand Down
10 changes: 5 additions & 5 deletions abbreviations/abbreviations.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,14 @@ func LoadAbbreviations() {
common.Exitf(1, "error reading abbreviation file")
}
// Loads abbreviations from file
reIsEmpty := regexp.MustCompile(`^\s*$`)
reIsComment := regexp.MustCompile(`^\s*#`)
for _, abbreviation := range abbrLines {
abbreviation = strings.TrimSpace(abbreviation)
list := strings.Split(abbreviation, " ")
abbr := list[0]
isComment, _ := regexp.MatchString(`^\s*#`, abbr)
isEmpty, _ := regexp.MatchString(`^\s*#\$`, abbr)
isComment := reIsComment.MatchString(abbr)
isEmpty := reIsEmpty.MatchString(abbr)
if isComment || isEmpty {
continue
}
Expand Down Expand Up @@ -175,9 +177,7 @@ func LoadAbbreviations() {
fmt.Printf("# %s\n", os.Args)
}
}
for _, arg := range os.Args {
common.CommandLineArgs = append(common.CommandLineArgs, arg)
}
common.CommandLineArgs = append(common.CommandLineArgs, os.Args...)
}

func init() {
Expand Down
6 changes: 3 additions & 3 deletions cmd/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ var (
Note that the deletion being prevented is only the one occurring through dbdeployer.
Users can still delete locked sandboxes manually.`,
Run: lockSandbox,
Annotations: map[string]string{"export": ExportAnnotationToJson(SandboxDirExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportSandboxDir, 1)},
}

adminUnlockCmd = &cobra.Command{
Expand All @@ -373,7 +373,7 @@ Users can still delete locked sandboxes manually.`,
Short: "Unlocks a sandbox",
Long: `Removes lock, allowing deletion of a given sandbox`,
Run: unlockSandbox,
Annotations: map[string]string{"export": ExportAnnotationToJson(SandboxDirExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportSandboxDir, 1)},
}
adminUpgradeCmd = &cobra.Command{
Use: "upgrade sandbox_name newer_sandbox",
Expand All @@ -384,7 +384,7 @@ The data directory of the old sandbox will be moved to the new one.`,
Example: "dbdeployer admin upgrade msb_8_0_11 msb_8_0_12",
Run: runUpgradeSandbox,
Args: SandboxNames(2),
Annotations: map[string]string{"export": ExportAnnotationToJson(DoubleSandboxDirExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportSandboxDir, 2)},
}
adminCapabilitiesCmd = &cobra.Command{
Use: "capabilities [flavor [version]]",
Expand Down
4 changes: 2 additions & 2 deletions cmd/cookbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var showCookbookCmd = &cobra.Command{
Short: "Shows the contents of a given recipe",
Long: `Shows the contents of a given recipe, without actually running it`,
Run: showCookbook,
Annotations: map[string]string{"export": ExportAnnotationToJson(CookbookNameExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportCookbookName, 1)},
}

var createCookbookCmd = &cobra.Command{
Expand All @@ -80,7 +80,7 @@ var createCookbookCmd = &cobra.Command{
Short: "creates a script for a given recipe",
Long: `creates a script for given recipe`,
Run: createCookbook,
Annotations: map[string]string{"export": ExportAnnotationToJson(CookbookNameExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportCookbookName, 1)},
}

func init() {
Expand Down
6 changes: 2 additions & 4 deletions cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,7 @@ func deleteSandbox(cmd *cobra.Command, args []string) {
if err != nil {
common.Exitf(1, globals.ErrWhileDeletingSandbox, err)
}
for _, list := range execList {
execLists = append(execLists, list)
}
execLists = append(execLists, execList...)
}
}
concurrent.RunParallelTasksByPriority(execLists)
Expand All @@ -131,7 +129,7 @@ var deleteCmd = &cobra.Command{
Long: `Stops the sandbox (and its depending sandboxes, if any), and removes it.
Warning: this command is irreversible!`,
Run: deleteSandbox,
Annotations: map[string]string{"export": ExportAnnotationToJson(SandboxDirExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportSandboxDir, 1)},
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/delete_binaries.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ var deleteBinariesCmd = &cobra.Command{
It will fail if the directory is still used by any sandbox.
Warning: this command is irreversible!`,
Run: runDeleteBinaries,
Annotations: map[string]string{"export": ExportAnnotationToJson(DeployExport)},
Annotations: map[string]string{"export": makeExportArgs(globals.ExportVersionDir, 1)},
}

func init() {
Expand Down
Loading

0 comments on commit e9f40b7

Please sign in to comment.