@@ -16,6 +16,7 @@ import (
1616 aws "github.com/gruntwork-io/terratest/modules/aws"
1717 g "github.com/gruntwork-io/terratest/modules/git"
1818 "github.com/gruntwork-io/terratest/modules/random"
19+ "github.com/gruntwork-io/terratest/modules/shell"
1920 "github.com/gruntwork-io/terratest/modules/terraform"
2021 "golang.org/x/oauth2"
2122)
@@ -417,3 +418,52 @@ func Teardown(t *testing.T, directory string, options *terraform.Options, keyPai
417418 }
418419 aws .DeleteEC2KeyPair (t , keyPair )
419420}
421+
422+ func GetErrorLogs (t * testing.T , kubeconfigPath string ) {
423+ repoRoot , err := filepath .Abs (g .GetRepoRoot (t ))
424+ if err != nil {
425+ t .Logf ("Error getting git root directory: %v" , err )
426+ }
427+ script , err := os .ReadFile (repoRoot + "/test/scripts/getLogs.sh" )
428+ if err != nil {
429+ t .Logf ("Error reading script: %v" , err )
430+ }
431+ errorLogsScript := shell.Command {
432+ Command : "bash" ,
433+ Args : []string {"-c" , string (script )},
434+ Env : map [string ]string {
435+ "KUBECONFIG" : kubeconfigPath ,
436+ },
437+ }
438+ out , err := shell .RunCommandAndGetOutputE (t , errorLogsScript )
439+ if err != nil {
440+ t .Logf ("Error running script: %s" , err )
441+ }
442+ t .Logf ("Log script output: %s" , out )
443+ }
444+
445+ func CheckReady (t * testing.T , kubeconfigPath string ) {
446+ repoRoot , err := filepath .Abs (g .GetRepoRoot (t ))
447+ if err != nil {
448+ t .Logf ("Error getting git root directory: %v" , err )
449+ t .Fail ()
450+ }
451+ script , err := os .ReadFile (repoRoot + "/test/scripts/readyNodes.sh" )
452+ if err != nil {
453+ t .Logf ("Error reading script: %v" , err )
454+ t .Fail ()
455+ }
456+ readyScript := shell.Command {
457+ Command : "bash" ,
458+ Args : []string {"-c" , string (script )},
459+ Env : map [string ]string {
460+ "KUBECONFIG" : kubeconfigPath ,
461+ },
462+ }
463+ out , err := shell .RunCommandAndGetOutputE (t , readyScript )
464+ if err != nil {
465+ t .Logf ("Error running script: %s" , err )
466+ t .Fail ()
467+ }
468+ t .Logf ("Ready script output: %s" , out )
469+ }
0 commit comments