Commit Graph

239 Commits

Author SHA1 Message Date
Mazz Mosley 1344533b24 filename is not optional
While it can be set to ultimately a value of None, when a
config file is read in from stdin, it is not optional.

We kinda make use of it's ability to be set to None in our
tests but functionally and design wise, it is required.

If filename is not set, extends does not work.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-09-02 15:42:38 +01:00
Aanand Prasad 83c514f838 Merge pull request #1933 from dnephin/fix_scale_test_flakes
Fix flaky test
2015-08-31 13:52:33 -07:00
mnowster f5d73fee57 Merge pull request #1932 from mrfuxi/image-dockerfile-validation
Do not allow to specify both image and dockerfile in configuration.
2015-08-28 10:12:54 +01:00
Daniel Nephin d264c2e33a Resolves #1804
Fix mutation of service.options when a label or environment variable is specified in the config.

Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-27 18:05:21 -04:00
Karol Duleba 477d4f491d Do not allow to specify both image and dockerfile in configuration. Closes #1908
Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
2015-08-27 19:36:39 +01:00
Aanand Prasad e777d08854 Merge pull request #1924 from dnephin/python3_fix_for_logs
Fix `docker-compose logs` on python3
2015-08-27 14:19:42 +01:00
Daniel Nephin 3a0153859a Resolves #1856, fix regression in #1645. Includes some refactoring to make testing easier.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-26 16:21:31 -04:00
Aanand Prasad ecd1cc31dc Merge pull request #1930 from dnephin/name_one_off_containers
Allow setting a one-off container name
2015-08-26 19:03:00 +01:00
Daniel Nephin d2718bed99 Allow setting a one-off container name
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-26 13:33:03 -04:00
Daniel Nephin bdec7e6b52 Cleanup some test case, remove unused mock return values, and use standard single underscore for unused variable
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-26 13:32:49 -04:00
Daniel Nephin 54973e8200 Remove flake8 ignores and wrap the longest lines to 140 char.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-26 12:53:11 -04:00
Daniel Nephin 9d9550c5b6 Fix log printing for python3 by converting everything to unicode.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-26 11:24:48 -04:00
Daniel Nephin 2b589606da Move log_printer_test into correct testing module for naming convention.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-25 16:49:49 -04:00
Daniel Nephin 71ff872e8e Update unit tests for stream_output to match the behaviour of a docker-py response.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-25 10:48:48 -04:00
Daniel Nephin 7e4c3142d7 Have log_printer use utf8 stream.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-25 10:47:06 -04:00
Daniel Nephin feaa4a5f1a Unit tests passing again.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-25 10:47:06 -04:00
Daniel Nephin 2943ac6812 Cleanup requirements.txt so we don't have to maintain separate copies for py2 and py3.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-25 10:46:08 -04:00
funkyfuture 9aa61e596e Run tests against Python 2.6, 2.7, 3.3, 3.4 and PyPy2
In particular it includes:
- some extension of CONTRIBUTING.md
- one fix for Python 2.6 in tests/integration/cli_test.py
- one fix for Python 3.3 in tests/integration/service_test.py
- removal of unused imports

Make stream_output Python 3-compatible

Signed-off-by: Frank Sachsenheim <funkyfuture@riseup.net>
2015-08-25 10:41:09 -04:00
Daniel Nephin 809443d6d0 Support python 3
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-25 10:37:29 -04:00
Daniel Nephin 59d4f304ee Run pre-commit on all files
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-08-24 17:04:50 -04:00
Joel Hansson 61936f6b88 log_opt: change address to syslog-address
Signed-off-by: Joel Hansson <joel.hansson@ecraft.com>
2015-08-20 16:46:06 +02:00
Aanand Prasad a806d9e77b Merge pull request #1855 from mnowster/number-is-a-valid-service-name
A number is a valid service name
2015-08-20 12:02:58 +01:00
mnowster 340eaf44fa Merge pull request #1889 from mrfuxi/1670-images-digest
Allow to specify image by digest. Fixes #1670
2015-08-20 10:55:00 +01:00
Karol Duleba 56f03bc20a Allow to specify image by digest. Fixes #1670
Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
2015-08-19 21:13:34 +01:00
mnowster 30b64e65cd Merge pull request #1859 from mrfuxi/extend-unexisting-service
Raise configuration error when trying to extend service that does not exist
2015-08-19 14:23:28 +01:00
Mazz Mosley 67995ab9e3 Pre-process validation steps
In order to validate a service name that has been specified as an
integer we need to run that as a pre-process validation step
*before* we pass the config to be validated against the schema.

