Skip to content

Commit

Permalink
fix: Allow for bytes as units in container metrics regex (cloudfoundr…
Browse files Browse the repository at this point in the history
…y#1105)

Adjusts container metrics regex to allow for `cf app` output to display `memory` and `disk` output in bytes.

Fixes `windows` and `apps` suite failures.

Previously, the cf CLI defaulted to `K`, `M`, or `G` as the units for those columns. However, cf CLI v7.7.10/v8.7.10 bumped `code.cloudfoundry.org/bytefmt` to include [this change](cloudfoundry/bytefmt@854d396), which now outputs `B` as the unit in certain circumstances.

---------

Co-authored-by: Carson Long <12767276+ctlong@users.noreply.github.com>
  • Loading branch information
2 people authored and arjun024 committed Jun 7, 2024
1 parent d753657 commit ddf548b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ var _ = AppsDescribe("Application Lifecycle", func() {

Context("is able to retrieve container metrics", func() {
// #0 running 2015-06-10 02:22:39 PM 0.0% 48.7M of 2G 14M of 1G 68B/s of unlimited
var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`)
var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`)
stats := func() (float64, float64, float64) {
app := cf.Cf("app", appName)
Expect(app.Wait()).To(Exit(0))
Expand Down
2 changes: 1 addition & 1 deletion windows/lifecycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var _ = WindowsDescribe("Application Lifecycle", func() {

By("verifying reported usage", func() {
// #0 running 2015-06-10 02:22:39 PM 0.0% 48.7M of 2G 14M of 1G 68B/s of unlimited
var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[KMG]? of (?:[\d\.]+)[KMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`)
var metrics = regexp.MustCompile(`running.*(?:[\d\.]+)%\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]? of (?:[\d\.]+)[BKMG]?\s+([\d\.]+)[BKMG]?/s of (?:[\d\.]+[BKMG]?/s|unlimited)`)
stats := func() (float64, float64, float64) {
helpers.CurlApp(Config, appName, "/logspew/1024")

Expand Down

0 comments on commit ddf548b

Please sign in to comment.