Update aggregatedList in ListInstances to use pageToken

aggregatedList returns max 500 instances, but in the infra, we can have much
more than that. So use the pageToken to make sure we get all of the instances.

Bug: 144589609
Test: acloud delete ...
atest acloud_test
Change-Id: Ide06ab58378c222510522f7480334aab229fa4f8
diff --git a/internal/lib/gcompute_client.py b/internal/lib/gcompute_client.py
index bde5ac2..9371b2d 100755
--- a/internal/lib/gcompute_client.py
+++ b/internal/lib/gcompute_client.py
@@ -846,15 +846,24 @@
         Returns:
             A list of instances.
         """
-        api = self.service.instances().aggregatedList(
-            project=self._project,
-            filter=instance_filter)
-        response = self.Execute(api)
+        # aggregatedList will only return 500 results max, so if there are more,
+        # we need to send in the next page token to get the next 500 (and so on
+        # and so forth.
+        get_more_instances = True
+        page_token = None
         instances_list = []
-        for instances_data in response["items"].values():
-            if "instances" in instances_data:
-                for instance in instances_data.get("instances"):
-                    instances_list.append(instance)
+        while get_more_instances:
+            api = self.service.instances().aggregatedList(
+                project=self._project,
+                filter=instance_filter,
+                pageToken=page_token)
+            response = self.Execute(api)
+            page_token = response.get("nextPageToken")
+            get_more_instances = page_token is not None
+            for instances_data in response["items"].values():
+                if "instances" in instances_data:
+                    for instance in instances_data.get("instances"):
+                        instances_list.append(instance)
 
         return instances_list
 
diff --git a/internal/lib/gcompute_client_test.py b/internal/lib/gcompute_client_test.py
index d4f225d..690588a 100644
--- a/internal/lib/gcompute_client_test.py
+++ b/internal/lib/gcompute_client_test.py
@@ -497,7 +497,8 @@
         calls = [
             mock.call(
                 project=PROJECT,
-                filter=None),
+                filter=None,
+                pageToken=None),
         ]
         resource_mock.aggregatedList.assert_has_calls(calls)
         self.assertEqual(instances, [instance_1, instance_2])