Additional install / download failure test
Ensure we can install again on a previously failed URL.
This commit is contained in:
@@ -634,7 +634,7 @@ void ArchiveExtractor::extractBytes(const uint8_t* bytes, size_t count)
|
|||||||
d.reset(new ZipExtractorPrivate(this));
|
d.reset(new ZipExtractorPrivate(this));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SG_LOG(SG_IO, SG_ALERT, "Invcalid archive type");
|
SG_LOG(SG_IO, SG_ALERT, "Invalid archive type");
|
||||||
_invalidDataType = true;
|
_invalidDataType = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -724,8 +724,10 @@ ArchiveExtractor::DetermineResult ArchiveExtractor::isTarData(const uint8_t* byt
|
|||||||
}
|
}
|
||||||
|
|
||||||
int result = inflate(&z, Z_SYNC_FLUSH);
|
int result = inflate(&z, Z_SYNC_FLUSH);
|
||||||
if (result != Z_OK) {
|
if ((result == Z_OK) || (result == Z_STREAM_END)) {
|
||||||
SG_LOG(SG_IO, SG_WARN, "inflate failed:" << result);
|
// all good
|
||||||
|
} else {
|
||||||
|
SG_LOG(SG_IO, SG_WARN, "isTarData: Zlib inflate failed:" << result);
|
||||||
inflateEnd(&z);
|
inflateEnd(&z);
|
||||||
return Invalid; // not tar data
|
return Invalid; // not tar data
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ std::string readFileIntoString(const SGPath& path)
|
|||||||
SGPath global_serverFilesRoot;
|
SGPath global_serverFilesRoot;
|
||||||
unsigned int global_catalogVersion = 0;
|
unsigned int global_catalogVersion = 0;
|
||||||
bool global_failRequests = false;
|
bool global_failRequests = false;
|
||||||
|
bool global_fail747Request = true;
|
||||||
|
|
||||||
class TestPackageChannel : public TestServerChannel
|
class TestPackageChannel : public TestServerChannel
|
||||||
{
|
{
|
||||||
@@ -97,8 +98,12 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (path == "/catalogTest1/b747.tar.gz") {
|
if (path == "/catalogTest1/b747.tar.gz") {
|
||||||
sendErrorResponse(403, false, "Bad URL");
|
if (global_fail747Request) {
|
||||||
return;
|
sendErrorResponse(403, false, "Bad URL");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
path = "/catalogTest1/b747.tar.gz"; // valid path
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localPath.append(path);
|
localPath.append(path);
|
||||||
@@ -1083,6 +1088,7 @@ void updateInvalidToInvalid(HTTP::Client* cl)
|
|||||||
void testInstallBadPackage(HTTP::Client* cl)
|
void testInstallBadPackage(HTTP::Client* cl)
|
||||||
{
|
{
|
||||||
global_catalogVersion = 0;
|
global_catalogVersion = 0;
|
||||||
|
global_fail747Request = true;
|
||||||
|
|
||||||
SGPath rootPath(simgear::Dir::current().path());
|
SGPath rootPath(simgear::Dir::current().path());
|
||||||
rootPath.append("pkg_install_bad_pkg");
|
rootPath.append("pkg_install_bad_pkg");
|
||||||
@@ -1113,8 +1119,22 @@ void testInstallBadPackage(HTTP::Client* cl)
|
|||||||
SG_VERIFY(p1->existingInstall() == ins);
|
SG_VERIFY(p1->existingInstall() == ins);
|
||||||
SG_CHECK_EQUAL(ins->status(), pkg::Delegate::FAIL_DOWNLOAD);
|
SG_CHECK_EQUAL(ins->status(), pkg::Delegate::FAIL_DOWNLOAD);
|
||||||
SG_CHECK_EQUAL(ins->path(), rootPath / "org.flightgear.test.catalog1" / "Aircraft" / "b744");
|
SG_CHECK_EQUAL(ins->path(), rootPath / "org.flightgear.test.catalog1" / "Aircraft" / "b744");
|
||||||
}
|
|
||||||
|
|
||||||
|
// now retry, it should work
|
||||||
|
global_fail747Request = false;
|
||||||
|
|
||||||
|
auto ins2 = p1->install();
|
||||||
|
SG_CHECK_EQUAL(ins2, p1->existingInstall());
|
||||||
|
root->scheduleToUpdate(ins2);
|
||||||
|
SG_VERIFY(ins2->isQueued());
|
||||||
|
|
||||||
|
didFail = false;
|
||||||
|
waitForUpdateComplete(cl, root);
|
||||||
|
SG_VERIFY(p1->isInstalled());
|
||||||
|
SG_VERIFY(!didFail);
|
||||||
|
SG_CHECK_EQUAL(ins->status(), pkg::Delegate::STATUS_SUCCESS);
|
||||||
|
SG_CHECK_EQUAL(ins->path(), rootPath / "org.flightgear.test.catalog1" / "Aircraft" / "b744");
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<PropertyList>
|
||||||
|
<sim>
|
||||||
|
<description>Boeing 747-400</description>
|
||||||
|
</sim>
|
||||||
|
</PropertyList>
|
||||||
Binary file not shown.
@@ -215,8 +215,8 @@
|
|||||||
<cockpit type="int">4</cockpit>
|
<cockpit type="int">4</cockpit>
|
||||||
</rating>
|
</rating>
|
||||||
|
|
||||||
<md5>a94ca5704f305b90767f40617d194ed6</md5>
|
<md5>4d3f7417d74f811aa20ccc4f35673d20</md5>
|
||||||
<!-- this URL will fail, on purpose -->
|
<!-- this URL will sometimes fail, on purpose -->
|
||||||
<url>http://localhost:2000/catalogTest1/b747.tar.gz</url>
|
<url>http://localhost:2000/catalogTest1/b747.tar.gz</url>
|
||||||
</package>
|
</package>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user