It is not possible to validate it *in* the schema, it causes a
type error. Even though a number is a valid service name, it
must be a cast as a string within the yaml to avoid type error.

Taken this opportunity to move the code design in a direction
towards:

1. pre-process
2. validate
3. construct

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-13 16:32:20 +01:00
Daniel Nephin b87c09b9fc Merge pull request #1824 from mrfuxi/run-with-ports
Allow manual port mapping when using "run" command
2015-08-13 08:29:25 -07:00
Karol Duleba 2e7f08c2ef Raise configuration error when trying to extend service that does not exist. Fixes #1826
Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
2015-08-12 22:34:25 +01:00
Karol Duleba ff87ceabbd Allow manual port mapping when using "run" command. Fixes #1709
Signed-off-by: Karol Duleba <mr.fuxi@gmail.com>
2015-08-12 18:54:42 +01:00
Mazz Mosley 440099754d memory values can be strings or numbers
Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-12 17:29:33 +01:00
mnowster c443e95f07 Merge pull request #1825 from aanand/dedupe-unset-env-warnings
Avoid duplicate warnings if an unset env variable is used multiple times
2015-08-12 15:57:04 +01:00
Aanand Prasad 4c65891db1 Avoid duplicate warnings if an unset env variable is used multiple times
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-12 15:39:33 +01:00
Mazz Mosley 5e2ecff8a1 Fix ports validation
I had misunderstood the valid formats allowed for ports. They must
always be in a list.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-12 15:19:28 +01:00
Aanand Prasad ed31673069 Merge pull request #1827 from mnowster/port-ranges
Port ranges
2015-08-12 11:17:22 +01:00
Aanand Prasad fb4c9fbb8b Merge pull request #1808 from mnowster/129-validate-compose-yml
129 validate compose yml
2015-08-12 11:15:47 +01:00
Aanand Prasad 982a845635 Fix mem_limit and memswap_limit regression
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-11 14:17:30 +01:00
Mazz Mosley f8efb54c80 Handle $ref defined types errors
We use $ref in the schema to allow us to specify multiple type, eg
command, it can be a string or a list of strings.

It required some extra parsing to retrieve a helpful type to display
in our error message rather than 'string or string'. Which while
correct, is not helpful. We value helpful.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-11 13:08:12 +01:00
Mazz Mosley df14a4384d Catch non-unique errors
When a schema type is set as unique, we should display the validation
error to indicate that non-unique values have been provided for a key.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-11 12:01:27 +01:00
Mazz Mosley e0675b50c0 Retrieve sub property keys
The validation message was confusing by displaying only 1 level of
property of the service, even if the error was another level down.

Eg. if the 'files' property of 'extends' was the incorrect format,
it was displaying 'an invalid value for 'extends'', rather than
correctly retrieving 'files'.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-11 12:01:27 +01:00
Mazz Mosley ece6a72712 Clean error.message
Unfortunately the way that jsonschema is calling %r on its property
and then encoding the complete message means I've had to do this
manual way of removing the literal string prefix, u'.

eg:

key = 'extends'
message = "Invalid value for %r" % key
error.message = message.encode("utf-8")"

results in:

"Invalid value for u'extends'"

