Skip to content

Commit

Permalink
e2e_test: enable serial logs in cos to support ReportInventory test (#…
Browse files Browse the repository at this point in the history
…297)

* e2e_test: enable serial logs in cos to support ReportInventory test

* govet
  • Loading branch information
adjackura authored Mar 19, 2021
1 parent 0fdd9dc commit dc0e45c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"log"
"path"
"regexp"
"strings"
"sync"
"time"

Expand Down Expand Up @@ -106,10 +107,14 @@ func runInventoryReportingTest(ctx context.Context, testSetup *inventoryTestSetu
// Build regexes for verification.
positivePatterns := []string{
fmt.Sprintf(`.*Calling ReportInventory with request containing hostname %s, short name %s, [1-9]+[0-9]* installed packages, [0-9]+ available packages`, testSetup.hostname, testSetup.shortName),
`.*"report_full_inventory".*true.*`,
`.*"report_full_inventory".*false.*`,
`.*Finished task "Report OSInventory".*`,
}
// Because COS does not output debug agent log to serial by default and we have to manually set
// that up on boot the agent will report full inventory before we can see the output.
if !strings.Contains(testSetup.image, "cos") {
positivePatterns = append(positivePatterns, `.*"report_full_inventory".*true.*`)
}
positiveRegexes, err := compileRegex(positivePatterns)
if err != nil {
testCase.WriteFailure("Error compiling ReportInventory RPC payload regex: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion e2e_tests/test_suites/inventoryreporting/test_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ var (
}

cosSetup = &inventoryTestSetup{
startup: compute.BuildInstanceMetadataItem("startup-script", utils.CurlPost),
startup: compute.BuildInstanceMetadataItem("startup-script", utils.CosSetup),
machineType: "e2-standard-2",
timeout: 5 * time.Minute,
}
Expand Down
9 changes: 9 additions & 0 deletions e2e_tests/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ sleep 5
done
systemctl start google-osconfig-agent` + CurlPost

// CosSetup sets up serial logging on COS.
CosSetup = `
sleep 10
sed -i 's/^#ForwardToConsole=no/ForwardToConsole=yes/' /etc/systemd/journald.conf
sed -i 's/^#MaxLevelConsole=info/MaxLevelConsole=debug/' /etc/systemd/journald.conf
MaxLevelConsole=debug
systemctl force-reload systemd-journald
systemctl restart google-osconfig-agent` + CurlPost

// CurlPost indicates agent is installed.
CurlPost = `
uri=http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/osconfig_tests/install_done
Expand Down

0 comments on commit dc0e45c

Please sign in to comment.