sge 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +22 -0
- data/Guardfile +17 -0
- data/README.markdown +22 -0
- data/lib/sge.rb +4 -4
- data/lib/sge/qacct.rb +2 -0
- data/lib/sge/qacct/job.rb +54 -0
- data/lib/sge/qacct/transformer.rb +31 -0
- data/lib/sge/qstat.rb +2 -0
- data/lib/sge/utils.rb +12 -0
- data/lib/sge/version.rb +1 -1
- data/spec/data/qacct.sge +1592 -0
- data/spec/data/qacct.yml +1592 -0
- data/spec/qacct/job_spec.rb +53 -0
- data/spec/qacct/transformer_spec.rb +47 -0
- data/spec/{qstat_job_spec.rb → qstat/job_spec.rb} +1 -1
- data/spec/{qstat_parser_spec.rb → qstat/parser_spec.rb} +0 -0
- data/spec/utils_spec.rb +17 -0
- data/utils/transform_to_yaml.sh +3 -0
- metadata +33 -18
- data/lib/sge/job.rb +0 -18
- data/spec/job_spec.rb +0 -53
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SGE::QAcct::Job do
|
4
|
+
let(:klass){ SGE::QAcct::Job }
|
5
|
+
context "Class Methods" do
|
6
|
+
subject{klass}
|
7
|
+
|
8
|
+
it { should respond_to(:command) }
|
9
|
+
it { should respond_to(:load_documents) }
|
10
|
+
|
11
|
+
it "should accept a command" do
|
12
|
+
klass.command(:cmd => "ls -l").should == "ls -l"
|
13
|
+
end
|
14
|
+
|
15
|
+
context "loading documents" do
|
16
|
+
let(:file){ File.expand_path('../../data/qacct.sge',__FILE__)}
|
17
|
+
|
18
|
+
it "should load documents" do
|
19
|
+
docs = klass.load_documents(:cmd => "cat #{file}", :remove_tmp_file => true)
|
20
|
+
docs.should_not be_empty
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should receive a block" do
|
24
|
+
doc = nil
|
25
|
+
klass.load_documents(:cmd => "cat #{file}", :remove_tmp_file => true) do |d|
|
26
|
+
doc = d
|
27
|
+
break
|
28
|
+
end
|
29
|
+
doc.should be_an_instance_of(klass)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should execute" do
|
34
|
+
Kernel.should_receive("system").once.with("ls").and_return "A list of files"
|
35
|
+
klass.execute('ls').should == "A list of files"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context "FIELDS" do
|
40
|
+
it "should define constant FIELD" do
|
41
|
+
SGE::QAcct::Job.should be_const_defined(:FIELDS)
|
42
|
+
SGE::QAcct::Job::FIELDS.should == [:qname, :hostname, :group, :owner, :project, :department, :jobname, :jobnumber, :taskid, :account, :priority, :qsub_time, :start_time, :end_time, :granted_pe, :slots, :failed, :exit_status, :ru_wallclock, :ru_utime, :ru_stime, :ru_maxrss, :ru_ixrss, :ru_ismrss, :ru_idrss, :ru_isrss, :ru_minflt, :ru_majflt, :ru_nswap, :ru_inblock, :ru_oublock, :ru_msgsnd, :ru_msgrcv, :ru_nsignals, :ru_nvcsw, :ru_nivcsw, :cpu, :mem, :io, :iow, :maxvmem, :arid]
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should define accessor for each fields" do
|
46
|
+
klass::FIELDS.each do |f|
|
47
|
+
subject.should respond_to(f)
|
48
|
+
subject.should respond_to("#{f}=")
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SGE::QAcct::Transformer do
|
4
|
+
it { should respond_to(:transformer_file)}
|
5
|
+
it { should respond_to(:command)}
|
6
|
+
it { should respond_to(:load_from_yaml_file)}
|
7
|
+
|
8
|
+
let (:sh_file){ subject.transformer_file}
|
9
|
+
|
10
|
+
context "#transformer_file" do
|
11
|
+
it "should point to the utility file" do
|
12
|
+
sh_file.should == File.expand_path('../../../utils/transform_to_yaml.sh', __FILE__)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
context "#command" do
|
17
|
+
it "should accept :file options" do
|
18
|
+
lambda{ subject.command}.should raise_error("We need a file to dump the yaml")
|
19
|
+
subject.command(:file => "hello.world").should == "echo | #{sh_file} > hello.world &"
|
20
|
+
subject.command(:file => "hello.world", :blocking => true).should == "echo | #{sh_file} > hello.world"
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should accept :cmd options" do
|
24
|
+
subject.command(:cmd => "echo 'Hello World!'", :file => "hello.world").should == "echo 'Hello World!' | #{sh_file} > hello.world &"
|
25
|
+
subject.command(:cmd => "echo 'Hello World!'", :file => "hello.world", :blocking => true).should == "echo 'Hello World!' | #{sh_file} > hello.world"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
context "#load_from_yaml_file" do
|
30
|
+
let(:file){ File.expand_path('../../data/qacct.yml',__FILE__)}
|
31
|
+
|
32
|
+
it "should accept a block" do
|
33
|
+
lambda{ subject.load_from_yaml_file(file, false) }.should raise_error
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should reads docs" do
|
37
|
+
documents = []
|
38
|
+
documents.should be_empty
|
39
|
+
subject.load_from_yaml_file(file, false) do |doc|
|
40
|
+
documents << doc
|
41
|
+
end
|
42
|
+
documents.should_not be_empty
|
43
|
+
documents.should be_all {|d| SGE::QAcct::Job === d }
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
File without changes
|
data/spec/utils_spec.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SGE::Utils do
|
4
|
+
it { should respond_to(:mkfifo)}
|
5
|
+
|
6
|
+
describe "#mkfifo" do
|
7
|
+
it "should make a fifo file" do
|
8
|
+
lambda{ SGE::Utils.mkfifo }.should raise_error
|
9
|
+
tmp_dir = "."
|
10
|
+
file = SGE::Utils.mkfifo(tmp_dir)
|
11
|
+
file.should =~ %r<^\.\/fifo\.....>
|
12
|
+
File.stat(file).should be_pipe
|
13
|
+
File.unlink file
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-27 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement: &
|
16
|
+
requirement: &70281742743320 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70281742743320
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70281742742520 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70281742742520
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rake
|
38
|
-
requirement: &
|
38
|
+
requirement: &70281742741680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70281742741680
|
47
47
|
description: Sun Grid Engine ruby library
|
48
48
|
email:
|
49
49
|
- hery@rails-royce.org
|
@@ -54,23 +54,34 @@ files:
|
|
54
54
|
- .gitignore
|
55
55
|
- .rspec
|
56
56
|
- Gemfile
|
57
|
+
- Guardfile
|
58
|
+
- README.markdown
|
57
59
|
- Rakefile
|
58
60
|
- lib/sge.rb
|
59
61
|
- lib/sge/command_runner.rb
|
60
|
-
- lib/sge/job.rb
|
61
62
|
- lib/sge/job_helpers.rb
|
63
|
+
- lib/sge/qacct.rb
|
64
|
+
- lib/sge/qacct/job.rb
|
65
|
+
- lib/sge/qacct/transformer.rb
|
66
|
+
- lib/sge/qstat.rb
|
62
67
|
- lib/sge/qstat/job.rb
|
63
68
|
- lib/sge/qstat/parser.rb
|
64
69
|
- lib/sge/summary.rb
|
70
|
+
- lib/sge/utils.rb
|
65
71
|
- lib/sge/version.rb
|
66
72
|
- sge.gemspec
|
67
73
|
- spec/command_runner_spec.rb
|
68
74
|
- spec/data/detailed_jobs.sge
|
69
75
|
- spec/data/jobs.sge
|
70
|
-
- spec/
|
71
|
-
- spec/
|
72
|
-
- spec/
|
76
|
+
- spec/data/qacct.sge
|
77
|
+
- spec/data/qacct.yml
|
78
|
+
- spec/qacct/job_spec.rb
|
79
|
+
- spec/qacct/transformer_spec.rb
|
80
|
+
- spec/qstat/job_spec.rb
|
81
|
+
- spec/qstat/parser_spec.rb
|
73
82
|
- spec/spec_helper.rb
|
83
|
+
- spec/utils_spec.rb
|
84
|
+
- utils/transform_to_yaml.sh
|
74
85
|
homepage: ''
|
75
86
|
licenses: []
|
76
87
|
post_install_message:
|
@@ -85,7 +96,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
85
96
|
version: '0'
|
86
97
|
segments:
|
87
98
|
- 0
|
88
|
-
hash: -
|
99
|
+
hash: -946621893360154507
|
89
100
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
101
|
none: false
|
91
102
|
requirements:
|
@@ -94,10 +105,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
105
|
version: '0'
|
95
106
|
segments:
|
96
107
|
- 0
|
97
|
-
hash: -
|
108
|
+
hash: -946621893360154507
|
98
109
|
requirements: []
|
99
110
|
rubyforge_project: sge
|
100
|
-
rubygems_version: 1.8.
|
111
|
+
rubygems_version: 1.8.10
|
101
112
|
signing_key:
|
102
113
|
specification_version: 3
|
103
114
|
summary: Sun Grid Engine ruby library
|
@@ -105,7 +116,11 @@ test_files:
|
|
105
116
|
- spec/command_runner_spec.rb
|
106
117
|
- spec/data/detailed_jobs.sge
|
107
118
|
- spec/data/jobs.sge
|
108
|
-
- spec/
|
109
|
-
- spec/
|
110
|
-
- spec/
|
119
|
+
- spec/data/qacct.sge
|
120
|
+
- spec/data/qacct.yml
|
121
|
+
- spec/qacct/job_spec.rb
|
122
|
+
- spec/qacct/transformer_spec.rb
|
123
|
+
- spec/qstat/job_spec.rb
|
124
|
+
- spec/qstat/parser_spec.rb
|
111
125
|
- spec/spec_helper.rb
|
126
|
+
- spec/utils_spec.rb
|
data/lib/sge/job.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
module SGE
|
2
|
-
class Job
|
3
|
-
include SGE::JobHelpers
|
4
|
-
define_attributes(
|
5
|
-
:JB_job_number => :job_number,
|
6
|
-
:JAT_prio => :priority,
|
7
|
-
:JB_name => :name,
|
8
|
-
:JB_owner => :owner,
|
9
|
-
:JAT_start_time => :start_time,
|
10
|
-
:queue_name => :queue_name,
|
11
|
-
:slots => :slots,
|
12
|
-
:state => :state,
|
13
|
-
:cpu => :cpu,
|
14
|
-
:JB_submission_time => :submission_time
|
15
|
-
)
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
data/spec/job_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe SGE::Job do
|
4
|
-
it "should respond_to define_attributes" do
|
5
|
-
SGE::Job.should respond_to(:define_attributes)
|
6
|
-
end
|
7
|
-
|
8
|
-
it { should respond_to(:job_number) }
|
9
|
-
it { should respond_to(:priority) }
|
10
|
-
it { should respond_to(:name) }
|
11
|
-
it { should respond_to(:queue_name) }
|
12
|
-
it { should respond_to(:start_time) }
|
13
|
-
it { should respond_to(:slots) }
|
14
|
-
it { should respond_to(:state) }
|
15
|
-
it { should respond_to(:owner) }
|
16
|
-
|
17
|
-
it { should respond_to(:job_number=) }
|
18
|
-
it { should respond_to(:priority=) }
|
19
|
-
it { should respond_to(:name=) }
|
20
|
-
it { should respond_to(:queue_name=) }
|
21
|
-
it { should respond_to(:start_time=) }
|
22
|
-
it { should respond_to(:slots=) }
|
23
|
-
it { should respond_to(:state=) }
|
24
|
-
it { should respond_to(:owner=) }
|
25
|
-
|
26
|
-
it "should retrieve data from XML document" do
|
27
|
-
string = %Q{
|
28
|
-
<job_list state="running">
|
29
|
-
<JB_job_number>2337</JB_job_number>
|
30
|
-
<JAT_prio>0.55451</JAT_prio>
|
31
|
-
<JB_name>s20100220_11;init_jour</JB_name>
|
32
|
-
<JB_owner>prodsoft</JB_owner>
|
33
|
-
<state>r</state>
|
34
|
-
<JAT_start_time>2010-02-24T21:55:13</JAT_start_time>
|
35
|
-
<queue_name>calcul-x@wousdat-dev.in.weborama.fr</queue_name>
|
36
|
-
<slots>1</slots>
|
37
|
-
</job_list>
|
38
|
-
}
|
39
|
-
doc = Nokogiri::XML::Document.new.parse(string)
|
40
|
-
lambda{ @job = SGE::Job.from_document(doc) }.should_not raise_error
|
41
|
-
@job.job_number.should == '2337'
|
42
|
-
@job.priority.should == '0.55451'
|
43
|
-
@job.name.should == 's20100220_11;init_jour'
|
44
|
-
@job.owner.should == 'prodsoft'
|
45
|
-
@job.state.should == 'r'
|
46
|
-
@job.start_time.should == '2010-02-24T21:55:13'
|
47
|
-
@job.queue_name.should == 'calcul-x@wousdat-dev.in.weborama.fr'
|
48
|
-
@job.slots.should == '1'
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
52
|
-
|
53
|
-
|