Performing a replace to strip out the extra "u'", does not change the
encoding of the string, it is at this point the character u followed
by a '.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-11 12:01:27 +01:00
Mazz Mosley b4872de213 Allow integer value for ports
While it was intended as a positive to be stricter in validation
it would in fact break backwards compatibility, which we do not
want to be doing.

Consider re-visiting this later and include a deprecation warning if
we want to be stricter.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-11 12:01:27 +01:00
Mazz Mosley 52733f6996 Merge pull request #1833 from aanand/deprecate-relative-volumes-without-dot
Show a warning when a relative path is specified without "./"
2015-08-11 11:21:17 +01:00
Ben Firshman b7baa899e2 Merge pull request #1829 from vlajos/typofixes-vlajos-20150807
typofix - https://github.com/vlajos/misspell_fixer
2015-08-10 22:13:30 +01:00
Aanand Prasad 46e8e4322a Show a warning when a relative path is specified without "./"
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-10 19:56:36 +01:00
Aanand Prasad dfa4bf4452 Ignore containers that don't have a name
If a container is in the process of being removed, or removal has
failed, it can sometimes appear in the output of GET /containers/json
but not have a 'Name' key. In that case, rather than crashing, we can
ignore it.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-10 16:29:12 +01:00
Veres Lajos 11adca9324 typofix - https://github.com/vlajos/misspell_fixer
Signed-off-by: Veres Lajos <vlajos@gmail.com>
2015-08-07 22:34:24 +01:00
Yuval Kohavi 0fdd977b06 fixed merge issue from previous commit
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
2015-08-07 16:22:39 +01:00
Yuval Kohavi 297941e460 rebasing port range changes
Signed-off-by: Yuval Kohavi <yuval.kohavi@gmail.com>
2015-08-07 16:22:39 +01:00
Mazz Mosley df74b131ff Use split_port for ports format check
Rather than implement the logic a second time, use docker-py
split_port function to test if the ports is valid.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 15:27:30 +01:00
Mazz Mosley 2e428f94ca Refactor validation out
Move validation out into its own file without causing circular
import errors.

Fix some of the tests to import from the right place.

Also fix tests that were not using valid test data, as the validation
schema is now firing telling you that you couldn't "just" have this
dict without a build/image config key.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 12:06:34 +01:00
Mazz Mosley ea3608e1f4 Improve test coverage for validation
Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 12:06:34 +01:00
Mazz Mosley d8aee782c8 Error handling
jsonschema provides a rich error tree of info, by parsing each error
we can pull out relevant info and re-write the error messages.

This covers current error handling behaviour.

This includes new error handling behaviour for types and formatting of
the ports field.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 12:06:34 +01:00
Mazz Mosley 6c7c598546 Format validation of ports
Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 12:06:34 +01:00
Mazz Mosley 76e6029f21 Replace service tests with config tests
We validate the config against our schema before a service is created
so checking whether a service name is valid at time of instantiation of
the Service class is not needed.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 12:06:34 +01:00
Mazz Mosley da36ee7cbc Perform schema validation
Define a schema that we can pass to jsonschema to validate against the
config a user has supplied. This will help catch a wide variety of common
errors that occur.

If the config does not pass schema validation then it raises an exception
and prints out human readable reasons.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-08-07 12:06:34 +01:00
Aanand Prasad fdaa5f2cde Update volume tests for clarity
- Better method names.

- Environment variable syntax in volume paths, even when a driver is
  specified, now *will* be processed (the test wasn't testing it
  properly). However, `~` will still *not* expand to the user's home
  directory.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-06 16:14:37 +01:00
Aanand Prasad 8b5bd945d0 Interpolate environment variables
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-06 11:18:57 +01:00
Aanand Prasad 92ef1f5702 Make compose.config a proper module
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-08-05 15:50:22 +01:00
Luke Marsden a68ee0d9c2 Support volume_driver in compose
* Add support for volume_driver parameter in compose yml
* Don't expand volume host paths if a volume_driver is specified
  (i.e., disable compose feature "relative to absolute path
  transformation" when volume drivers are in use, since volume drivers
  can use name where host path is normally specified; this is a
  heuristic)

