Mysteries of Dropbox Property-Based Testing of a Distributed Synchronization Service

Mysteries of Dropbox Property-Based Testing of a Distributed Synchronization Service

Mysteries of Dropbox Property-Based Testing of a Distributed Synchronization Service John Hughes∗y, Benjamin C. Piercez, Thomas Arts∗, Ulf Norell∗y, ∗ Quviq AB, Goteborg,¨ Sweden y Dept of Computer Science and Engineering, Chalmers University of Technology, Goteborg,¨ Sweden z Dept of Computer and Information Science, University of Pennsylvania, PA, USA Abstract—File synchronization services such as Dropbox are Our goal in this paper is to present a testable formal specifi- used by hundreds of millions of people to replicate vital data. cation for the core behavior of a file synchronizer. We do so via Yet rigorous models of their behavior are lacking. We present a model developed using Quviq QuickCheck [4]. Despite the the first formal—and testable—model of the core behavior of a modern file synchronizer, and we use it to discover surprising apparent simplicity of the problem, we encountered interesting behavior in two widely deployed synchronizers. Our model is challenges regarding both specification and testing. We used based on a technique for testing nondeterministic systems that the model to test Dropbox, Google Drive, and ownCloud (an avoids requiring that the system’s internal choices be made visible open source alternative), exposing unexpected behavior in two to the testing framework. out of three. In Section II, we introduce our testing framework. Sec- I. INTRODUCTION tion III gives a high-level overview of the concepts used in our model, in particular the operations performed by test cases, the File synchronization services—distributed systems that observations made when a test case is run on the system under maintain consistency among multiple copies of a file or test (SUT), and the explanations that we construct to determine directory structure—are now ubiquitous. Dropbox claim 400 whether the test has passed or failed. Section IV presents the million users,1 while Google Drive and Microsoft OneDrive formal specification itself, beginning with a naive version and are reported to have over 240 million users each.2 In addition refining it in light of failed tests that reveal subtleties in the to these large-scale commercial offerings and many smaller synchronizer’s handling of corner cases. Section V describes ones, there are a plethora of open source synchronizers, further failed tests that, rather than pinpointing inadequacies enabling users to create their own ‘cloud storage.’ With so in the specification, seem to us to exemplify unintended many people trusting their data to synchronization services, behaviors of both Dropbox and ownCloud, including situations their correctness should be a high priority indeed. where each system can lose data. In Section VI, we discuss the Surprisingly, then, it seems that only one file synchronizer pragmatics of our testing framework, in particular our methods has been formally specified to date: Unison [1]–[3]. However, for triggering timing-dependent behaviors, for observing when even Unison’s specification is not directly useful for testing; the system has reached quiescence, and for shrinking tests to moreover, Unison works rather differently from contemporary minimal failing cases in the presence of nondeterminism. In synchronization services: it synchronizes two peers at a time, Section VII, we sketch an initially promising attempt to formu- rather than many clients with one server; synchronization is late the specification in terms of Lamport’s “happens before” invoked explicitly by the user, rather than taking place auto- relation and explain why it ultimately proved unsuccessful. matically in the background; and conflict resolution involves Section VIII surveys related work, and Sections IX and X user interaction, rather than being performed automatically. present future directions and concluding remarks. Synchronizers are challenging not only to specify but also Our main contributions are as follows: (1) We construct the to test. They are large-scale, nondeterministic distributed sys- first formal model of the core behavior of modern file synchro- tems, with timing-dependent behavior. They must cope with nizers. (2) To define the model, we develop a technique for conflicts (when the same file is modified concurrently on two testing nondeterministic systems that does not require that the or more clients). They work in the background, and their system’s internal choices be visible to the testing framework. state is unobservable. Moreover, they are slow. They share Our technique is based on an explicit representation of hidden these difficulties with a large class of critical systems; thus, system state plus “conjectured events” that mutate it. (3) We techniques for addressing these problems are valuable, not validate our final model against two commercial synchronizers only for testing file synchronizers, but in a broader context. and one open-source one, showing that their behavior agrees with the model in most situations. (4) We demonstrate the 1 techcrunch.com, “Dropbox now has more than 400 million registered effectiveness of our model and testing framework by using it users”, June 24th, 2015. 2fortune.com, “Who’s winning the consumer cloud storage wars?” to reveal a number of surprising behaviors, likely not intended November 6th, 2014. by the developers of these systems. II. TESTING A SYNCHRONIZATION SERVICE ones we have tested so far. In particular, we did not want to assume any direct access to remote servers outside our control. We begin by making a rather drastic simplifying assump- Therefore, we treat the synchronizer as a ‘black box’, which tion: we consider only one file, with operations to read, we communicate with only through the file system; our tests write, and delete it. We consider only operations that read just read and write files on the virtual machines and check the and write the entire file; we do not specify or test how the results for validity. This allows us to write the specification synchronizer interacts with open files as they are modified. without dependencies on synchronizer-specific APIs.3 Restricting our attention to one file may seem extreme, but even this simple setting forces us to confront essential issues III. OVERVIEW OF THE SPECIFICATION of synchronization—in particular subtleties arising in the pres- Our strategy for test case generation is very simple: we ence of conflicts—and it is enough to expose surprising be- generate test cases consisting of random sequences of calls to haviors in real systems. A plan for extending the specification a small set of basic filesystem operations. The basic operations to multiple files and directories is sketched in Section IX. we consider are We developed our model using Quviq QuickCheck [4], • READN , which reads the (one) file on node N (one of a descendant of Haskell QuickCheck [5]. QuickCheck tests the VMs), and properties—universally quantified boolean formulæ—by gen- • WRITEN V , which writes the value V (a string) to the erating random values for the quantified variables and check- file on node N. true ing that the formula evaluates to . When a test fails, We will introduce a few additional operations below. QuickCheck “shrinks” it, searching for a similar but smaller We use QuickCheck’s state machine library to generate test that also fails and ultimately reporting a failing test that tests, with a trivial model state—our tests are simply random is ‘minimal’ in some sense. (This process is akin to delta- sequences of READs and WRITEs, with random arguments. debugging [6], although the details are slightly different.) One might expect to track the file contents in the model state, QuickCheck provides a domain-specific language for defining and check that READ returns the modeled contents—but this test data generators and shrinking searches; using this DSL, could only work if synchronization were instantaneous, which users can exert fine control over the random distribution of of course it is not. Instead of trying to express our specification test cases. A part of this DSL is a notation for specifying in this synchronous style, we collect observed events as each state machine models, which generate test cases consisting of operation is actually executed, and we use a separate state sequences of calls to an API under test [7], [8]; this is how machine to validate the resulting sequence of events. we generated test cases for synchronizers. Quviq QuickCheck The observed events corresponding to the READ and WRITE is embedded in the Erlang programming language—that is, operations are as follows: specifications are just Erlang programs that call libraries • when READ returns the value V , we observe the event supplied by QuickCheck—and the generated tests invoke the N READ ! V , and SUT directly via Erlang function calls. As a result, there is N • when WRITE V overwrites the value V , we observe no distinction between ‘abstract’ and ‘concrete’ test cases, as N old the event WRITE V ! V . there often is in model-based testing, and there is no need for N old a ‘system adapter’; instead, generated test cases are directly Notice that, when we write the file, we observe the previous executable. contents as well as the new one (taking the ‘previous contents’ We ran our tests on laptops running a host operating system of a newly created file to be the special value ?). The value (Windows 8.1 or Mac OS) together with several virtual ma- that we overwrite matters, because of the way synchronizers chines running Ubuntu Linux. The file synchronizer under test handle conflicts. (This observation is not actually atomic, but was installed on each virtual machine and under the host op- it is very unlikely that the dropbox dæmon will overwrite the erating system, so we could read and write files on any of the file between our read and write, and we have not observed it virtual machines, or on the host, and expect the synchronizer to happen.) to propagate changes to all of the others.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    11 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us