Skip to content
Snippets Groups Projects
  1. Sep 05, 2012
    • Iustin Pop's avatar
      Introduce a helper for simple Arbitrary instances · 8492daa3
      Iustin Pop authored
      
      After getting really annoyed at yet another "<*> arbitrary", I thought
      that we should be able to automate this, at least for types which are
      simple enough and have already all the "prerequisites".
      
      Hence the new genArbitrary function and its helpers, which can:
      
      - build an arbitrary for Bounded types, using the regular "elements
        [minBound..maxBound]" (20 manually defined cases right now)
      - build an arbitrary instance for single-constructor data types,
        e.g. "data A = A x y z", using a simple "arbitrary = pure A <*>
        arbitrary <*> arbitrary <*> arbitrary"
      - build an arbitrary instance for multi-constructor data types, using
        "arbitrary = oneof [<arbitrary for each individual construct, per
        the previous>]"
      
      Both normal and record-based constructors are supported.
      
      It can also build arbitrary instances for new types and type synonyms,
      although for these last two I'm not so confident on the soundness of
      the instances.
      
      Note that this helper won't work for types which are not well behaved;
      for example, Node has the name as String not as FQDN, so our manually
      written arbitrary instance has just a few overrides as getFQDN instead
      of arbitrary, so we can't automate this particular type yet; this only
      means we get another push to use proper types, instead of primitive
      ones, for fields which have any kinds of restrictions ("what's good
      for arbitrary is good for regular code" too).
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      8492daa3
    • Iustin Pop's avatar
      Add Instance serialisations tests · ce93b4a0
      Iustin Pop authored
      
      This is not perfect, as for many of the parameters we don't have good
      Arbitrary instances, but is better than nothing.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      ce93b4a0
    • Iustin Pop's avatar
      Add a test helper for simple JSON serialisation testing · 63b068c1
      Iustin Pop authored
      
      While adding yet another JSON serialisation test, I realised that this
      can be trivially abstracted; hence this patch, replacing both simple
      versions (readJSON . showJSON == id) and the standard version (with
      different error messages) across the tests with a single function
      call.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      63b068c1
    • Iustin Pop's avatar
      Add unit test for serialisation of DiskLogicalId and Nodes · 8d2b6a12
      Iustin Pop authored
      
      Since the DiskLogicalId type is manually serialised/deserialised (see
      Objects.hs, `encodeDLid' and `decodeDLId'), let's add a test that
      checks that these are idempotent when combined.
      
      Since we're at it, let's add the same test for Node serialisation,
      which already has an Arbitrary instance.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      8d2b6a12
    • Iustin Pop's avatar
      Add unittests for the BasicTypes module · 1493a93b
      Iustin Pop authored
      
      This adds test properties for the various laws that the instances of
      Result should follow; I could not find (offline) laws about `mappend',
      but otherwise I implemented all laws that I could find.
      
      Note that we have to silence hlint warnings for the things we want to
      test, as otherwise hlint is all "this is already true based on the
      functor law, why 'fmap id' and not just 'id'?".
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      1493a93b
    • Iustin Pop's avatar
      Fixup test suite names · e09c1fa0
      Iustin Pop authored
      
      The names were not in a proper hierarchy, leading to inconsistencies
      about what they were actually tested.
      
      We change this by reproducing in the test names the relative hierarchy
      within the Ganeti directory, leading to nicer test suite names (in
      test-framework output).
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      e09c1fa0
    • Iustin Pop's avatar
      Simplify property and test case names · 20bc5360
      Iustin Pop authored
      
      Since we now have separate namespaces due to the multi-file split, we
      don't need to keep the name of the module in the property names, as we
      don't have so many potential conflicts anymore.
      
      We remove the group prefix handling from TestHelper and simply do a
      sed over all the test files, removing it from the function names.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      20bc5360
    • Iustin Pop's avatar
      Move Version.hs up from under HTools/ · 2997cb0a
      Iustin Pop authored
      
      This is another module that is generic, and not htools-specific.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      2997cb0a
    • Iustin Pop's avatar
      Two tiny makefile fixes · 662de722
      Iustin Pop authored
      
      During the recent moves and renames, two things have slipped through,
      since I didn't run make check-local…
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarRené Nussbaumer <rn@google.com>
      662de722
  2. Sep 04, 2012
  3. Sep 03, 2012
    • Iustin Pop's avatar
      Fix warnings/errors with newer pylint · 8ad0da1e
      Iustin Pop authored
      
      To help developing Ganeti on newer distributions, let's try to fix
      pylint warnings/errors. I'm using pylint from current Debian wheezy:
      pylint 0.25.1, astng 0.23.1, common 0.58.0, and we have 3 things that
      needs fixing.
      
      First, a really wide "except", with the silencing in the wrong
      place. I'm not sure why this doesn't have "except Exception", so let's
      add it. However, pylint still complains about "Catching too general
      exception", even though we do want to catch both system and our
      exception, so let's add a silence for W0703. It's true that we
      shouldn't catch KeyboardInterrupt and friends, but that should be
      cleaned up on the master branch.
      
      Second, pylint complains about "redefining name builtin tuple",
      because we do some pattern matching in the except blocks in
      netutils. This seems to be a false positive, but let's clean the code
      around this.
      
      And finally, type inference again goes bad, so let's silence E1103
      with its "boolean doesn't have 'get' method".
      
      After this, I can run "make lint", and by extension "make
      commit-check" on Debian Wheezy, yay! We might be able to bump our
      required pylint versions to something not ancient…
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
      8ad0da1e
    • Guido Trotter's avatar
      Merge branch 'devel-2.6' · e53decc1
      Guido Trotter authored
      
      * devel-2.6:
        Instance autorepair design
      
      Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
      Reviewed-by: default avatarIustin Pop <iustin@google.com>
      e53decc1
    • Iustin Pop's avatar
      Fix decorator uses which crash newer pylint · fc3f75dd
      Iustin Pop authored
      
      Pylint version:
      
        pylint 0.25.1,
        astng 0.23.1, common 0.58.0
      
      crashes when passing the fully-qualified decorator name with:
      
        File "/usr/lib/pymodules/python2.7/pylint/checkers/base.py", line 161, in visit_function
          if not redefined_by_decorator(node):
        File "/usr/lib/pymodules/python2.7/pylint/checkers/base.py", line 116, in redefined_by_decorator
          decorator.expr.name == node.name):
      AttributeError: 'Getattr' object has no attribute 'name'
      
      I found out that simply using a shortened name will 'fix' this issue,
      so let's do this to allow running newer pylint versions.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
      fc3f75dd
    • Guido Trotter's avatar
      Instance autorepair design · 68640987
      Guido Trotter authored
      
      This design describes a tool that will perform automatic repairs on
      instances when they are detected to be unhealthy (living on offline or
      drained nodes, at the moment). These repairs can be scheduled
      automatically or requested as a one-off by a tool or person.
      
      Signed-off-by: default avatarGuido Trotter <ultrotter@google.com>
      Reviewed-by: default avatarBernardo Dal Seno <bdalseno@google.com>
      Reviewed-by: default avatarIustin Pop <iustin@google.com>
      68640987
    • Iustin Pop's avatar
      Add missing luxi query 'QueryFields' · 72295708
      Iustin Pop authored
      
      This was missed; we add the definition and the de-serialisation
      support.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      72295708
    • Iustin Pop's avatar
      Add Query support for Nodes (no filtering, no RPC) · 046fe3f5
      Iustin Pop authored
      
      This is the initial support for Query2: basic infrastructure (except
      filtering) and node query support (without RPC).
      
      It implements all the fields (tests by comparison with list-fields on
      the Python side), except that:
      
      - filter is not done
      - since RPC is not integrated yet, the runtime gathering/computing is
        simply stubbed out
      
      However, the infrastructure seems pretty reasonable, so I'm sending as
      is.
      
      Note that I've split the functions/declarations into multiple files,
      to keep each file clean and readable.
      
      Signed-off-by: default avatarIustin Pop <iustin@google.com>
      Reviewed-by: default avatarAgata Murawska <agatamurawska@google.com>
      046fe3f5
Loading