Signed-off-by: Luke Marsden <luke@clusterhq.com>
2015-07-31 15:23:15 +01:00
Aanand Prasad 80d90a745a Make sure an exception in any iterator gets raised in the main thread
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>

Conflicts:
	compose/cli/multiplexer.py
2015-07-29 19:42:33 +01:00
Aanand Prasad a9942b512a Wait for all containers to exit when running 'up' interactively
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-07-29 19:42:33 +01:00
Aanand Prasad 04a773f1c8 Deprecate --allow-insecure-ssl
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-07-23 10:56:21 +01:00
Aanand Prasad 233c509f71 Remove logging test
It doesn't do much other than cause the remainder of the test suite to
generate lots of junk output.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-07-21 15:56:37 +01:00
Aanand Prasad 89f6caf871 Allow any volume mode to be specified
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-07-17 16:14:09 +01:00
Mazz Mosley 2db0a377e2 Minor test refactor
Rather than creating a docker client within each test, create one
at setup and make it accessible to the whole class.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-13 14:11:12 +01:00
Aanand Prasad 81707ef1ad Merge pull request #1643 from aanand/warn-about-legacy-one-off-containers
Show an error on 'run' when there are legacy one-off containers
2015-07-08 14:48:03 +01:00
Aanand Prasad 8b033d3946 Merge pull request #1665 from mnowster/1648-support-log-opt
1648 support log opt
2015-07-07 17:08:04 +01:00
Mazz Mosley 6f31e8ebe9 Add support for log_opt
When specifying a log_driver you want to specify some options for
the logger as per the docker run --log-opt option. The logger
options are key value pairs.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-07 16:26:43 +01:00
Aanand Prasad 531265bc84 Fix smart recreate when 'image' is changed to something nonexistent
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-07-07 16:01:44 +01:00
Mazz Mosley fc26982132 Add in memswap_limit run option
By allowing the memswap_limit option to be defined we also need to
check that mem_limit is set, you can't have swap without a limit.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-06 17:08:57 +01:00
Aanand Prasad e98caf5cf9 Show an error on 'run' when there are legacy one-off containers
Also warn the user about the one-off containers in the standard error
message about legacy containers.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-07-06 14:45:17 +01:00
Mazz Mosley 317bbec98c Move make_service_dict out of config
This top level function is a test helper, so I've moved it into the
config_test file and updated accordingly.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 15:06:53 +01:00
Mazz Mosley 6e6dbdad95 working_dir is no longer optional
When building test data using make_service_dict, we need to include
working_dir as it is core to some of the functionality of
ServiceLoader.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 14:56:18 +01:00
Mazz Mosley c6e03d739d Test self referencing 'file'
When specifying the 'file' key to a value of it's own name, test
that this works and does not cause a false positive circular reference
error.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 14:14:47 +01:00
Mazz Mosley ba71e2a549 Use new load_from_filename
Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 14:05:14 +01:00
Mazz Mosley 254bc4908c Move extends validation into ServiceLoader class
This refactoring allows us to raise an error when there is no
'file' key specified in the .yml and no self.filename set. This
error was specific to the tests, as the tests are
the only place that constructs service dicts without sometimes
setting a filename.

Moving the function within the class as well as it is code that
is exclusively for the use of validating properties for the
ServiceLoader class.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 11:26:31 +01:00
Mazz Mosley 24c1d95869 Refactor extends validation tests
Split them out into individual validation tests so it is clearer
to see what is going on and to enable adding further validation
tests.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 11:26:31 +01:00
Mazz Mosley 6e4a954dbd 'file' key can be omitted from extends
If the 'file' key is not set in the extends_options dict then we
look for the 'service' from within the same file.

