File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ import (
4545 "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/hostnamevalidation"
4646 "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/hotattach"
4747 "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/imageboot"
48+ "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/imagebuilder"
4849 "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/licensevalidation"
4950 "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/livemigrate"
5051 "github.com/GoogleCloudPlatform/cloud-image-tests/test_suites/loadbalancer"
@@ -344,6 +345,10 @@ func main() {
344345 imageboot .Name ,
345346 imageboot .TestSetup ,
346347 },
348+ {
349+ imagebuilder .Name ,
350+ imagebuilder .TestSetup ,
351+ },
347352 {
348353 licensevalidation .Name ,
349354 licensevalidation .TestSetup ,
Original file line number Diff line number Diff line change 1+ // Package imagebuilder is a CIT suite for testing customer images built by the GCE Image Builder.
2+ package imagebuilder
3+
4+ import (
5+ "net"
6+ "testing"
7+ )
8+
9+ func TestNetworkInterfacesUp (t * testing.T ) {
10+ interfaces , err := net .Interfaces ()
11+ if err != nil {
12+ t .Fatalf ("Failed to retrieve network interfaces via net.Interfaces() (equivalent command: 'ip -j a'): %v" , err )
13+ }
14+
15+ // Validate that we have at least one valid, UP network interface
16+ var upCount int
17+ var foundNonLoopback bool
18+
19+ for _ , iface := range interfaces {
20+ // Skip the loopback interface via FlagLoopback or name "lo"
21+ if iface .Name == "lo" || (iface .Flags & net .FlagLoopback ) != 0 {
22+ continue
23+ }
24+
25+ foundNonLoopback = true
26+
27+ // Check if the interface has the FlagUp set
28+ if (iface .Flags & net .FlagUp ) != 0 {
29+ upCount ++
30+ t .Logf ("Found active network interface: %s (Flags: %v)" , iface .Name , iface .Flags )
31+ }
32+ }
33+
34+ if ! foundNonLoopback {
35+ t .Error ("Failure: No non-loopback network interfaces were discovered on this system (equivalent command: 'ip -j a')." )
36+ }
37+
38+ if upCount == 0 {
39+ t .Error ("Failure: Found network interfaces, but zero non-loopback interfaces are 'UP' (equivalent command: 'ip -j a')." )
40+ }
41+ }
Original file line number Diff line number Diff line change 1+ // Package imagebuilder is a CIT suite for testing customer images built by the GCE Image Builder.
2+ package imagebuilder
3+
4+ import (
5+ "github.com/GoogleCloudPlatform/cloud-image-tests"
6+ )
7+
8+ // Name is the name of the test package. It must match the directory name.
9+ var Name = "imagebuilder"
10+
11+ // TestSetup sets up the test workflow.
12+ func TestSetup (t * imagetest.TestWorkflow ) error {
13+ vm1 , err := t .CreateTestVM ("networkinterfacesup" )
14+ if err != nil {
15+ return err
16+ }
17+ vm1 .RunTests ("TestNetworkInterfacesUp" )
18+
19+ return nil
20+ }
You can’t perform that action at this time.
0 commit comments