ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/FILEMOVER/test/file_manager.py
Revision: 1.1
Committed: Tue Jan 6 14:32:43 2009 UTC (16 years, 3 months ago) by bbockelm
Content type: text/x-python
Branch: MAIN
CVS Tags: V01_00_33, V01_00_32, V01_00_31, V01_00_30, V01_00_29, V01_00_28, V01_00_27, V01_00_26, V01_00_25, V01_00_24, V01_00_23, V01_00_22, V01_00_21, V01_00_20, V01_00_19, V01_00_18, V01_00_17, V01_00_16, V01_00_15, V01_00_14, V01_00_13, V01_00_12, HEAD
Log Message:
Further improvements in the CmsFs features.  Ran the whole suite through pylint for bug cleanup.

Added an activity monitor so we can eventually produce a "status" page.

Moved PickEvent logic from the web service to the CMSRunManager.

Minor updates to the EdmFile*; not sure if we'll be using these files (as the CMSRunManager already implements these features).

File Contents

# User Rev Content
1 bbockelm 1.1 #!/usr/bin/env python
2     #-*- coding: ISO-8859-1 -*-
3     #
4     # Author: Brian Bockelman
5    
6     import os
7     import sys
8     import time
9     import unittest
10     import ConfigParser
11    
12     if os.path.exists("src"):
13     sys.path.append("src")
14     if os.path.exists('../src'):
15     sys.path.append('../src')
16    
17     from CmsFileServer.FileManager import Server
18    
19     class TestFileManager(unittest.TestCase):
20    
21     def setUp(self):
22     cp = ConfigParser.ConfigParser()
23     cp.add_section("file_manager")
24     cp.set("file_manager", "base_directory", "/Users/brian/tmp/cms_stuff")
25     cp.add_section("transfer_wrapper")
26     cp.set("transfer_wrapper", "transfer_command", "srmcp -debug=true " \
27     "-srm_protocol_version=2 -retry_num=1 -streams_num=1")
28     self.cp = cp
29    
30     def test_main(self):
31     # Test case demonstrates:
32     # - Single transfer works
33     # - Second transfer starts up in parallel
34     # - Third transfer notices that it's for the same LFN as the first, and it
35     # just sits waiting for the first one to finish.
36     # - Cancelling works
37     # - Graceful shutdown works
38     cp = self.cp
39     Server.configure(cp)
40     Server.request("/store/data/CRUZET2/Cosmics/RECO/CRUZET2_V1_v2/0018/FEB27E49-B63C-DD11-89D8-000423D6B42C.root")
41     time.sleep(10)
42     Server.request("/store/data/CRUZET2/Cosmics/RECO/CRUZET2_V1_v2/0018/FEB27E49-B63C-DD11-89D8-000423D6B42C.root")
43     Server.request("/store/data/CRUZET2/Cosmics/RECO/CRUZET2_V1_v2/0018/FE989CBF-913C-DD11-BEE5-001617E30CE8.root")
44     time.sleep(5)
45     print "****", Server.status("/store/data/CRUZET2/Cosmics/RECO/CRUZET2_V1_v2/0018/FE989CBF-913C-DD11-BEE5-001617E30CE8.root")
46     print "****", Server.status("/store/data/CRUZET2/Cosmics/RECO/CRUZET2_V1_v2/0018/FEB27E49-B63C-DD11-89D8-000423D6B42C.root")
47     time.sleep(30)
48     Server.cancel("/store/data/CRUZET2/Cosmics/RECO/CRUZET2_V1_v2/0018/FE989CBF-913C-DD11-BEE5-001617E30CE8.root")
49     # Note that the thread pool is all daemon - if the main thread exits, the
50     # python process terminates, even if the thread pool is running. Hence, we
51     # use the graceful_exit function
52     Server.graceful_exit()
53    
54     # At this point, you can hit Ctrl+C, and the partial file will clean up
55     # and the transfer will kill itself.
56    
57     # Let this run successfully once, and notice that if you run it again,
58     # the file was cached locally and the request returns successfully
59     # instantly.
60    
61     if __name__ == '__main__':
62     unittest.main()
63