[Caching] Don't propagate import error on plugin side (#5390)

* HotFix for ConvertPrecision tests

* [Caching] Don't propagate import error on plugin side

Instead, invalid cache will be silently removed and network will be loaded without cache

Co-authored-by: Ilya Churaev <ilya.churaev@intel.com>
This commit is contained in:
Mikhail Nosov 2021-04-27 06:54:49 +03:00 committed by GitHub
parent 2a51a62d48
commit 6581127114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 7 deletions

View File

@ -290,7 +290,9 @@ class Core::Impl : public ICore {
networkIsImported = false;
} catch (...) {
cacheManager->removeCacheEntry(blobId);
throw;
networkIsImported = false;
// TODO: temporary disabled by #54335. In future don't throw only for new 'blob_outdated' exception
// throw;
}
return execNetwork;
}

View File

@ -644,8 +644,8 @@ TEST_P(CachingTest, TestCacheDirCreateRecursive) {
});
}
CommonTestUtils::removeFilesWithExt(newCacheDir2, "blob");
std::remove(newCacheDir2.c_str());
std::remove(newCacheDir1.c_str());
CommonTestUtils::removeDir(newCacheDir2);
CommonTestUtils::removeDir(newCacheDir1);
}
TEST_P(CachingTest, TestDeviceArchitecture) {
@ -763,6 +763,8 @@ TEST_P(CachingTest, TestThrowOnExport) {
}
}
// TODO: temporary behavior is to no re-throw exception on import error (see 54335)
// In future add separate 'no throw' test for 'blob_outdated' exception from plugin
TEST_P(CachingTest, TestThrowOnImport) {
ON_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).WillByDefault(Throw(1));
ON_CALL(*mockPlugin, ImportNetworkImpl(_, _)).WillByDefault(Throw(1));
@ -781,14 +783,14 @@ TEST_P(CachingTest, TestThrowOnImport) {
});
}
{
EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(0);
EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(0);
EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, LoadExeNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _, _)).Times(m_remoteContext ? 1 : 0);
EXPECT_CALL(*mockPlugin, ImportNetworkImpl(_, _)).Times(!m_remoteContext ? 1 : 0);
EXPECT_CALL(*net, ExportImpl(_)).Times(0);
EXPECT_CALL(*net, ExportImpl(_)).Times(1);
testLoad([&](Core &ie) {
ie.SetConfig({{CONFIG_KEY(CACHE_DIR), m_cacheDir}});
EXPECT_ANY_THROW(m_testFunction(ie));
EXPECT_NO_THROW(m_testFunction(ie));
});
}
{ // Step 3: same load, cache should be deleted due to unsuccessful import on step 2