Пример #1
0
    def test_set_resources_memory_limit_and_reservation(self, *mocks):
        """
        Ensures memory reservation and limit are left alone when they are both defined
        """
        merge_profile_mock = mocks[0]
        merge_profile_mock.return_value = get_content(
            'profiles/limit_and_reservation.yml')

        profile = Profile(self.workflow)

        param = {}
        content = profile._compile(
            param)  # the param is ignored because it's using the mock

        merge_profile_mock.assert_called_with(param)

        data = yaml_load(content)
        resources = data['services']['app']['deploy']['resources']

        self.assertEqual('10M', resources['reservations']['memory'])
        self.assertEqual('100M', resources['limits']['memory'])
Пример #2
0
    def test_set_resources_memory_reservation_no_limit(self, *mocks):
        """
        Ensures memory limit is matched to reservation when no limit is given
        """
        merge_profile_mock = mocks[0]
        merge_profile_mock.return_value = get_content(
            'profiles/reservation_no_limit.yml')

        profile = Profile(self.workflow)

        param = {}
        content = profile._compile(
            param)  # the param is ignored because it's using the mock

        merge_profile_mock.assert_called_with(param)

        data = yaml_load(content)
        resources = data['services']['app']['deploy']['resources']

        self.assertEqual(resources['limits']['memory'],
                         resources['reservations']['memory'])
Пример #3
0
    def test_set_resources_memory_limit_no_reservation(self, *mocks):
        """
        Ensures memory reservation is matched to limit when no reservation is given
        """
        merge_profile_mock = mocks[0]
        merge_profile_mock.return_value = get_content(
            "profiles/limit_no_reservation.yml"
        )

        profile = Profile(self.workflow)

        param = {}
        content = profile._compile(
            param
        )  # the param is ignored because it's using the mock

        merge_profile_mock.assert_called_with(param)

        data = yaml_load(content)
        resources = data["services"]["app"]["deploy"]["resources"]

        self.assertEqual(
            resources["reservations"]["memory"], resources["limits"]["memory"]
        )