- Dec 04, 2012
-
-
Guido Trotter authored
This module implements some algorithms on Data.Graph data structures. At the moment its main functionality is an LF-color implementation (greedy coloring in descending order of degree). There are also a few extra functions to calculate the degree order, and convert the node to color mapping to color to nodes. Signed-off-by:
Guido Trotter <ultrotter@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Dec 03, 2012
-
-
Michele Tartara authored
The serialization itself is done by Text.JSON, so the tests deal with checking that Text.JSON objects are created correctly from the DRBD parser data structures. Signed-off-by:
Michele Tartara <mtartara@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 27, 2012
-
-
Michele Tartara authored
* Now the parser completely consumes the input, up to the end of the text. * Name of the test suite module changed to adhere to naming conventions. * Some reformatting of the source code. Signed-off-by:
Michele Tartara <mtartara@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Nov 20, 2012
-
-
Michele Tartara authored
This adds tests that existing test files can be parsed by the Haskell parser as well, plus one new test file. Signed-off-by:
Michele Tartara <mtartara@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
Iustin Pop authored
There are already three cases where we copied type definitions between the htools-specific types into the main ganeti code. Let's stop doing this
☺️ and create a common types module that holds these. Note that there already exists BasicTypes.hs, but that refers to very low-level types, and can't use TH derivation itself. A side effect of this unification is that there is a small conflict between AdminStatus/AdminOffline and InstanceStatus/AdminOffline. As such, I renamed AdminOffline and AdminDown to StatusOffline/StatusDown in the InstanceStatus type. The patch also moves the tests related to these types to a new test module. Signed-off-by:Iustin Pop <iustin@google.com> Reviewed-by:
Adeodato Simo <dato@google.com>
-
- Nov 13, 2012
-
-
Michele Tartara authored
Attoparsec is known to have had issues with parsing non-ASCII strings. This test makes sure that parsing of Unicode characters works fine. Signed-off-by:
Michele Tartara <mtartara@google.com> [iustin: small doc string fixes] Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Oct 26, 2012
-
-
Iustin Pop authored
Five modules under the HTools/ directories are backend implementations, so let's move them to a separate directory, to more clearly show the hierarchy. I wanted to do this for a while, but merging between branches is always an issue, so let's do it know since we have an opportunity. This patch contains the actual renames, the required changed module names, imports, etc., but no other changes. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This is very THH specific, and applies to all serialisations generated by THH, so I'm adding it in its own module. Probably we should add some more generic tests, but in general THH code is tested by the various definitions; this new field type however is not (yet), so this is why I want this specific unittest. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 25, 2012
-
-
Iustin Pop authored
As described in the module doc string, while writing this it dawned upon me that we're mixing all errors together into a single hierarchy (well, type on the Haskell side), which is not good. Some errors are used purely within noded, some in the CLI frontends, etc. so these should not be the same type; frontend functions should only be able to raise frontend errors, not backend ones. As to this patch itself, I've used again Template Haskell to generate both the data type and the serialisation functions, as the initial version, hand-written, seemed too prone to errors due to string matching. A small unittest for checking serialisation consistency is also added. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Oct 08, 2012
-
-
Iustin Pop authored
This is, I believe, the last non-htools specific file that still lived in the htools directory; it's already widely used in non-htools code, so let's move it before we add more functionality to this module. All changes are related to the name change, imports fixup, etc.; there are no other changes in this patch. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
- Sep 07, 2012
-
-
Iustin Pop authored
We can build the test groups directly in the `testSuite' helper, instead of doing it (much later) in the test harness. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
Iustin Pop authored
Since the recent commits improved the speed of the two "slow" test groups to regular test speed, we can remove this kludge and simplify significantly our test runner, yay! Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- Sep 05, 2012
-
-
Iustin Pop authored
While investigating how we could test the Daemon.hs module, I realised that we have a very, erm, sub-optimal situation: - HTools/CLI.hs has a nice IO/pure separation testing in cmdline parsing, which allows some basic functionality to be tested, but uses direct 'read' in many options, which fails at runtime when evaluating the argument, and not when parsing the options - Daemon.hs lacks that, but has a much nicer 'reqWithConversion' helper that can be used for nicer option parsing, and uses that + tryRead instead of plain 'read' Since this situation is very bad, let's clean it up. We introduce yet another module, Common.hs, that holds functionality common to all command line programs (daemons or not). We move the parsing to this module, and introduce a type class to handle option types which support --help/--version. This allows removal of duplicated code from CLI.hs and Daemon.hs. The other part of the patch is cleanup/rework of the tests for this code: we introduce some helpers (checkOpt, passFailOpt, checkEarlyExit) that can be used from the much-slimmer now tests for CLI and Daemon. In the common module, we just test the yes/no helper we have. Many new tests for boolean options and numeric options are added. A side change is the removal of the obsolete `--replay-count', `--test-size' options (unused since commit 95f6c931, “Switch Haskell test harness to test-framework”). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
These tests are node specific only because we don't have other query types implemented yet, but what they actually test is the various filter types. The tests are trying to cover most filter functionality; missing for now is proper checking for ContainsFilter and TrueFilter, the rest should be more or less covered. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
These new tests check that: - no known fields return unknown - any unknown field returns unknown - the type of the fields is consistent between the getters and the field definition - the length of each result row corresponds with the number of fields queried, and the length of the field definitions returned - the length of the rows corresponds to the number of nodes - querying fields on empty fields returns all fields Finally this patch found a bug, in that the pinst_list/sinst_list fields were declared as QFTNumber (copy-paste error from pinst_cnt/sinst_cnt), yay! I also changed genEmptyCluster to ensure that it generates unique node names, so that the number of result rows is consistent with what we requested, and switched ResultEntry from a normal constructor to record syntax, so that we can extract the fields without having to use pattern matching. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
Using the recently-added genArbitrary, we can now implement Arbitrary instances for even "huge" objects like Cluster, so let's use that to implement entire ConfigData serialisation tests. Note that, as we don't have yet proper types for some of the Params fields, we have to cheat via FlexibleInstances and TypeSynonymInstances, using either empty items or real arbitrary values. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
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:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
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:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
- Sep 04, 2012
-
-
Iustin Pop authored
In order to have correct code coverage results, we must somehow import all production modules into the test runner. Until now, this was done manually (when we didn't forget) in QC.hs. To improve the situation, we remove QC.hs and replace it with an auto-generated file which imports all modules. This reduces the maintenance burden and ensures we'll always have correct coverage. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Michael Hanselmann <hansmi@google.com>
-
Iustin Pop authored
This makes QC.hs obsolete, but we will remove it in a later patch, once we automatically build a file with all the imports (to ensure correct coverage results). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
Except for Ganeti.HTools.JSON, which needs rename, we split all the other test suites into separate files. We have to add another common test helper, due to import dependencies (sigh), but otherwise this split is pretty straightforward. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
… from QC.hs into their own files, again mirroring the production code source tree. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
This required lots of other code moves, so I created it as a standalone patch. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
This splits the confd/utils tests, and adds the TestCommon module for shared test code. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
This is the first file split out from QC.hs - an easy one, since it has just one test. The patch changes the way we build hpc excludes, since now we'll have many modules that need to be excluded, and hpc doesn't seem to be able to do wildcards (it can do packages, but all our code is not-package-based). Further splitting will be done in bigger batches. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
This is the first commit of a series that will attempt to cleanup the test code organisation, which evolved somewhat organically from the initial pure htools functionality. The proposed organisation of the tree will be as follows: - htools (or maybe renamed to haskell or hs): only production code - htest: top-level test directory, containing test.hs, static helper scripts, etc. - htest/Ganeti/*.hs: modules implementing the actual test properties and test cases for the correspondingly-named production code modules - htest/data: containing test data files for the test cases This particular patch moves all the test code (test.hs, hpc-htools.hs symlink) and helper scripts (offline-test.sh, etc.) from htools/ to htest/, while updating the files themselves (if they had paths mentioning htools/), .gitignore and the Makefile. The only special mention is that in Makefile, we used to have a BINARY shell variable in binary build rule; that was computed via stripping `htools/' prefix; I've cleaned that and replaced with $(notdir $@); even though it's duplicated a few times, it leads to more readable make output (and easier to copy-paste). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
- Sep 03, 2012
-
-
Iustin Pop authored
This is similar to the Python version, objects.py:FillDict. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
- Aug 28, 2012
-
-
Iustin Pop authored
These test that we encode requests correctly and decode good messages, that a message with a too old/new timestamp is never accepted, and that a message signed with a different key is never accepted. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
With the change to test-framework, where individual tests are listed, QCHelper tries to remove a "prop_$group_" prefix from the function names, for shorter names. However, some test groups (LUXI) and test functions are not uniform, leading to long names, so we should fix them. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
This patch replaces our home-grown, and quite limited, test runner infrastructure with test-framework (http://batterseapower.github.com/test-framework/ ). The rationale for doing so is as follows: - we will need to add support for HUnit tests, so either we add more custom code or we switch to an existing library - test-framework is mature and already packaged, at least in Debian/Ubuntu - it supports more features: parallel test running, better test selection, etc. As you can see, the changes are trivial, and don't touch the tests at all; if/when we split the QC.hs file into per-module files, then we could drop QCHelper too, and replace it with test-framework-th, which does the same, but even more automated (auto-discovery, without having to list the tests at all). Dependencies are updated in devnotes.rst; note that I've already added the hunit dependencies since we're going to use that soon. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
While starting to use the new filter types, I realised that what is currently implemented is the equivalent of `lib/qlang.py', not `lib/query.py', since we only deal with data types for now and not the actual query runtime functionality (RPC, config, etc.). Let's rename the file to be more consistent with the Python code base. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Iustin Pop authored
This adds support for encoding/decoding Query2 filters to/from JSON, in (hopefully) the same format as the Python code generates. It also adds a simple unit-test to check that this conversion is idempotent. Of note here is that, since the Filter data type is recursive, we have to manually ensure that the generator for it correctly "shrinks" at each step (first version crashed hard my workstation after eating ~8GB of ram :). Compared to the current Query2 implementation, the following changes were done: - style: shortened some names to match the Python ones (LessEqualThan → LE, etc.) - changed FilterValue from string to an ADT that can encode both quoted strings and numeric values, since this is actually what qlang.py generates - added support for EmptyField, which in hindsight it's an obvious missing part :) Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-
Agata Murawska authored
Right now we're only able to test if when a node is offline, the call fails with an appropriate errror. Signed-off-by:
Agata Murawska <agatamurawska@google.com> Reviewed-by:
Iustin Pop <iustin@google.com>
-
- Jun 08, 2012
-
-
Iustin Pop authored
This patch fixes a (brown-bag) bug in the ssconf implementation where the looked-for filenames were not prefixed with the ssconf file prefix. Additionally, a test for this is added (which fails without the fix). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Guido Trotter <ultrotter@google.com>
-
- May 08, 2012
-
-
Iustin Pop authored
This patch adds a hand-coded decoder for LuxiCall arguments, as the data-structure is not uniform enough for automated generation (even for the serialisation, we had to add hints for some fields, de-serialisation is even harder). It also fixes a tiny issue with WaitForJobChange job ID encoding, and adds unittests for the encoding/decoding of LuxiOp structures. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
And its associated unittests. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
- Feb 29, 2012
-
-
Iustin Pop authored
This is not perfect, as the override applies identical target test values to both the 'fast' and 'slow' tests (making the slow tests take a long time), but it allows a quick override for manual runs. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
- Jan 16, 2012
-
-
Iustin Pop authored
'zip' finishes on the shortest list, so parseISpecString accepted any string of 3 values or more, which is not good. Fix this and add test for both successful and failed parsing. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
Iustin Pop authored
This only test successful parsing, but for this case it tests reasonably well the resulting cluster properties, I think (coverage is >70% for expressions). Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
René Nussbaumer <rn@google.com>
-
- Dec 08, 2011
-
-
Iustin Pop authored
First, we update the recommended hlint version to what I used to get a clean output (1.8.15). Most of the changes are: - remove unneeded parentheses - some simplifications (intercalate " " → unwords, maybe … id → fromMaybe, etc.) - removal of some duplicate code (in previous patches) There are still some warnings which I didn't clean out but plain ignored: - 'Eta reduce' in some specific files, because the type inference specialises the function on the first call, and annotating the type properly would be too verbose - use of 'first', 'comparing', and 'on', since these don't seem to be widely or consistently used (outside ganeti/htools, I mean) - use of Control.Exception.catch, as we only care about I/O errors; at one point yes, we will need to transition to this new API - 'Reduce duplication', since hlint warns even for 3 duplicate lines, and abstracting that away seems overkill to me After this patch, make hlint is clean and doesn't exit with an error anymore; we could enable it automatically on 'make lint' if hlint is detected (future patch). Note that we explicitly skip the THH.hs file from checking because it seems that hlint doesn't parse correctly for now the splice notation. Signed-off-by:
Iustin Pop <iustin@google.com> Reviewed-by:
Agata Murawska <agatamurawska@google.com>
-