Merge lp:~gz/juju-ci-tools/gzip_logs_hang into lp:juju-ci-tools
- gzip_logs_hang
- Merge into trunk
Status: | Merged |
---|---|
Merged at revision: | 1012 |
Proposed branch: | lp:~gz/juju-ci-tools/gzip_logs_hang |
Merge into: | lp:juju-ci-tools |
Diff against target: |
86 lines (+28/-19) 2 files modified
deploy_stack.py (+3/-4) test_assess_heterogeneous_control.py (+25/-15) |
To merge this branch: | bzr merge lp:~gz/juju-ci-tools/gzip_logs_hang |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Aaron Bentley (community) | Needs Fixing | ||
Review via email: mp+243179@code.launchpad.net |
Commit message
Description of the change
Avoid hang I ran into testing upgrade locally where having no logs in the artefacts dir hung the process
If there are no logs, don't try to gzip them, rather than running gzip with no args - which makes it read from stdin instead.
- 752. By Aaron Bentley
-
Give equal time to old and new clients in DeployManyAttempt
- 753. By Aaron Bentley
-
Use eight containers instead of 10 for AWS.
- 754. By Aaron Bentley
-
Improve logging for industrial test.
- 755. By Martin Packman
-
More concise reporting in jujupy when waiting for status changes
Martin Packman (gz) wrote : | # |
I disagree about actually wanting to exec gzip in tests - I think that's exactly the level we want to mock out. Asserting that the gzip command line and the filename passed, which I did as a side effect as part of this change, should be good enough to trust we'll really get the compressed files in real usage.
Aaron Bentley (abentley) wrote : | # |
Sorry, I didn't mean actually execcing gzip, just asserting that subprocess does/doesn't get run (like the tests previously did) is fine. I was saying that mocking out glob isn't necessary to control whether gzip gets run, and it's a better test if we don't.
- 756. By Aaron Bentley
-
Emit status text for agent timeout.
- 757. By Aaron Bentley
-
Suite param istead of --quick option, rename 'quick' to 'density'.
- 758. By Curtis Hovey
-
Support both .tgz and .tar.gz backup file names.
- 759. By Aaron Bentley
-
Support Joyent for backup/restore.
- 760. By Curtis Hovey
-
Add support for weekly streams. Downloading candidated and extracting them.
- 761. By Curtis Hovey
-
Fixed revision_build key.
- 762. By Curtis Hovey
-
Remove pdb. :(.
- 763. By Curtis Hovey
-
Fixed revision_build in test data.
- 764. By Aaron Bentley
-
Add schedule_
reliability_ tests.py - 765. By Aaron Bentley
-
Skip artifacts directories.
- 766. By Curtis Hovey
-
Add a sleep to ha because Juju lies about ha ready.
- 767. By Aaron Bentley
-
Use a 2x2 config for DeployManyAttempt when type is maas.
- 768. By Aaron Bentley
-
Add run-reliability
-test - 769. By Aaron Bentley
-
Add timeout to EnvJujuClient.
destroy_ environment. - 770. By Martin Packman
-
Add newline after final report while waiting for changes in jujupy
- 771. By Aaron Bentley
-
Select suite and jobs for reliability testing.
- 772. By John George
-
Move the parse_error function and its mock dependency to test_utility.py
- 773. By Aaron Bentley
-
Increase set of agent-state-infos that indicate failure.
- 774. By Aaron Bentley
-
Update dependency handling.
- 775. By John George
-
Add support to the terminate_instances function for maas.
- 776. By Curtis Hovey
-
Use jujuci.py helper to get artifacts.
- 777. By Aaron Bentley
-
Support agent-url
- 778. By Aaron Bentley
-
Use find_candidates in schedule-
hetero- control - 779. By Aaron Bentley
-
Always delete jenv in industrial test.
- 780. By Curtis Hovey
-
Revert use of jujuci.py because it will not exist on the remote machine.
- 781. By Curtis Hovey
-
Do not let EC2 issues damn unit-test results.
- 782. By Curtis Hovey
-
Added build_juju.py to mange building juju on a jenkin's job.
- 783. By Curtis Hovey
-
Fix argument order in build_juju.py.
- 784. By Curtis Hovey
-
Alway honour --juju-
release- tools. - 785. By Curtis Hovey
-
Give maas more time to upgrade.
- 786. By Curtis Hovey
-
Fix args to build_juju.py; osx-client is what crossbuild expects.
- 787. By Curtis Hovey
-
Do not swallow errors retrieving logs.
- 788. By Curtis Hovey
-
Extend the status timeout during upgrades to 5 minutes.
- 789. By Curtis Hovey
-
Use relativePath when creating links to archived files.
- 790. By Curtis Hovey
-
Added --install-juju to test-win-client so that we can switch to the crossbuilder.
- 791. By John George
-
add branch 1.21 support to check_blockers
- 792. By Curtis Hovey
-
Parameterise args so that restricted network testing can run on precise or trusty.
- 793. By Aaron Bentley
-
Log exceptions in the context where they were emitted.
- 794. By Curtis Hovey
-
Use dump_env_logs to call dump_logs for each machine in the env.
- 795. By Curtis Hovey
-
Allway update juju when updating the master and the slaves.
- 796. By Curtis Hovey
-
Increase the size of tmpfs to 3G.
- 797. By Curtis Hovey
-
Always capture logs from all the machines that were deployed.
- 798. By John George
-
Adds support for running juju quickstart to the jujupy module and adds the quickstart_
deploy. py script for starting test jobs. - 799. By Curtis Hovey
-
Need more output to debug build failures.
- 800. By John George
-
Add install of juju-quickstart and juju-deployer. Also pull latest updates into ~/repository.
- 801. By John George
-
Change repository update order, so CWD is ~/juju-ci-tools, so that make install-deps can proceed.
- 802. By John George
-
Added the --service-count option to quickstart_
deploy. py - 803. By Curtis Hovey
-
Move common bash rules into python jobs so that anyone can run the script locally.
- 804. By Aaron Bentley
-
Handle missing environments more cleanly.
- 805. By John George
-
Set management-
certificate- path for Azuze quickstart tests. - 806. By Curtis Hovey
-
Build vivid packages for testing.
- 807. By Aaron Bentley
-
Add remove-machine to industrial testing.
- 808. By Aaron Bentley
-
Avoid creating temp juju homes inside temp juju homes.
- 809. By Curtis Hovey
-
Add support to run unit-tests on windows,
- 810. By Curtis Hovey
-
Remove errant raise of exception.
- 811. By Curtis Hovey
-
Added rules to explain the version under test.
- 812. By Curtis Hovey
-
pass the glob to the script, not bash.
- 813. By Curtis Hovey
-
Fixed editing typo in JUJU_HOME.
- 814. By Curtis Hovey
-
Make the script more verbose for jenkins.
- 815. By Curtis Hovey
-
Do not sync agents from s3 because juju-ci is the canonical source. it is already correct.
- 816. By Aaron Bentley
-
Support testing backups on Azure.
- 817. By Aaron Bentley
-
Run bootstrap and restore asynchronously.
- 818. By Curtis Hovey
-
OSX cannot be crosscompiled (else x509 errors). Test osx client.
- 819. By Curtis Hovey
-
Ensure the osx testing env is destroyed.
- 820. By Curtis Hovey
-
Updated the osx-slave when we update branches.
- 821. By Curtis Hovey
-
It is not an error to destroy an non-existent env.
- 822. By Curtis Hovey
-
Pass the -y flag to destroy env.
- 823. By John George
-
While publishing weekly streams, backup the buildvars.json files to S3, to maintain a record of the builds that have been published.
- 824. By Aaron Bentley
-
Add --debug to all tests.
- 825. By Curtis Hovey
-
Update slaves by their registered hostname.
- 826. By John George
-
Make common-startup.sh less verbose.
- 827. By Curtis Hovey
-
Use new Joyent Client API.
- 828. By Curtis Hovey
-
Fix type and DNS resolution to update master and slaves.
- 829. By John George
-
While running _deploy_stack print Juju status between bootstrap and stack deployment, before upgrade and just before destroying the environment.
- 830. By Curtis Hovey
-
Just use host to get ip address of juju-ci.
- 831. By Curtis Hovey
-
Use juju-ci's real address when updating slaves. Update path for osx-slave.
- 832. By Curtis Hovey
-
Retry ssh connections to win-slave.
- 833. By Aaron Bentley
-
Switch OpenStackAccount to manager_
from_config. - 834. By Aaron Bentley
-
Use manager_from_config with AWS and OpenStack.
- 835. By John George
-
Restore debug output after common-startup.sh sources ec2rc
- 836. By Aaron Bentley
-
Allow optional temp_env_name to control the environment name used.
- 837. By Curtis Hovey
-
Added --clean-env to setup_workspace, removed teardown from common-startup.
- 838. By Curtis Hovey
-
Clean the osx client job too.
- 839. By Curtis Hovey
-
Fix mock calls.
- 840. By Curtis Hovey
-
Move the call to euca-create-tags to when we know the instances have descriptions.
- 841. By Curtis Hovey
-
Update clean_resources.py to use AWSAccount.
manager_ from_config. - 842. By Curtis Hovey
-
Do not call euca when credentials are not set.
- 843. By Aaron Bentley
-
Implement upgrade testing.
- 844. By Curtis Hovey
-
Use google's DNS to resolve the hosts to update.
- 845. By Curtis Hovey
-
Added azure lib and reconciled call to joyent client in preperation for modules to move.
- 846. By Curtis Hovey
-
Removed recursive tree and added symlink to match juju-release-tools.
- 847. By Curtis Hovey
-
Remove symlink because it breaks discover unittests.
- 848. By Curtis Hovey
-
Leave no mongod running.
- 849. By Aaron Bentley
-
Use credentials to access Jenkins.
- 850. By Aaron Bentley
-
Add credentials to build_juju and candidates.
- 851. By Curtis Hovey
-
Use jenkins user in osx build and run. Always use authentication when calling jujuci.
- 852. By Curtis Hovey
-
Source the creds in the bash script because they are not exposed by deploy_stack.
- 853. By Curtis Hovey
-
OS X uses a different JUJU_HOME.
- 854. By Curtis Hovey
-
Set a JUJU_HOME for os x.
- 855. By Curtis Hovey
-
Source the os x bashrc which maps linuxisms to os x.
- 856. By Curtis Hovey
-
Strip the \n from the basic auth because it causes request errors seen on several slaves.
- 857. By Curtis Hovey
-
Always source the os x bashrc.
- 858. By Curtis Hovey
-
JUJU_HOME != cloud-city on os-x
- 859. By Curtis Hovey
-
Make authorized jujuci requests from publish-revision and vagrant tests.
- 860. By Curtis Hovey
-
~/ci was removed from osx. we use $HOME now like other slaves.
- 861. By Aaron Bentley
-
Fix restricted-network tests to use auth for accessing Jenkins artifacts.
- 862. By Curtis Hovey
-
Ensure win tests don't see OpenSSH, and do see powershell.
- 863. By Curtis Hovey
-
Sanitise the os.environ['PATH'] for windows, not the sys.path.
- 864. By Curtis Hovey
-
Improve verbosity.
- 865. By Aaron Bentley
-
Remove unused LOCAL_JENKINS_URL
- 866. By Curtis Hovey
-
Copy the environ PATH to Path for win32; always remove OpenSSH.
- 867. By Aaron Bentley
-
Enhance upgrade test.
- 868. By Curtis Hovey
-
Cleanup manual instance when describe fails.
- 869. By Aaron Bentley
-
Run multiple suites and combine results.
- 870. By Aaron Bentley
-
Add --old-stable parameter to run-reliability
-test. - 871. By Curtis Hovey
-
Run win unittests through powershell.
- 872. By Aaron Bentley
-
Use authenticated access for schedule_... scripts.
- 873. By Aaron Bentley
-
schedule_
reliability_ tests accepts multiple --suite options. - 874. By Aaron Bentley
-
Fix schedule_
hetero_ control executability. - 875. By Seman
-
Ensure tests use future distro-info-data
- 876. By John George
-
Resolve MaaS DNS names against the server defined in the environment and use the IP to fetch logs.
- 877. By Curtis Hovey
-
Reverted revno 876 because AttributeError: 'EnvJujuClient' object has no attribute 'client'
- 878. By Aaron Bentley
-
Add upgrade-charm to industrial testing.
- 879. By Curtis Hovey
-
Moved azure and joyent instance management into juju-ci.tools.
- 880. By Aaron Bentley
-
Delete all files in before running industrial-test.
- 881. By Curtis Hovey
-
Honour old_age when killing joyent procs.
- 882. By John George
-
Add juju-deployer test support.
- 883. By John George
-
Reverting do to un-wanted arg order change.
- 884. By John George
-
Add juju-deployer test support.
- 885. By Curtis Hovey
-
Rety tagging instances instead of failing.
- 886. By Seman
-
Added a test to verify 'juju run' command continues to work before and after an upgrade
- 887. By Aaron Bentley
-
Switch deploy_stack from Environment to EnvJujuClient.
- 888. By Aaron Bentley
-
Revert r887.
- 889. By Aaron Bentley
-
Switch deploy_stack from Environment to EnvJujuClient.
- 890. By Aaron Bentley
-
Destroy environment when status is broken.
- 891. By Martin Packman
-
Always print a newline after GroupReporter output
- 892. By Martin Packman
-
Added script to fetch the latest Amazon image id, fixing merge history
- 893. By Seman
-
Updated a call to assess_juju_run() to ensure every deployment has a working ssh and run. Renamed test_upgrade() to assess_upgrade()
- 894. By Aaron Bentley
-
Add get-juju-bin and get-certificati
on-bin subcommands to jujuci - 895. By Aaron Bentley
-
Provide stub get_distro_
information if lsb_release cannot be imported. - 896. By Curtis Hovey
-
Provide more network information for analysis.
- 897. By Curtis Hovey
-
Fix function defintion.
- 898. By Martin Packman
-
Revert addition of get_ami script from r892
- 899. By Aaron Bentley
-
Add run_deploy_job.bash
- 900. By Aaron Bentley
-
Handle series in run-deploy-job.bash
- 901. By Curtis Hovey
-
Restore the default route when the test fails.
- 902. By Seman
-
Added safe_print_status to output juju status without raising exceptions. Updated deploy_stack to use this function in finally blocks so that it doesn't prevent destroy_environment from running.
- 903. By Curtis Hovey
-
Do not build i386 packages when BUILD_i386 is not "true".
- 904. By Curtis Hovey
-
Fix syntax error.
- 905. By Curtis Hovey
-
Simple build and test script for merge gating go projects using git.
- 906. By Curtis Hovey
-
Allow passing of all the filters get_ami uses, and change defaults fo virt and root_store.
- 907. By Aaron Bentley
-
Pass extra args to deploy_job.
- 908. By John George
-
Added the add_basic_
testing_ arguments function for setting up arguments needed for quickstart, deployer and charmstore tests. - 909. By Seman
-
Updated deploy_stack() to retain jenv file after a failure.
- 910. By Martin Packman
-
Improvements to the git_gate script in log output and arg handling
- 911. By John George
-
Re-write quickstart_
deploy. py to use EnvJujuClient. - 912. By Curtis Hovey
-
Added vivid-slave-
b.vapour. ws to the update script. - 913. By Curtis Hovey
-
Added a script to run unit-tests for ecosystem projects that import juju.
- 914. By Martin Packman
-
Fix broken tests for git gate script
- 915. By John George
-
Add a test script to deploy from the charm store stagging server.
- 916. By John George
-
Re-raise exceptions encountered while running quickstart_deploy steps and ensure the script exits with non-zero on errors.
- 917. By Curtis Hovey
-
Fix calls to service.
service_ name attribute. - 918. By Curtis Hovey
-
Added script to delete old s3 control-buckets.
- 919. By Curtis Hovey
-
Remove redundant workspace setup and hardcoded token.
- 920. By Martin Packman
-
Add lxc container logs to collected artifacts
- 921. By Martin Packman
-
Add region as a parameter to get_ami script
- 922. By Curtis Hovey
-
Use the local goroot if it is present.
- 923. By Martin Packman
-
Add wrapping at 79 character width to GroupReporter
- 924. By Martin Packman
-
Set TMP during unit tests on windows to mitigate cleanup issues
- 925. By Martin Packman
-
Update gotestwin.bash to not depend on lastSuccessfulBuild
- 926. By Curtis Hovey
-
Spec the mocks with the azure classes.
- 927. By Aaron Bentley
-
Add --keep-env flag to deploy_job.
- 928. By Aaron Bentley
-
Add --upload-tools to deploy_job.py
- 929. By Martin Packman
-
Further improvements to robustness of running unit tests on windows
- 930. By Martin Packman
-
More poking on the gotesttarball.py script
- 931. By Martin Packman
-
Correct wrapping of dots on groups displayed after the first
- 932. By Aaron Bentley
-
Auto-enable support for cloudsigma in 1.24.
- 933. By Martin Packman
-
Retest relations work after upgrade in deploy_stack
- 934. By Curtis Hovey
-
Bidirectional testing of ecosystem projects.
- 935. By Curtis Hovey
-
Use the command name, not an aliases (fixes broken job).
- 936. By Curtis Hovey
-
Copy stats after copying buildvars.
- 937. By Seman
-
Added code to upload the test results of Heterogeneous Control to S3.
- 938. By Aaron Bentley
-
Remove DeployManyFactory.
- 939. By Aaron Bentley
-
Fix bug #1449123 by passing juju_home.
- 940. By Curtis Hovey
-
Open critical "blocker" bugs prevent merges.
- 941. By Curtis Hovey
-
Close blocking bugs for a branch/series that passed in CI.
- 942. By Martin Packman
-
Prevent joyent failures from mixing kvm images with non-kvm packages
- 943. By Martin Packman
-
Make check_blockers.py nicer for human use
- 944. By Martin Packman
-
Tweak how jujupy wait reporting finalises
- 945. By Curtis Hovey
-
Capture logs from deployer tests.
- 946. By Curtis Hovey
-
Add support for --agent-stream to deploy_job.py.
- 947. By Curtis Hovey
-
Ensure the os gest package updates to find the current package.
- 948. By Curtis Hovey
-
Use the ubuntu archives in the test.
- 949. By Curtis Hovey
-
Soft-code $PACKAGES_JOB for certification.
- 950. By Curtis Hovey
-
Ubuntu changed the naming convention again :(.
- 951. By Curtis Hovey
-
Certify any Ubuntu version.
- 952. By Martin Packman
-
Correct deploy job juju run logging
- 953. By Curtis Hovey
-
Remove extra ")" causing a syntax error and make test failure.
- 954. By Curtis Hovey
-
Set default juju to 1.20.11 whenthe juju under test in 1.21.x or 1.22.x.
- 955. By John George
-
Support taking a bundle name in addition to the bundle config file path.
- 956. By Curtis Hovey
-
Also ABRT mongod runing from /usr/lib/juju/bin/.
- 957. By Curtis Hovey
-
Added get-build-vars command to jujuci.py.
- 958. By Curtis Hovey
-
Use get-build-vars instead of sourcing buildvard.bash.
- 959. By Curtis Hovey
-
Added manage-
build-revision. bash extracted from revision-result job. - 960. By Curtis Hovey
-
Use lowercase name for $revision_build.
- 961. By Aaron Bentley
-
Treat cloudsigma as provisional in juju 2.5
- 962. By Curtis Hovey
-
Add support to build centos7.
- 963. By Martin Packman
-
Add --race flag to run-unit-test script
- 964. By Curtis Hovey
-
Include centos and win agents in test streams.
- 965. By Curtis Hovey
-
Fixed comment.
- 966. By John George
-
Add run_chaos_monkey.py
- 967. By Curtis Hovey
-
Remove common-startup.sh.
- 968. By John George
-
Add sub-command support to jujupy, as well as including subordinate items from Status.
agent_items( ). - 969. By Curtis Hovey
-
Set JUJU in the env when testing quickstart,
- 970. By Curtis Hovey
-
Print the boot staus before starting deployer.
- 971. By Curtis Hovey
-
client.
wait_for_ started( ) before running deployer. - 972. By Curtis Hovey
-
Added script to manage the lxc cache for hosts on closed networks.
- 973. By Curtis Hovey
-
Get juju binaries from build-binary-* jobs.
- 974. By John George
-
Add wait_for_
subordinate_ units to jujupy.py. - 975. By Martin Packman
-
Use more specific name for per-machine artifacts directories
- 976. By Aaron Bentley
-
Implement tests for log rotation, using action do and action fetch.
- 977. By Curtis Hovey
-
Use jujuci to get build and job data because it works on all OSes and series.
- 978. By Curtis Hovey
-
Adjust test env so tht make test can pass on the osx-slave.
- 979. By John George
-
Add start action calls to run_chaos_monkey.
- 980. By John George
-
Adds the is_healthy() function to run_chaos_monkey.py for executing the health check script provided by the user.
- 981. By Curtis Hovey
-
Hush lint and make tests work on other series and OSes.
- 982. By Martin Packman
-
Destroy lxc containers before attempting to create them in run-unit-tests script
- 983. By Curtis Hovey
-
Move substrate (not juju) functions to substrate.py.
- 984. By Martin Packman
-
New Remote class for communicating with juju machines
- 985. By Martin Packman
-
Fix test broken by misadventures in lint
- 986. By Aaron Bentley
-
Fix error handling in assess_
log_rotation. - 987. By John George
-
Run chaos, wait for completion and check health.
- 988. By Curtis Hovey
-
Added MAASAccount to work directly with the MAAS substrate.
- 989. By Curtis Hovey
-
Update get_machines_
for_log to get real maas ip addresses. - 990. By Curtis Hovey
-
Fix dump_env_logs calls passing obsolete keyword.
- 991. By Curtis Hovey
-
Always collect logs.
- 992. By John George
-
Modify run_chaos_monkey.py to use the first action ID, for a unit, as the monkey-id for all subsequent action calls.
- 993. By John George
-
Prevent subsequent unleash_once calls from overwriting the stored ID for a unit.
- 994. By John George
-
Give deploy_stack extra time to complete on MAAS.
- 995. By Curtis Hovey
-
Ensure name is defined in the juju config for maas.
- 996. By Seman
-
Upload last completed compatibility test result.
- 997. By Curtis Hovey
-
Fix test-win-client exit code, script path, and deps.
- 998. By Curtis Hovey
-
Add support for Wily.
- 999. By Seman
-
Ensure Jenkins build is completed before uploading the compatibility test result by a build number.
- 1000. By Aaron Bentley
-
Use verbose output for run-juju-
eco-unit- tests. - 1001. By Aaron Bentley
-
Use workspace-runner for test-win-client.
- 1002. By John George
-
Add a script to run basic openstack commands as a sniff test.
- 1003. By Martin Packman
-
Use trusty state server when testing windows charms
- 1004. By Curtis Hovey
-
Add --robust to select an ideal test combination.
- 1005. By Martin Packman
-
Add pipdep tool for managing requirements using an S3 cache
- 1006. By Martin Packman
-
Add python-pip to make install-deps
- 1007. By Martin Packman
-
Support precise pip by using file: url for directory
- 1008. By Martin Packman
-
Add winrm remote class to enable interacting with windows machines
- 1009. By Martin Packman
-
Enable windows deployment testing and log collection
- 1010. By Curtis Hovey
-
Remove callto kill long running joyent procs.
- 1011. By Curtis Hovey
-
Retry wekkly stream publication.
- 1012. By Martin Packman
-
Update gzip hang fix for trunk, and address review comment by abentley
Martin Packman (gz) wrote : | # |
Fixed Aaron's concern with the tests, so will just land.
- 1013. By Martin Packman
-
Fix lint
Preview Diff
1 | === modified file 'deploy_stack.py' |
2 | --- deploy_stack.py 2015-07-02 00:59:47 +0000 |
3 | +++ deploy_stack.py 2015-07-03 18:46:32 +0000 |
4 | @@ -35,7 +35,6 @@ |
5 | from substrate import ( |
6 | destroy_job_instances, |
7 | LIBVIRT_DOMAIN_RUNNING, |
8 | - MAASAccount, |
9 | resolve_remote_dns_names, |
10 | run_instances, |
11 | start_libvirt_domain, |
12 | @@ -216,12 +215,12 @@ |
13 | copy_local_logs(env, directory) |
14 | else: |
15 | copy_remote_logs(remote, directory) |
16 | - subprocess.check_call( |
17 | - ['gzip', '-f'] + |
18 | - glob.glob(os.path.join(directory, '*.log'))) |
19 | except Exception as e: |
20 | print_now("Failed to retrieve logs") |
21 | print_now(str(e)) |
22 | + log_files = glob.glob(os.path.join(directory, '*.log')) |
23 | + if log_files: |
24 | + subprocess.check_call(['gzip', '-f'] + log_files) |
25 | |
26 | |
27 | lxc_template_glob = '/var/lib/juju/containers/juju-*-lxc-template/*.log' |
28 | |
29 | === modified file 'test_assess_heterogeneous_control.py' |
30 | --- test_assess_heterogeneous_control.py 2015-06-22 00:14:18 +0000 |
31 | +++ test_assess_heterogeneous_control.py 2015-07-03 18:46:32 +0000 |
32 | @@ -16,31 +16,41 @@ |
33 | SimpleEnvironment, |
34 | _temp_env, |
35 | ) |
36 | +from utility import ( |
37 | + temp_dir, |
38 | +) |
39 | |
40 | |
41 | class TestDumping_env(TestCase): |
42 | |
43 | def test_dumping_env_exception(self): |
44 | client = EnvJujuClient(SimpleEnvironment('env'), '5', '4') |
45 | - with patch.object(client, 'destroy_environment') as de_mock: |
46 | - with patch('subprocess.check_call') as cc_mock: |
47 | - with patch('deploy_stack.copy_remote_logs') as crl_mock: |
48 | - with self.assertRaises(ValueError): |
49 | - with dumping_env(client, 'foo', 'bar'): |
50 | - raise ValueError |
51 | - crl_mock.assert_called_once_with('foo', 'bar') |
52 | - cc_mock.assert_called_once_with(['gzip', '-f']) |
53 | + with temp_dir() as log_dir: |
54 | + with patch.object(client, 'destroy_environment') as de_mock: |
55 | + with patch('subprocess.check_call', autospec=True) as cc_mock: |
56 | + with patch('deploy_stack.copy_remote_logs') as crl_mock: |
57 | + with self.assertRaises(ValueError): |
58 | + with dumping_env(client, 'a-hostname', log_dir): |
59 | + raise ValueError |
60 | + crl_mock.assert_called_once_with('a-hostname', log_dir) |
61 | + self.assertEquals(cc_mock.call_count, 0) |
62 | de_mock.assert_called_once_with() |
63 | |
64 | def test_dumping_env_success(self): |
65 | + def _fake_remote_logs(remote, directory): |
66 | + with open(os.path.join(directory, 'fake.log'), 'w') as f: |
67 | + f.write('log contents') |
68 | client = EnvJujuClient(SimpleEnvironment('env'), '5', '4') |
69 | - with patch.object(client, 'destroy_environment') as de_mock: |
70 | - with patch('subprocess.check_call') as cc_mock: |
71 | - with patch('deploy_stack.copy_remote_logs') as crl_mock: |
72 | - with dumping_env(client, 'foo', 'bar'): |
73 | - pass |
74 | - crl_mock.assert_called_once_with('foo', 'bar') |
75 | - cc_mock.assert_called_once_with(['gzip', '-f']) |
76 | + with temp_dir() as log_dir: |
77 | + with patch.object(client, 'destroy_environment') as de_mock: |
78 | + with patch('subprocess.check_call', autospec=True) as cc_mock: |
79 | + with patch('deploy_stack.copy_remote_logs', autospec=True, |
80 | + side_effect=_fake_remote_logs) as crl_mock: |
81 | + with dumping_env(client, 'a-hostname', log_dir): |
82 | + pass |
83 | + crl_mock.assert_called_once_with('a-hostname', log_dir) |
84 | + log_path = os.path.join(log_dir, 'fake.log') |
85 | + cc_mock.assert_called_once_with(['gzip', '-f', log_path]) |
86 | self.assertEqual(de_mock.call_count, 0) |
87 | |
88 |
The code looks fine, but I think the tests should create log files if necessary. We want to assert that gzip -f gets run. And we want a test case for dump_logs, asserting that it doesn't run gzip if there are no logs. Yes, there are no tests for deploy_stack, but I think that needs to change. I've been adding tests for other testless functionality when I change it.