Changeset 252259 in webkit


Ignore:
Timestamp:
Nov 8, 2019 1:26:15 PM (4 years ago)
Author:
achristensen@apple.com
Message:

Fix flaky tests in http/tests/cache/disk-cache
https://bugs.webkit.org/show_bug.cgi?id=203822

Reviewed by Youenn Fablet.

Source/WebKit:

Right now tests that set the cache model do so using a race condition. I think this will fix the flakyness we've observed.

  • NetworkProcess/NetworkProcess.cpp:

(WebKit::NetworkProcess::setCacheModelSynchronouslyForTesting):

  • NetworkProcess/NetworkProcess.h:
  • NetworkProcess/NetworkProcess.messages.in:
  • UIProcess/API/C/WKWebsiteDataStoreRef.cpp:

(WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting):

  • UIProcess/API/C/WKWebsiteDataStoreRef.h:
  • UIProcess/WebProcessPool.cpp:

(WebKit::WebProcessPool::setCacheModelSynchronouslyForTesting):

  • UIProcess/WebProcessPool.h:
  • UIProcess/WebsiteData/WebsiteDataStore.cpp:

(WebKit::WebsiteDataStore::setCacheModelSynchronouslyForTesting):

  • UIProcess/WebsiteData/WebsiteDataStore.h:

Tools:

  • WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:

(WTR::InjectedBundle::setCacheModel):

  • WebKitTestRunner/TestInvocation.cpp:

(WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
(WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):

Location:
trunk
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r252258 r252259  
     12019-11-08  Alex Christensen  <achristensen@webkit.org>
     2
     3        Fix flaky tests in http/tests/cache/disk-cache
     4        https://bugs.webkit.org/show_bug.cgi?id=203822
     5
     6        Reviewed by Youenn Fablet.
     7
     8        Right now tests that set the cache model do so using a race condition.  I think this will fix the flakyness we've observed.
     9
     10        * NetworkProcess/NetworkProcess.cpp:
     11        (WebKit::NetworkProcess::setCacheModelSynchronouslyForTesting):
     12        * NetworkProcess/NetworkProcess.h:
     13        * NetworkProcess/NetworkProcess.messages.in:
     14        * UIProcess/API/C/WKWebsiteDataStoreRef.cpp:
     15        (WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting):
     16        * UIProcess/API/C/WKWebsiteDataStoreRef.h:
     17        * UIProcess/WebProcessPool.cpp:
     18        (WebKit::WebProcessPool::setCacheModelSynchronouslyForTesting):
     19        * UIProcess/WebProcessPool.h:
     20        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
     21        (WebKit::WebsiteDataStore::setCacheModelSynchronouslyForTesting):
     22        * UIProcess/WebsiteData/WebsiteDataStore.h:
     23
    1242019-11-08  Alex Christensen  <achristensen@webkit.org>
    225
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp

    r251831 r252259  
    19941994}
    19951995
     1996void NetworkProcess::setCacheModelSynchronouslyForTesting(CacheModel cacheModel, CompletionHandler<void()>&& completionHandler)
     1997{
     1998    setCacheModel(cacheModel, { });
     1999    completionHandler();
     2000}
     2001
    19962002void NetworkProcess::setCacheModel(CacheModel cacheModel, String cacheStorageDirectory)
    19972003{
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.h

    r251676 r252259  
    407407
    408408    void setCacheModel(CacheModel, String overrideCacheStorageDirectory);
     409    void setCacheModelSynchronouslyForTesting(CacheModel, CompletionHandler<void()>&&);
    409410    void allowSpecificHTTPSCertificateForHost(const WebCore::CertificateInfo&, const String& host);
    410411    void clearCacheForAllOrigins(uint32_t cachesToClear);
  • trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in

    r251659 r252259  
    7070   
    7171    ClearCacheForAllOrigins(uint32_t cachesToClear)
    72     SetCacheModel(enum:uint8_t WebKit::CacheModel cacheModel, String overrideCacheStorageDirectory);
     72    SetCacheModel(enum:uint8_t WebKit::CacheModel cacheModel, String overrideCacheStorageDirectory)
     73    SetCacheModelSynchronouslyForTesting(enum:uint8_t WebKit::CacheModel cacheModel) -> () Synchronous
    7374
    7475    ProcessDidTransitionToBackground()
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.cpp

    r251213 r252259  
    683683}
    684684
     685void WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(WKWebsiteDataStoreRef dataStoreRef, WKCacheModel cacheModel)
     686{
     687    WebKit::toImpl(dataStoreRef)->setCacheModelSynchronouslyForTesting(WebKit::toCacheModel(cacheModel));
     688}
  • trunk/Source/WebKit/UIProcess/API/C/WKWebsiteDataStoreRef.h

    r251213 r252259  
    3333extern "C" {
    3434#endif
     35
     36typedef uint32_t WKCacheModel;
    3537
    3638WK_EXPORT WKTypeID WKWebsiteDataStoreGetTypeID();
     
    152154WK_EXPORT void WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemoval(WKWebsiteDataStoreRef dataStoreRef, void* context, WKWebsiteDataStoreClearAdClickAttributionsThroughWebsiteDataRemovalFunction callback);
    153155
     156WK_EXPORT void WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(WKWebsiteDataStoreRef dataStoreRef, WKCacheModel cacheModel);
     157
    154158#ifdef __cplusplus
    155159}
  • trunk/Source/WebKit/UIProcess/WebProcessPool.cpp

    r252257 r252259  
    15751575}
    15761576
     1577void WebProcessPool::setCacheModelSynchronouslyForTesting(CacheModel cacheModel)
     1578{
     1579    updateBackForwardCacheCapacity();
     1580
     1581    if (m_networkProcess)
     1582        m_networkProcess->sendSync(Messages::NetworkProcess::SetCacheModelSynchronouslyForTesting(cacheModel), { }, { });
     1583}
     1584
    15771585void WebProcessPool::setDefaultRequestTimeoutInterval(double timeoutInterval)
    15781586{
  • trunk/Source/WebKit/UIProcess/WebProcessPool.h

    r252257 r252259  
    284284
    285285    void setCacheModel(CacheModel);
     286    void setCacheModelSynchronouslyForTesting(CacheModel);
     287
    286288
    287289    void setDefaultRequestTimeoutInterval(double);
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp

    r252014 r252259  
    20642064}
    20652065
     2066void WebsiteDataStore::setCacheModelSynchronouslyForTesting(CacheModel cacheModel)
     2067{
     2068    for (auto processPool : WebProcessPool::allProcessPools())
     2069        processPool->setCacheModelSynchronouslyForTesting(cacheModel);
     2070}
     2071
    20662072#if !PLATFORM(COCOA)
    20672073WebsiteDataStoreParameters WebsiteDataStore::parameters()
  • trunk/Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h

    r251687 r252259  
    7979class WebProcessProxy;
    8080class WebResourceLoadStatisticsStore;
     81enum class CacheModel : uint8_t;
    8182enum class WebsiteDataFetchOption;
    8283enum class WebsiteDataType;
     
    139140
    140141    void getLocalStorageDetails(Function<void(Vector<LocalStorageDatabaseTracker::OriginDetails>&&)>&&);
     142    void setCacheModelSynchronouslyForTesting(CacheModel);
    141143
    142144#if ENABLE(RESOURCE_LOAD_STATISTICS)
  • trunk/Tools/ChangeLog

    r252249 r252259  
     12019-11-08  Alex Christensen  <achristensen@webkit.org>
     2
     3        Fix flaky tests in http/tests/cache/disk-cache
     4        https://bugs.webkit.org/show_bug.cgi?id=203822
     5
     6        Reviewed by Youenn Fablet.
     7
     8        * WebKitTestRunner/InjectedBundle/InjectedBundle.cpp:
     9        (WTR::InjectedBundle::setCacheModel):
     10        * WebKitTestRunner/TestInvocation.cpp:
     11        (WTR::TestInvocation::didReceiveMessageFromInjectedBundle):
     12        (WTR::TestInvocation::didReceiveSynchronousMessageFromInjectedBundle):
     13
    1142019-11-08  Aakash Jain  <aakash_jain@apple.com>
    215
  • trunk/Tools/WebKitTestRunner/InjectedBundle/InjectedBundle.cpp

    r251950 r252259  
    926926    WKRetainPtr<WKStringRef> messageName = adoptWK(WKStringCreateWithUTF8CString("SetCacheModel"));
    927927    WKRetainPtr<WKUInt64Ref> messageBody = adoptWK(WKUInt64Create(model));
    928     WKBundlePagePostMessage(page()->page(), messageName.get(), messageBody.get());
     928    WKBundlePagePostSynchronousMessageForTesting(page()->page(), messageName.get(), messageBody.get(), nullptr);
    929929}
    930930
  • trunk/Tools/WebKitTestRunner/TestInvocation.cpp

    r251213 r252259  
    547547    }
    548548
    549     if (WKStringIsEqualToUTF8CString(messageName, "SetCacheModel")) {
    550         ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
    551         uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
    552         WKContextSetCacheModel(TestController::singleton().context(), model);
    553         return;
    554     }
    555 
    556549    if (WKStringIsEqualToUTF8CString(messageName, "SetCustomPolicyDelegate")) {
    557550        ASSERT(WKGetTypeID(messageBody) == WKDictionaryGetTypeID());
     
    878871        WKRetainPtr<WKTypeRef> result = adoptWK(WKBooleanCreate(isActive));
    879872        return result;
     873    }
     874
     875    if (WKStringIsEqualToUTF8CString(messageName, "SetCacheModel")) {
     876        ASSERT(WKGetTypeID(messageBody) == WKUInt64GetTypeID());
     877        uint64_t model = WKUInt64GetValue(static_cast<WKUInt64Ref>(messageBody));
     878        WKWebsiteDataStoreSetCacheModelSynchronouslyForTesting(TestController::websiteDataStore(), model);
     879        return nullptr;
    880880    }
    881881
Note: See TracChangeset for help on using the changeset viewer.