Fixes this issue: https://github.com/docker/compose/issues/1237

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-03 11:26:30 +01:00
Aanand Prasad db7e5124f3 Merge pull request #1488 from dnephin/config_from_stdin
Support reading config from stdin
2015-07-03 09:03:40 +01:00
Aanand Prasad a6b9982a1e Merge pull request #1633 from jeffk/parse_env_vars_in_all_volumes
Added env var parsing to volume container paths
2015-07-03 08:55:48 +01:00
Daniel Nephin ae96fc0071 Support reading config from stdin.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-07-02 22:16:22 -04:00
Jeff Kramer 8709dc3c24 Added env var parsing to volume container paths
This commit adds environment variable parsing to the container side
of the volume mapping in configs. The common use case for this is
mounting SSH agent sockets in a container, using code like:

volumes:
    - $SSH_AUTH_SOCK:$SSH_AUTH_SOCK
environment:
    - SSH_AUTH_SOCK

Signed-off-by: Jeff Kramer <jeff.kramer@voxmedia.com>
2015-07-02 13:13:38 -05:00
Mazz Mosley f33f673b49 Allow _.- chars in service names
As VALID_CHARS is shared with project names, these chars are also
now allowed within project names.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-01 17:57:50 +01:00
Mazz Mosley 8cf84ea552 Fix missing image names
These tests were indeed raising a config error, but not for the reason
intended/tested for. I've added in the image name so the config error
raise is correctly testing the Service name.

Signed-off-by: Mazz Mosley <mazz@houseofmnowster.com>
2015-07-01 17:57:50 +01:00
Aanand Prasad c8751980f9 Merge pull request #1578 from aanand/fix-migrate-help
Fix 'docker-compose help migrate-to-labels'
2015-06-21 17:25:52 -07:00
Aanand Prasad 4f83a18912 Merge pull request #1570 from aanand/fix-build-pull
Explicitly set pull=False when building
2015-06-21 17:25:46 -07:00
Aanand Prasad 93372dd665 Fix 'docker-compose help migrate-to-labels'
- Fix "No such command" error

- Add text from migration section of install docs

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-06-19 15:43:53 -07:00
Aanand Prasad c22cc02df5 Don't set network mode when none is specified
Setting a value overrides the new default network option.

Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-06-19 15:22:13 -07:00
Aanand Prasad bef0926c58 Explicitly set pull=False when building
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-06-18 17:43:16 -07:00
Daniel Nephin 06db577105 Move converge() to a test module, and use a short timeout for tests.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-06-14 17:18:27 -04:00
Travis Thieman c24d5380e6 Extend up -t to pass timeout to stop running containers
Signed-off-by: Travis Thieman <travis.thieman@gmail.com>
2015-06-14 16:45:28 -04:00
Aanand Prasad 08bc4b830b Fix volume binds de-duplication
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-06-12 16:57:22 -04:00
Todd Whiteman b9c502531d Possible division by zero error when pulling an image - fixes #1463
Signed-off-by: Todd Whiteman <todd.whiteman@joyent.com>
2015-05-26 15:34:34 -07:00
Aanand Prasad b0cb31c186 Use 'top' instead of 'sleep' as a dummy command
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-05-21 16:24:29 +01:00
Aanand Prasad ef4eb66723 Implement smart recreate behind an experimental CLI flag
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
2015-05-18 18:39:18 +01:00
Daniel Nephin 62059d55e6 Add migration warning and option to migrate to labels.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-05-18 10:55:12 -04:00
Daniel Nephin ed50a0a3a0 Resolves #1066, use labels to identify containers
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-05-18 10:47:26 -04:00
Daniel Nephin 417d9c2d51 Use individual volumes for recreate instead of volumes_from
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-05-11 13:01:43 -04:00
delbert@umn.edu df87bd91c8 Added devices configuration option
Signed-off-by: Dan Elbert <dan.elbert@gmail.com>
2015-05-11 10:50:58 -05:00
Daniel Nephin 6829efd4d3 Resolves #874, Rename instead of use an intermediate.
Signed-off-by: Daniel Nephin <dnephin@gmail.com>
2015-05-07 21:53:41 -04:00