@@ -79,14 +79,22 @@ const (
79
79
cloudImageTmpl = "docker.elastic.co/observability-ci/elastic-agent:%s"
80
80
)
81
81
82
- // Aliases for commands required by master makefile
83
- var Aliases = map [string ]interface {}{
84
- "build" : Build .All ,
85
- "demo" : Demo .Enroll ,
86
- }
87
- var errNoManifest = errors .New ("missing ManifestURL environment variable" )
88
- var errNoAgentDropPath = errors .New ("missing AGENT_DROP_PATH environment variable" )
89
- var errAtLeastOnePlatform = errors .New ("elastic-agent package is expected to build at least one platform package" )
82
+ var (
83
+ // Aliases for commands required by master makefile
84
+ Aliases = map [string ]interface {}{
85
+ "build" : Build .All ,
86
+ "demo" : Demo .Enroll ,
87
+ }
88
+
89
+ errNoManifest = errors .New ("missing ManifestURL environment variable" )
90
+ errNoAgentDropPath = errors .New ("missing AGENT_DROP_PATH environment variable" )
91
+ errAtLeastOnePlatform = errors .New ("elastic-agent package is expected to build at least one platform package" )
92
+
93
+ // goIntegTestTimeout is the timeout passed to each instance of 'go test' used in integration tests.
94
+ goIntegTestTimeout = 2 * time .Hour
95
+ // goProvisionAndTestTimeout is the timeout used for both provisioning and running tests.
96
+ goProvisionAndTestTimeout = goIntegTestTimeout + 30 * time .Minute
97
+ )
90
98
91
99
func init () {
92
100
common .RegisterCheckDeps (Update , Check .All )
@@ -2069,7 +2077,7 @@ func (Integration) TestOnRemote(ctx context.Context) error {
2069
2077
extraFlags = append (extraFlags , goTestFlags ... )
2070
2078
}
2071
2079
extraFlags = append (extraFlags , "-test.shuffle" , "on" ,
2072
- "-test.timeout" , "2h" , "-test.run" , "^(" + strings .Join (packageTests , "|" )+ ")$" )
2080
+ "-test.timeout" , goIntegTestTimeout . String () , "-test.run" , "^(" + strings .Join (packageTests , "|" )+ ")$" )
2073
2081
params := mage.GoTestArgs {
2074
2082
LogName : testName ,
2075
2083
OutputFile : fileName + ".out" ,
@@ -2091,6 +2099,13 @@ func (Integration) TestOnRemote(ctx context.Context) error {
2091
2099
}
2092
2100
2093
2101
func integRunner (ctx context.Context , matrix bool , singleTest string ) error {
2102
+ if _ , ok := ctx .Deadline (); ! ok {
2103
+ // If the context doesn't have a timeout (usually via the mage -t option), give it one.
2104
+ var cancel context.CancelFunc
2105
+ ctx , cancel = context .WithTimeout (ctx , goProvisionAndTestTimeout )
2106
+ defer cancel ()
2107
+ }
2108
+
2094
2109
for {
2095
2110
failedCount , err := integRunnerOnce (ctx , matrix , singleTest )
2096
2111
if err != nil {
0 commit comments