Пример #1
0
    def test02_start_deployed_threebot(self):
        """Test case for starting a threebot.

        **Test Scenario**

        - Deploy a threebot.
        - Stop the deployed threebot
        - Start the stopped threebot.
        - Check that threebot is reachable.
        """
        self.info("Deploy a threebot")
        name = self.random_name()
        self.secret = self.random_name()
        threebot = deployer.deploy_threebot(solution_name=name,
                                            secret=self.secret,
                                            expiration=time() + 60 * 15,
                                            ssh="")
        self.solution_uuid = threebot.solution_id

        self.info("Stop the deployed threebot")
        stop_threebot_solution(self.tname, self.solution_uuid, self.secret)

        self.info("Start the stopped threebot")
        threebot = deployer.start_threebot(name, self.secret)
        self.solution_uuid = threebot.solution_id

        self.info("Check that threebot is reachable.")
        request = j.tools.http.get(f"http://{threebot.domain}",
                                   verify=False,
                                   timeout=self.timeout)
        self.assertEqual(request.status_code, 200)
Пример #2
0
    def test03_change_deployed_threebot_size(self):
        """Test case for changing a threebot size.

        **Test Scenario**

        - Deploy a threebot.
        - Stop the deployed threebot.
        - Change the stopped threebot size.
        - Check that threebot is reachable.
        """
        self.info("Deploy a threebot")
        name = self.random_name()
        self.secret = self.random_name()
        expiration = j.data.time.utcnow().timestamp + 60 * 15
        threebot = deployer.deploy_threebot(solution_name=name,
                                            secret=self.secret,
                                            expiration=expiration,
                                            ssh="")
        self.solution_uuid = threebot.solution_id

        self.info("Stop the deployed threebot")
        stop_threebot_solution(self.tname, self.solution_uuid, self.secret)
        self.assertTrue(
            self.wait_for_threebot_state(name, ThreebotState.STOPPED),
            "Threebot didn't stop")

        self.info("Start the stopped threebot")
        threebot = deployer.change_threebot_size(
            name,
            self.secret,
            flavor="Gold (CPU 2 - Memory 4 GB - Disk 4 GB [SSD])")
        self.solution_uuid = threebot.solution_id
        threebot_config = USER_THREEBOT_FACTORY.get(
            f"threebot_{self.solution_uuid}")
        threebot_container_workload = j.sals.zos.get().workloads.get(
            threebot_config.threebot_container_wid)
        self.assertEqual(threebot_container_workload.capacity.cpu, 2)
        self.assertEqual(threebot_container_workload.capacity.memory, 4096)
        self.assertEqual(threebot_container_workload.capacity.disk_size, 4096)

        self.info("Check that threebot is reachable.")
        request = j.tools.http.get(f"http://{threebot.domain}",
                                   verify=False,
                                   timeout=self.timeout)
        self.assertEqual(request.status_code, 200)
Пример #3
0
def stop_threebot() -> str:
    data = j.data.serializers.json.loads(request.body.read())
    user_info = j.data.serializers.json.loads(get_user_info())
    if "password" not in data or "uuid" not in data:
        return HTTPResponse(
            j.data.serializers.json.dumps(
                {"error": "invalid body. missing keys"}),
            status=400,
            headers={"Content-Type": "application/json"},
        )
    try:
        stop_threebot_solution(owner=user_info["username"],
                               solution_uuid=data["uuid"],
                               password=data["password"])
    except (exceptions.Permission, exceptions.Validation):
        return HTTPResponse(
            j.data.serializers.json.dumps({"error": "invalid secret"}),
            status=401,
            headers={"Content-Type": "application/json"},
        )
    return j.data.serializers.json.dumps({"data": True})
Пример #4
0
    def test04_change_deployed_threebot_location(self):
        """Test case for changing a threebot location.

        **Test Scenario**

        - Deploy a threebot.
        - Stop the deployed threebot.
        - Change the stopped threebot location.
        - Check that threebot is reachable.
        """
        self.info("Deploy a threebot")
        name = self.random_name()
        expiration = j.data.time.utcnow().timestamp + 60 * 15
        self.secret = self.random_name()
        threebot = deployer.deploy_threebot(solution_name=name,
                                            secret=self.secret,
                                            expiration=expiration,
                                            ssh="")
        self.solution_uuid = threebot.solution_id

        self.info("Stop the deployed threebot")
        stop_threebot_solution(self.tname, self.solution_uuid, self.secret)
        self.assertTrue(
            self.wait_for_threebot_state(name, ThreebotState.STOPPED),
            "Threebot didn't stop")

        self.info("Start the stopped threebot")
        expiration = j.data.time.utcnow().timestamp + 60 * 15
        threebot = deployer.change_threebot_location(
            name, self.secret, expiration_time=expiration)
        self.solution_uuid = threebot.solution_id

        self.info("Check that threebot is reachable.")
        request = j.tools.http.get(f"http://{threebot.domain}",
                                   verify=False,
                                   timeout=self.timeout)
        self.assertEqual(request.status_code, 200)
Пример #5
0
 def tearDown(self):
     if self.solution_uuid and self.secret:
         stop_threebot_solution(self.tname, self.solution_uuid, self.secret)