Skip to content

Commit dc0e45c

Browse files
authored
e2e_test: enable serial logs in cos to support ReportInventory test (#297)
* e2e_test: enable serial logs in cos to support ReportInventory test * govet
1 parent 0fdd9dc commit dc0e45c

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

e2e_tests/test_suites/inventoryreporting/inventory_reporting.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"log"
2121
"path"
2222
"regexp"
23+
"strings"
2324
"sync"
2425
"time"
2526

@@ -106,10 +107,14 @@ func runInventoryReportingTest(ctx context.Context, testSetup *inventoryTestSetu
106107
// Build regexes for verification.
107108
positivePatterns := []string{
108109
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),
109-
`.*"report_full_inventory".*true.*`,
110110
`.*"report_full_inventory".*false.*`,
111111
`.*Finished task "Report OSInventory".*`,
112112
}
113+
// Because COS does not output debug agent log to serial by default and we have to manually set
114+
// that up on boot the agent will report full inventory before we can see the output.
115+
if !strings.Contains(testSetup.image, "cos") {
116+
positivePatterns = append(positivePatterns, `.*"report_full_inventory".*true.*`)
117+
}
113118
positiveRegexes, err := compileRegex(positivePatterns)
114119
if err != nil {
115120
testCase.WriteFailure("Error compiling ReportInventory RPC payload regex: %v", err)

e2e_tests/test_suites/inventoryreporting/test_setup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ var (
8181
}
8282

8383
cosSetup = &inventoryTestSetup{
84-
startup: compute.BuildInstanceMetadataItem("startup-script", utils.CurlPost),
84+
startup: compute.BuildInstanceMetadataItem("startup-script", utils.CosSetup),
8585
machineType: "e2-standard-2",
8686
timeout: 5 * time.Minute,
8787
}

e2e_tests/utils/utils.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,15 @@ sleep 5
5656
done
5757
systemctl start google-osconfig-agent` + CurlPost
5858

59+
// CosSetup sets up serial logging on COS.
60+
CosSetup = `
61+
sleep 10
62+
sed -i 's/^#ForwardToConsole=no/ForwardToConsole=yes/' /etc/systemd/journald.conf
63+
sed -i 's/^#MaxLevelConsole=info/MaxLevelConsole=debug/' /etc/systemd/journald.conf
64+
MaxLevelConsole=debug
65+
systemctl force-reload systemd-journald
66+
systemctl restart google-osconfig-agent` + CurlPost
67+
5968
// CurlPost indicates agent is installed.
6069
CurlPost = `
6170
uri=http://metadata.google.internal/computeMetadata/v1/instance/guest-attributes/osconfig_tests/install_done

0 commit comments

Comments
 (0)