Exemplo n.º 1
0
    def Run(self):
        with test_lib.FakeTime(42):
            hunt_id = self.CreateHunt(description="the hunt",
                                      creator=self.token.username)
            hunt.StartHunt(hunt_id)

            client_ids = self.SetupClients(5)

            self.AssignTasksToClients(client_ids=client_ids[:-1])
            # Only running the hunt on a single client, as SampleMock
            # implementation is non-deterministic in terms of resources
            # usage that gets reported back to the hunt.
            self.RunHunt(client_ids=[client_ids[-1]], failrate=0)

        # Create replace dictionary.
        replace = {hunt_id: "H:123456", hunt_id + ":hunt": "H:123456"}

        self.Check("ListHuntClients",
                   args=hunt_plugin.ApiListHuntClientsArgs(
                       hunt_id=hunt_id, client_status="STARTED"),
                   replace=replace)
        self.Check("ListHuntClients",
                   args=hunt_plugin.ApiListHuntClientsArgs(
                       hunt_id=hunt_id, client_status="OUTSTANDING"),
                   replace=replace)
        self.Check("ListHuntClients",
                   args=hunt_plugin.ApiListHuntClientsArgs(
                       hunt_id=hunt_id, client_status="COMPLETED"),
                   replace=replace)
Exemplo n.º 2
0
    def Run(self):
        with test_lib.FakeTime(42):
            hunt_urn = self.StartHunt(description="the hunt")

            if data_store.RelationalDBReadEnabled():
                clients = self.SetupTestClientObjects(5)
                client_ids = sorted(clients)
            else:
                client_ids = [urn.Basename() for urn in self.SetupClients(5)]

            self.AssignTasksToClients(client_ids=client_ids)
            # Only running the hunt on a single client, as SampleMock
            # implementation is non-deterministic in terms of resources
            # usage that gets reported back to the hunt.
            client_urns = [rdf_client.ClientURN(client_ids[-1])]
            self.RunHunt(client_ids=client_urns, failrate=0)

        # Create replace dictionary.
        replace = {hunt_urn.Basename(): "H:123456"}

        self.Check("ListHuntClients",
                   args=hunt_plugin.ApiListHuntClientsArgs(
                       hunt_id=hunt_urn.Basename(), client_status="STARTED"),
                   replace=replace)
        self.Check("ListHuntClients",
                   args=hunt_plugin.ApiListHuntClientsArgs(
                       hunt_id=hunt_urn.Basename(),
                       client_status="OUTSTANDING"),
                   replace=replace)
        self.Check("ListHuntClients",
                   args=hunt_plugin.ApiListHuntClientsArgs(
                       hunt_id=hunt_urn.Basename(), client_status="COMPLETED"),
                   replace=replace)