-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restorableappengine: Use new storage usage func
- Apply the new functionality for obtaining storage usage statistic to the restorable apps - the check if there is enough free storage before pulling App. - This fixes the math issue in the previous usage function used by the pre-pull check. The previous math applied the "watermark" (max allowed storage space that can be utilized by apps) to the free space not to the all storage capacity. For example, if there is already less than <capacity> - <capacity*watermark (0.8)> = <reserved storage> of free storage the math would allow update as long as <free space> * 0.8 is enough to fit App. - Adjust tests to the new math. - One of the tests had dos/ms line ending, so the whole file was changed. Signed-off-by: Mike Sul <[email protected]>
- Loading branch information
Showing
5 changed files
with
88 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,46 @@ | ||
#include "fixtures/composeappenginetest.cc" | ||
#include "fixtures/liteclienttest.cc" | ||
|
||
class AkliteTest : public fixtures::ClientTest, | ||
public fixtures::AppEngineTest, | ||
public ::testing::WithParamInterface<std::string> { | ||
protected: | ||
void SetUp() override { | ||
fixtures::AppEngineTest::SetUp(); | ||
|
||
const auto app_engine_type{GetParam()}; | ||
|
||
if (app_engine_type == "ComposeAppEngine") { | ||
app_engine = | ||
std::make_shared<Docker::ComposeAppEngine>(apps_root_dir, compose_cmd, docker_client_, registry_client_); | ||
} else if (app_engine_type == "RestorableAppEngine") { | ||
setAvailableStorageSpace(std::numeric_limits<boost::uintmax_t>::max()); | ||
app_engine = std::make_shared<Docker::RestorableAppEngine>( | ||
fixtures::ClientTest::test_dir_.Path() / "apps-store", apps_root_dir, daemon_.dataRoot(), registry_client_, | ||
docker_client_, registry.getSkopeoClient(), daemon_.getUrl(), compose_cmd, | ||
[this](const boost::filesystem::path& path) { | ||
return std::tuple<boost::uintmax_t, boost::uintmax_t>{this->available_storage_space_, | ||
(this->watermark_ * this->available_storage_space_)}; | ||
}); | ||
} else { | ||
throw std::invalid_argument("Unsupported AppEngine type: " + app_engine_type); | ||
} | ||
} | ||
|
||
std::shared_ptr<LiteClient> createLiteClient(InitialVersion initial_version = InitialVersion::kOn, | ||
boost::optional<std::vector<std::string>> apps = boost::none, | ||
bool finalize = true) override { | ||
const auto app_engine_type{GetParam()}; | ||
|
||
if (app_engine_type == "ComposeAppEngine") { | ||
return ClientTest::createLiteClient(app_engine, initial_version, apps, apps_root_dir.string(), boost::none, | ||
create_containers_before_reboot_, finalize); | ||
} else if (app_engine_type == "RestorableAppEngine") { | ||
return ClientTest::createLiteClient(app_engine, initial_version, apps, apps_root_dir.string(), | ||
!!apps ? apps : std::vector<std::string>{""}, | ||
create_containers_before_reboot_, finalize); | ||
} else { | ||
throw std::invalid_argument("Unsupported AppEngine type: " + app_engine_type); | ||
} | ||
} | ||
|
||
void setAvailableStorageSpace(const boost::uintmax_t& space_size) { available_storage_space_ = space_size; } | ||
void setCreateContainersBeforeReboot(bool value) { create_containers_before_reboot_ = value; } | ||
|
||
private: | ||
boost::uintmax_t available_storage_space_; | ||
float watermark_{0.8}; | ||
bool create_containers_before_reboot_{true}; | ||
}; | ||
#include "fixtures/composeappenginetest.cc" | ||
#include "fixtures/liteclienttest.cc" | ||
|
||
class AkliteTest : public fixtures::ClientTest, | ||
public fixtures::AppEngineTest, | ||
public ::testing::WithParamInterface<std::string> { | ||
protected: | ||
void SetUp() override { | ||
fixtures::AppEngineTest::SetUp(); | ||
|
||
const auto app_engine_type{GetParam()}; | ||
|
||
if (app_engine_type == "ComposeAppEngine") { | ||
app_engine = | ||
std::make_shared<Docker::ComposeAppEngine>(apps_root_dir, compose_cmd, docker_client_, registry_client_); | ||
} else if (app_engine_type == "RestorableAppEngine") { | ||
app_engine = std::make_shared<Docker::RestorableAppEngine>( | ||
fixtures::ClientTest::test_dir_.Path() / "apps-store", apps_root_dir, daemon_.dataRoot(), registry_client_, | ||
docker_client_, registry.getSkopeoClient(), daemon_.getUrl(), compose_cmd, getTestStorageSpaceFunc()); | ||
} else { | ||
throw std::invalid_argument("Unsupported AppEngine type: " + app_engine_type); | ||
} | ||
} | ||
|
||
std::shared_ptr<LiteClient> createLiteClient(InitialVersion initial_version = InitialVersion::kOn, | ||
boost::optional<std::vector<std::string>> apps = boost::none, | ||
bool finalize = true) override { | ||
const auto app_engine_type{GetParam()}; | ||
|
||
if (app_engine_type == "ComposeAppEngine") { | ||
return ClientTest::createLiteClient(app_engine, initial_version, apps, apps_root_dir.string(), boost::none, | ||
create_containers_before_reboot_, finalize); | ||
} else if (app_engine_type == "RestorableAppEngine") { | ||
return ClientTest::createLiteClient(app_engine, initial_version, apps, apps_root_dir.string(), | ||
!!apps ? apps : std::vector<std::string>{""}, | ||
create_containers_before_reboot_, finalize); | ||
} else { | ||
throw std::invalid_argument("Unsupported AppEngine type: " + app_engine_type); | ||
} | ||
} | ||
|
||
void setCreateContainersBeforeReboot(bool value) { create_containers_before_reboot_ = value; } | ||
|
||
private: | ||
bool create_containers_before_reboot_{true}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters