@@ -2540,7 +2540,7 @@ func (testCtx *VPCPeeringTestCtx) gatewayPeeringNATTest(ctx context.Context) (bo
25402540 // Wait for NAT gateway peering to take effect
25412541 time .Sleep (15 * time .Second )
25422542
2543- if err := DoVLABTestConnectivity (ctx , testCtx .workDir , testCtx .cacheDir , testCtx .tcOpts ); err != nil {
2543+ if err := DoVLABTestConnectivity (ctx , testCtx .vlabCfg . WorkDir , testCtx .vlabCfg . CacheDir , testCtx .tcOpts ); err != nil {
25442544 return false , reverts , fmt .Errorf ("testing NAT gateway peering connectivity: %w" , err )
25452545 }
25462546
@@ -2706,9 +2706,15 @@ func (testCtx *VPCPeeringTestCtx) gatewayPeeringOverlapNATTest(ctx context.Conte
27062706 // Wait for network configuration
27072707 time .Sleep (10 * time .Second )
27082708
2709+ // Get SSH connection for server-02
2710+ serverSSH , err := testCtx .getSSH (ctx , serverToDetach )
2711+ if err != nil {
2712+ return false , reverts , fmt .Errorf ("getting ssh config for server %s: %w" , serverToDetach , err )
2713+ }
2714+
27092715 // Clean up and reconfigure server-02 for the new overlapping VPC
2710- if err := execNodeCmd ( testCtx . hhfabBin , testCtx . workDir , serverToDetach , "/opt/bin/hhnet cleanup" ); err != nil {
2711- return false , reverts , fmt .Errorf ("cleaning up server %s: %w" , serverToDetach , err )
2716+ if _ , stderr , err := serverSSH . Run ( ctx , "/opt/bin/hhnet cleanup" ); err != nil {
2717+ return false , reverts , fmt .Errorf ("cleaning up server %s: %w: %s " , serverToDetach , err , stderr )
27122718 }
27132719
27142720 // Get connection for netconf command
@@ -2723,8 +2729,9 @@ func (testCtx *VPCPeeringTestCtx) gatewayPeeringOverlapNATTest(ctx context.Conte
27232729 return false , reverts , fmt .Errorf ("getting netconf cmd for server %s: %w" , serverToDetach , err )
27242730 }
27252731
2726- if err := execNodeCmd (testCtx .hhfabBin , testCtx .workDir , serverToDetach , fmt .Sprintf ("/opt/bin/hhnet %s" , netconfCmd )); err != nil {
2727- return false , reverts , fmt .Errorf ("configuring server %s: %w" , serverToDetach , err )
2732+ cmd := fmt .Sprintf ("/opt/bin/hhnet %s" , netconfCmd )
2733+ if _ , stderr , err := serverSSH .Run (ctx , cmd ); err != nil {
2734+ return false , reverts , fmt .Errorf ("configuring server %s: %w: %s" , serverToDetach , err , stderr )
27282735 }
27292736
27302737 // Set up NAT gateway peering between the overlapping VPCs
@@ -2746,7 +2753,7 @@ func (testCtx *VPCPeeringTestCtx) gatewayPeeringOverlapNATTest(ctx context.Conte
27462753 time .Sleep (15 * time .Second )
27472754
27482755 // Test connectivity using the standard test framework
2749- if err := DoVLABTestConnectivity (ctx , testCtx .workDir , testCtx .cacheDir , testCtx .tcOpts ); err != nil {
2756+ if err := DoVLABTestConnectivity (ctx , testCtx .vlabCfg . WorkDir , testCtx .vlabCfg . CacheDir , testCtx .tcOpts ); err != nil {
27502757 return false , reverts , fmt .Errorf ("testing NAT gateway peering connectivity: %w" , err )
27512758 }
27522759
@@ -3431,14 +3438,15 @@ type JUnitReport struct {
34313438}
34323439
34333440type JUnitTestSuite struct {
3434- XMLName xml.Name `xml:"testsuite"`
3435- Name string `xml:"name,attr"`
3436- Tests int `xml:"tests,attr"`
3437- Failures int `xml:"failures,attr"`
3438- Skipped int `xml:"skipped,attr"`
3439- Time float64 `xml:"time,attr"`
3440- TimeHuman time.Duration `xml:"-"`
3441- TestCases []JUnitTestCase `xml:"testcase"`
3441+ XMLName xml.Name `xml:"testsuite"`
3442+ Name string `xml:"name,attr"`
3443+ Tests int `xml:"tests,attr"`
3444+ Failures int `xml:"failures,attr"`
3445+ Skipped int `xml:"skipped,attr"`
3446+ ExpectedFails int `xml:"expectedfails,attr"`
3447+ Time float64 `xml:"time,attr"`
3448+ TimeHuman time.Duration `xml:"-"`
3449+ TestCases []JUnitTestCase `xml:"testcase"`
34423450}
34433451
34443452type SkipFlags struct {
@@ -3504,14 +3512,21 @@ func (sf *SkipFlags) PrettyPrint() string {
35043512}
35053513
35063514type JUnitTestCase struct {
3507- XMLName xml.Name `xml:"testcase"`
3508- ClassName string `xml:"classname,attr"`
3509- Name string `xml:"name,attr"`
3510- Time float64 `xml:"time,attr"`
3511- Failure * Failure `xml:"failure,omitempty"`
3512- Skipped * Skipped `xml:"skipped,omitempty"`
3513- F TestFunc `xml:"-"` // function to run
3514- SkipFlags SkipFlags `xml:"-"` // flags to determine whether to skip the test
3515+ XMLName xml.Name `xml:"testcase"`
3516+ ClassName string `xml:"classname,attr"`
3517+ Name string `xml:"name,attr"`
3518+ Time float64 `xml:"time,attr"`
3519+ Failure * Failure `xml:"failure,omitempty"`
3520+ Skipped * Skipped `xml:"skipped,omitempty"`
3521+ ExpectedFail * ExpectedFail `xml:"expectedfail,omitempty"`
3522+ F TestFunc `xml:"-"` // function to run
3523+ SkipFlags SkipFlags `xml:"-"` // flags to determine whether to skip the test
3524+ ExpectFailure bool `xml:"-"`
3525+ }
3526+
3527+ type ExpectedFail struct {
3528+ XMLName xml.Name `xml:"expectedfail"`
3529+ Message string `xml:"message,attr,omitempty"`
35153530}
35163531
35173532type Failure struct {
@@ -3533,21 +3548,25 @@ func printTestSuite(ts *JUnitTestSuite) {
35333548}
35343549
35353550func printSuiteResults (ts * JUnitTestSuite ) {
3536- var numFailed , numSkipped , numPassed int
3551+ var numFailed , numSkipped , numPassed , numXFail int
35373552 slog .Info ("Test suite results" , "suite" , ts .Name )
35383553 for _ , test := range ts .TestCases {
3539- if test .Skipped != nil { //nolint:gocritic
3554+ switch {
3555+ case test .Skipped != nil :
35403556 slog .Warn ("SKIP" , "test" , test .Name , "reason" , test .Skipped .Message )
35413557 numSkipped ++
3542- } else if test .Failure != nil {
3558+ case test .ExpectedFail != nil :
3559+ slog .Info ("XFAIL" , "test" , test .Name , "reason" , test .ExpectedFail .Message )
3560+ numXFail ++
3561+ case test .Failure != nil :
35433562 slog .Error ("FAIL" , "test" , test .Name , "error" , strings .ReplaceAll (test .Failure .Message , "\n " , "; " ))
35443563 numFailed ++
3545- } else {
3564+ default :
35463565 slog .Info ("PASS" , "test" , test .Name )
35473566 numPassed ++
35483567 }
35493568 }
3550- slog .Info ("Test suite summary" , "tests" , len (ts .TestCases ), "passed" , numPassed , "skipped" , numSkipped , "failed" , numFailed , "duration" , ts .TimeHuman )
3569+ slog .Info ("Test suite summary" , "tests" , len (ts .TestCases ), "passed" , numPassed , "skipped" , numSkipped , "failed" , numFailed , "xfail" , numXFail , " duration" , ts .TimeHuman )
35513570}
35523571
35533572func pauseOnFail () {
@@ -3610,7 +3629,8 @@ func doRunTests(ctx context.Context, testCtx *VPCPeeringTestCtx, ts *JUnitTestSu
36103629 // - we then apply reverts in reverse order, and if any of them fails, we mark the test as failed, and pause (potentially a second time) if configured to do so.
36113630 // we also stop applying reverts at the first failure
36123631 // - finally, if we get to the end without any errors, we log the test as passed
3613- if skip {
3632+ switch {
3633+ case skip :
36143634 var skipMsg string
36153635 if err != nil {
36163636 skipMsg = err .Error ()
@@ -3624,8 +3644,14 @@ func doRunTests(ctx context.Context, testCtx *VPCPeeringTestCtx, ts *JUnitTestSu
36243644 }
36253645 ts .Skipped ++
36263646 slog .Warn ("SKIP" , "test" , test .Name , "reason" , skipMsg )
3627- }
3628- if err != nil {
3647+ case test .ExpectFailure && err != nil :
3648+ ts .TestCases [i ].ExpectedFail = & ExpectedFail {
3649+ Message : err .Error (),
3650+ }
3651+ ts .ExpectedFails ++
3652+ slog .Info ("XFAIL" , "test" , test .Name , "reason" , err .Error ())
3653+ err = nil
3654+ case err != nil :
36293655 ts .TestCases [i ].Failure = & Failure {
36303656 Message : err .Error (),
36313657 }
@@ -3705,10 +3731,17 @@ func failAllTests(suite *JUnitTestSuite, err error) *JUnitTestSuite {
37053731 if suite .TestCases [i ].Skipped != nil {
37063732 continue
37073733 }
3708- suite .TestCases [i ].Failure = & Failure {
3709- Message : err .Error (),
3734+ if suite .TestCases [i ].ExpectFailure {
3735+ suite .TestCases [i ].ExpectedFail = & ExpectedFail {
3736+ Message : err .Error (),
3737+ }
3738+ suite .ExpectedFails ++
3739+ } else {
3740+ suite .TestCases [i ].Failure = & Failure {
3741+ Message : err .Error (),
3742+ }
3743+ suite .Failures ++
37103744 }
3711- suite .Failures ++
37123745 }
37133746
37143747 return suite
@@ -4057,15 +4090,17 @@ func makeVpcPeeringsBasicSuite(testCtx *VPCPeeringTestCtx) *JUnitTestSuite {
40574090 },
40584091 },
40594092 {
4060- Name : "Gateway Peering with NAT" ,
4061- F : testCtx .gatewayPeeringNATTest ,
4093+ Name : "Gateway Peering with NAT" ,
4094+ F : testCtx .gatewayPeeringNATTest ,
4095+ ExpectFailure : true ,
40624096 SkipFlags : SkipFlags {
40634097 NoGateway : true ,
40644098 },
40654099 },
40664100 {
4067- Name : "Gateway Peering Overlapping Subnets with NAT" ,
4068- F : testCtx .gatewayPeeringOverlapNATTest ,
4101+ Name : "Gateway Peering Overlapping Subnets with NAT" ,
4102+ F : testCtx .gatewayPeeringOverlapNATTest ,
4103+ ExpectFailure : true ,
40694104 SkipFlags : SkipFlags {
40704105 NoGateway : true ,
40714106 },
0 commit comments