-
Notifications
You must be signed in to change notification settings - Fork 934
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
push now accepts log rate limit flag
Signed-off-by: Carson Long <lcarson@vmware.com> Signed-off-by: Rebecca Roberts <robertsre@vmware.com>
- Loading branch information
1 parent
950baff
commit f1f0c78
Showing
14 changed files
with
264 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package v7pushaction | ||
|
||
import ( | ||
"code.cloudfoundry.org/cli/command/translatableerror" | ||
"code.cloudfoundry.org/cli/util/manifestparser" | ||
) | ||
|
||
func HandleLogRateLimitOverride(manifest manifestparser.Manifest, overrides FlagOverrides) (manifestparser.Manifest, error) { | ||
if overrides.LogRateLimit != "" { | ||
if manifest.ContainsMultipleApps() { | ||
return manifest, translatableerror.CommandLineArgsWithMultipleAppsError{} | ||
} | ||
|
||
webProcess := manifest.GetFirstAppWebProcess() | ||
if webProcess != nil { | ||
webProcess.LogRateLimit = overrides.LogRateLimit | ||
} else { | ||
app := manifest.GetFirstApp() | ||
app.LogRateLimit = overrides.LogRateLimit | ||
} | ||
} | ||
|
||
return manifest, nil | ||
} |
149 changes: 149 additions & 0 deletions
149
actor/v7pushaction/handle_log_rate_limit_override_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
package v7pushaction_test | ||
|
||
import ( | ||
"code.cloudfoundry.org/cli/command/translatableerror" | ||
"code.cloudfoundry.org/cli/util/manifestparser" | ||
|
||
. "code.cloudfoundry.org/cli/actor/v7pushaction" | ||
|
||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
var _ = Describe("HandleLogRateLimitOverride", func() { | ||
var ( | ||
originalManifest manifestparser.Manifest | ||
transformedManifest manifestparser.Manifest | ||
overrides FlagOverrides | ||
executeErr error | ||
) | ||
|
||
BeforeEach(func() { | ||
originalManifest = manifestparser.Manifest{} | ||
overrides = FlagOverrides{} | ||
}) | ||
|
||
JustBeforeEach(func() { | ||
transformedManifest, executeErr = HandleLogRateLimitOverride(originalManifest, overrides) | ||
}) | ||
|
||
When("log rate limit is not set on a flag override", func() { | ||
BeforeEach(func() { | ||
originalManifest.Applications = []manifestparser.Application{ | ||
{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "web"}, | ||
{Type: "worker", LogRateLimit: "1B"}, | ||
}, | ||
}, | ||
} | ||
}) | ||
|
||
It("does not change the manifest", func() { | ||
Expect(executeErr).ToNot(HaveOccurred()) | ||
Expect(transformedManifest.Applications).To(ConsistOf( | ||
manifestparser.Application{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "web"}, | ||
{Type: "worker", LogRateLimit: "1B"}, | ||
}, | ||
}, | ||
)) | ||
}) | ||
}) | ||
|
||
When("manifest web process does not specify log rate limit", func() { | ||
BeforeEach(func() { | ||
overrides.LogRateLimit = "64K" | ||
|
||
originalManifest.Applications = []manifestparser.Application{ | ||
{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "web"}, | ||
}, | ||
}, | ||
} | ||
}) | ||
|
||
It("changes the log rate limit of the web process in the manifest", func() { | ||
Expect(executeErr).ToNot(HaveOccurred()) | ||
Expect(transformedManifest.Applications).To(ConsistOf( | ||
manifestparser.Application{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "web", LogRateLimit: "64K"}, | ||
}, | ||
}, | ||
)) | ||
}) | ||
}) | ||
|
||
When("manifest app has only non-web processes", func() { | ||
BeforeEach(func() { | ||
overrides.LogRateLimit = "32B" | ||
|
||
originalManifest.Applications = []manifestparser.Application{ | ||
{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "worker"}, | ||
}, | ||
}, | ||
} | ||
}) | ||
|
||
It("changes the log rate limit of the app in the manifest", func() { | ||
Expect(executeErr).ToNot(HaveOccurred()) | ||
Expect(transformedManifest.Applications).To(ConsistOf( | ||
manifestparser.Application{ | ||
LogRateLimit: "32B", | ||
Processes: []manifestparser.Process{ | ||
{Type: "worker"}, | ||
}, | ||
}, | ||
)) | ||
}) | ||
}) | ||
|
||
When("manifest app has web and non-web processes", func() { | ||
BeforeEach(func() { | ||
overrides.LogRateLimit = "4MB" | ||
|
||
originalManifest.Applications = []manifestparser.Application{ | ||
{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "worker"}, | ||
{Type: "web"}, | ||
}, | ||
LogRateLimit: "1GB", | ||
}, | ||
} | ||
}) | ||
|
||
It("changes the log rate limit of the web process in the manifest", func() { | ||
Expect(executeErr).ToNot(HaveOccurred()) | ||
Expect(transformedManifest.Applications).To(ConsistOf( | ||
manifestparser.Application{ | ||
Processes: []manifestparser.Process{ | ||
{Type: "worker"}, | ||
{Type: "web", LogRateLimit: "4MB"}, | ||
}, | ||
LogRateLimit: "1GB", | ||
}, | ||
)) | ||
}) | ||
}) | ||
|
||
When("there are multiple apps in the manifest", func() { | ||
BeforeEach(func() { | ||
overrides.LogRateLimit = "64M" | ||
|
||
originalManifest.Applications = []manifestparser.Application{ | ||
{}, | ||
{}, | ||
} | ||
}) | ||
|
||
It("returns an error", func() { | ||
Expect(executeErr).To(MatchError(translatableerror.CommandLineArgsWithMultipleAppsError{})) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package push | ||
|
||
import ( | ||
"time" | ||
|
||
"code.cloudfoundry.org/cli/api/cloudcontroller/ccversion" | ||
"code.cloudfoundry.org/cli/integration/helpers" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
. "github.com/onsi/gomega/gbytes" | ||
. "github.com/onsi/gomega/gexec" | ||
) | ||
|
||
var _ = Describe("push with log rate limit flag", func() { | ||
var ( | ||
appName string | ||
) | ||
|
||
BeforeEach(func() { | ||
helpers.SkipIfVersionLessThan(ccversion.MinVersionLogRateLimitingV3) | ||
|
||
appName = helpers.NewAppName() | ||
}) | ||
|
||
Context("when the -l flag is provided with application log rate limit", func() { | ||
It("creates the app with the specified log rate limit", func() { | ||
helpers.WithHelloWorldApp(func(dir string) { | ||
session := helpers.CustomCF(helpers.CFEnv{WorkingDirectory: dir}, | ||
PushCommandName, appName, | ||
"-l", "5K", | ||
) | ||
Eventually(session).Should(Exit(0)) | ||
}) | ||
|
||
time.Sleep(5 * time.Second) | ||
session := helpers.CF("app", appName) | ||
Eventually(session).Should(Say(`name:\s+%s`, appName)) | ||
Eventually(session).Should(Say(`last uploaded:\s+%s`, helpers.ReadableDateTimeRegex)) | ||
//TODO: check output of push command | ||
// Eventually(session).Should(Say(`log rate usage per second:\s+5K`)) | ||
// Eventually(session).Should(Say(`\s+state\s+since\s+cpu\s+memory\s+disk\s+log rate per second`)) | ||
Eventually(session).Should(Say(`#0\s+running\s+\d{4}-[01]\d-[0-3]\dT[0-2][0-9]:[0-5]\d:[0-5]\dZ`)) | ||
Eventually(session).Should(Exit(0)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.