@@ -102,11 +102,13 @@ def _validate_content_starts(self):
102
102
except requests .RequestException as e :
103
103
elapsed = time .time () - start_time
104
104
raise AssertionError (f"Failed to access content after { elapsed :.1f} s: { e } " )
105
+
106
+
105
107
106
108
def _fetch_and_print_job_logs (self ):
107
109
"""Helper to fetch and print job logs for debugging."""
108
110
try :
109
- # Get the most recent job
111
+ # Get all jobs which will include the environment restore and application logs
110
112
jobs_response = requests .get (
111
113
f"{ self .base_url } /__api__/v1/content/{ self .content ['guid' ]} /jobs" ,
112
114
headers = {"Authorization" : f"Key { self .api_key } " }
@@ -117,23 +119,30 @@ def _fetch_and_print_job_logs(self):
117
119
print ("No jobs found for content" )
118
120
return
119
121
120
- job_key = jobs [0 ]["key" ]
121
-
122
- # Get the job logs
123
- log_response = requests .get (
124
- f"{ self .base_url } /__api__/v1/content/{ self .content ['guid' ]} /jobs/{ job_key } /log" ,
125
- headers = {"Authorization" : f"Key { self .api_key } " }
126
- )
127
- logs = log_response .json ()
122
+ print (f"Found { len (jobs )} jobs for content" )
128
123
129
- print (f"Job logs for job { job_key } :" )
130
- if "entries" in logs and logs ["entries" ]:
131
- for entry in logs ["entries" ]:
132
- timestamp = entry .get ("timestamp" , "" )
133
- message = entry .get ("data" , "" )
134
- print (f" { timestamp } - { message } " )
135
- else :
136
- print ("No log entries found" )
124
+ # Iterate through all jobs
125
+ # Iterate through jobs in reverse order (most recent first)
126
+ for job in reversed (jobs ):
127
+ job_key = job ["key" ]
128
+
129
+ # Get the job logs
130
+ log_response = requests .get (
131
+ f"{ self .base_url } /__api__/v1/content/{ self .content ['guid' ]} /jobs/{ job_key } /log" ,
132
+ headers = {"Authorization" : f"Key { self .api_key } " }
133
+ )
134
+ logs = log_response .json ()
135
+
136
+ print (f"Job logs for job { job_key } :" )
137
+ if "entries" in logs and logs ["entries" ]:
138
+ for entry in logs ["entries" ]:
139
+ timestamp = entry .get ("timestamp" , "" )
140
+ message = entry .get ("data" , "" )
141
+ print (f" { timestamp } - { message } " )
142
+ else :
143
+ print (f" No log entries found for job { job_key } " )
144
+
145
+ print ("-" * 50 ) # Separator between jobs
137
146
138
147
except Exception as e :
139
148
print (f"Error fetching job logs: { e } " )
0 commit comments