osc-machete 2.0.0.pre2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/publish.yml +43 -0
- data/CHANGELOG.md +65 -1
- data/lib/osc/machete/job.rb +1 -1
- data/lib/osc/machete/process.rb +3 -0
- data/lib/osc/machete/status.rb +50 -29
- data/lib/osc/machete/torque_helper.rb +34 -36
- data/lib/osc/machete/user.rb +3 -0
- data/lib/osc/machete/version.rb +1 -1
- data/osc-machete.gemspec +2 -2
- data/test/fixtures/quick.sh +1 -1
- data/test/test_job_dir.rb +1 -1
- data/test/test_location.rb +19 -19
- data/test/test_torque_helper.rb +49 -4
- data/test/test_torque_helper_live.rb +6 -6
- metadata +10 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e83b320b7f61439e04b289507d2731cebf2bb46209b90deafebb83319cdeb81c
|
4
|
+
data.tar.gz: 93f38ebb3a88edb94ee029bba3827408b4b48a54874ceda731e36d49be724acc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6ec3ae443f7deed3d0d99d1bc69b9d6ed4842181af11ecdbb6d15f85d3dad4bd5a553c51683f36728f9fe12ca11bcd6fd8f7e595e729d1fac0b6e43f4c3e267d
|
7
|
+
data.tar.gz: 2e3dd9f7fe061ee7e8052b792e10240582840dae8bf2d8f72235327b7d84cd17b7d0722eca1efc9870587cd0a0a267374e03169526e71eb7f20d68a46df87d7b
|
@@ -0,0 +1,43 @@
|
|
1
|
+
name: Publish Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- "*"
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
publish:
|
10
|
+
runs-on: ubuntu-latest
|
11
|
+
|
12
|
+
steps:
|
13
|
+
- name: Set version
|
14
|
+
id: version
|
15
|
+
run: echo ::set-output name=version::${GITHUB_REF#refs/*/v}
|
16
|
+
|
17
|
+
- name: checkout
|
18
|
+
uses: actions/checkout@v2
|
19
|
+
|
20
|
+
- name: Setup Ruby using Bundler
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: "2.7.1"
|
24
|
+
bundler-cache: true
|
25
|
+
bundler: "2.1.4"
|
26
|
+
|
27
|
+
- name: install gems
|
28
|
+
run: bundle install
|
29
|
+
|
30
|
+
- name: Setup Rubygems credentials
|
31
|
+
run: |
|
32
|
+
set +x
|
33
|
+
mkdir -p ~/.gem
|
34
|
+
cat << EOF > ~/.gem/credentials
|
35
|
+
---
|
36
|
+
:rubygems_api_key: ${{ secrets.OSC_ROBOT_RUBYGEMS_TOKEN }}
|
37
|
+
EOF
|
38
|
+
chmod 0600 ~/.gem/credentials
|
39
|
+
|
40
|
+
- name: Publish Gem
|
41
|
+
run: |
|
42
|
+
bundle exec rake build
|
43
|
+
gem push pkg/osc-machete-${{ steps.version.outputs.version }}.gem
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,64 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
7
|
|
8
|
+
## [1.2.2] - 2017-08-04
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- host name for Ruby Cluster changed
|
13
|
+
|
14
|
+
## [1.2.1] - 2016-12-16
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
|
18
|
+
- host name for Quick Cluster changed
|
19
|
+
|
20
|
+
## [1.2.0] - 2016-09-06
|
21
|
+
|
22
|
+
### Added
|
23
|
+
|
24
|
+
- TorqueHelper.default= so we can specify a different TorqueHelper
|
25
|
+
- TorqueHelper#pbs to get the PBS::Batch object for the given id, script, or host.
|
26
|
+
This lets us change the TorqueHelper instance used as a default with a
|
27
|
+
different TorqueHelper class or instance that has a different implementation
|
28
|
+
of TorqueHelper#pbs.
|
29
|
+
- (OSC specific) Owens cluster support
|
30
|
+
- (OSC specific) LIB and BIN for specifying torque lib locations
|
31
|
+
|
32
|
+
### Changed
|
33
|
+
|
34
|
+
- Depends on latest version of pbs ruby gem 2.0
|
35
|
+
- TorqueHelper.default returns the same instance every time (which is now
|
36
|
+
memoized) instead of creating a new instance
|
37
|
+
|
38
|
+
### Deprecated
|
39
|
+
|
40
|
+
- `OSC::Machete::User` - use `OodSupport::User` instead
|
41
|
+
- `OSC::Machete::Process` - use `OodSupport::Process` instead
|
42
|
+
|
43
|
+
### Fixed
|
44
|
+
|
45
|
+
- yardoc documentation for OSC::Machete::Status class methods
|
46
|
+
- deprecation warnings by using File.exist? instead of File.exists?
|
47
|
+
|
48
|
+
## [1.1.4] - 2016-08-17
|
49
|
+
|
50
|
+
### Added
|
51
|
+
|
52
|
+
- `Job#host` getter (which should have been there but was accidentally omitted)
|
53
|
+
|
54
|
+
## [1.1.3] - 2016-06-07
|
55
|
+
|
56
|
+
### Fixed
|
57
|
+
|
58
|
+
- README and gemspec docs update for rubygems.org release
|
59
|
+
|
60
|
+
## [1.1.2] - 2016-06-07
|
61
|
+
|
62
|
+
### Fixed
|
63
|
+
|
64
|
+
- Copyright in LICENSE.txt
|
65
|
+
|
8
66
|
## [1.1.1] - 2016-02-24
|
9
67
|
|
10
68
|
### Fixed
|
@@ -79,7 +137,13 @@ lib/osc/machete/torque_helper.rb _(still an internal class right now, not meant
|
|
79
137
|
|
80
138
|
Previous release of osc-machete
|
81
139
|
|
82
|
-
[Unreleased]: https://github.com/AweSim-OSC/osc-machete/compare/v1.
|
140
|
+
[Unreleased]: https://github.com/AweSim-OSC/osc-machete/compare/v1.2.2...master
|
141
|
+
[1.2.2]: https://github.com/AweSim-OSC/osc-machete/compare/v1.2.1...v1.2.2
|
142
|
+
[1.2.1]: https://github.com/AweSim-OSC/osc-machete/compare/v1.2.0...v1.2.1
|
143
|
+
[1.2.0]: https://github.com/AweSim-OSC/osc-machete/compare/v1.1.4...v1.2.0
|
144
|
+
[1.1.4]: https://github.com/AweSim-OSC/osc-machete/compare/v1.1.3...v1.1.4
|
145
|
+
[1.1.3]: https://github.com/AweSim-OSC/osc-machete/compare/v1.1.2...v1.1.3
|
146
|
+
[1.1.2]: https://github.com/AweSim-OSC/osc-machete/compare/v1.1.1...v1.1.2
|
83
147
|
[1.1.1]: https://github.com/AweSim-OSC/osc-machete/compare/v1.1.0...v1.1.1
|
84
148
|
[1.1.0]: https://github.com/AweSim-OSC/osc-machete/compare/v1.0.1...v1.1.0
|
85
149
|
[1.0.1]: https://github.com/AweSim-OSC/osc-machete/compare/v1.0.0...v1.0.1
|
data/lib/osc/machete/job.rb
CHANGED
@@ -205,7 +205,7 @@ class OSC::Machete::Job
|
|
205
205
|
# something if the script name is munged
|
206
206
|
|
207
207
|
# recursively delete the directory after killing the job
|
208
|
-
Pathname.new(path).rmtree if path && rmdir && File.
|
208
|
+
Pathname.new(path).rmtree if path && rmdir && File.exist?(path)
|
209
209
|
end
|
210
210
|
end
|
211
211
|
|
data/lib/osc/machete/process.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# Class that maintains the User and additional methods for the process.
|
2
2
|
# Helper methods provided use the Process module underneath.
|
3
3
|
#
|
4
|
+
# @deprecated Please use {http://www.rubydoc.info/gems/ood_support/OodSupport/Process OodSupport::Process} instead.
|
4
5
|
class OSC::Machete::Process
|
5
6
|
|
6
7
|
def initialize
|
7
8
|
@user = OSC::Machete::User.from_uid(Process.uid)
|
9
|
+
|
10
|
+
warn "[DEPRECATION] `OSC::Machete::Process` is deprecated. Please use `OodSupport::Process` instead (see ood_support gem)."
|
8
11
|
end
|
9
12
|
|
10
13
|
# The system name of the process user
|
data/lib/osc/machete/status.rb
CHANGED
@@ -55,27 +55,42 @@ class OSC::Machete::Status
|
|
55
55
|
end
|
56
56
|
|
57
57
|
|
58
|
-
#
|
59
|
-
#
|
60
|
-
|
61
|
-
#
|
62
|
-
|
63
|
-
#
|
64
|
-
|
65
|
-
#
|
66
|
-
|
67
|
-
#
|
68
|
-
|
69
|
-
# @return [Status]
|
70
|
-
def self.running() end
|
71
|
-
# @return [Status]
|
72
|
-
def self.queued() end
|
73
|
-
# @return [Status]
|
74
|
-
def self.held() end
|
75
|
-
# @return [Status]
|
76
|
-
def self.suspended() end
|
77
|
-
|
58
|
+
# NOTE: on yard documentation: to do something like what I do below,
|
59
|
+
# documenting a set of class methods, you must have the documentation block be
|
60
|
+
# inside the `class << self` block or else the last documented method will be
|
61
|
+
# ignored or hidden if newlines exist between each @!method block. If no
|
62
|
+
# newlines exist, like below, the entire block would have been ignored.
|
63
|
+
# Also, indenting the tags for the rest of the methods is required when
|
64
|
+
# omitting newlines, otherwise, each method includes all of the returns below
|
65
|
+
# it - so yard displays 6 return Status lines for the method.
|
66
|
+
#
|
67
|
+
# Why do we have no newlines here? So that "View source" on each of these
|
68
|
+
# class methods points to the block itself.
|
78
69
|
class << self
|
70
|
+
# @!method undetermined
|
71
|
+
# A 'null' special case for Status
|
72
|
+
# @return [Status]
|
73
|
+
#
|
74
|
+
# @!method not_submitted
|
75
|
+
# @return [Status]
|
76
|
+
#
|
77
|
+
# @!method passed
|
78
|
+
# @return [Status]
|
79
|
+
#
|
80
|
+
# @!method failed
|
81
|
+
# @return [Status]
|
82
|
+
#
|
83
|
+
# @!method running
|
84
|
+
# @return [Status]
|
85
|
+
#
|
86
|
+
# @!method queued
|
87
|
+
# @return [Status]
|
88
|
+
#
|
89
|
+
# @!method held
|
90
|
+
# @return [Status]
|
91
|
+
#
|
92
|
+
# @!method suspended
|
93
|
+
# @return [Status]
|
79
94
|
VALUES_HASH.each do |char, name|
|
80
95
|
define_method(name) do
|
81
96
|
OSC::Machete::Status.new(char)
|
@@ -84,22 +99,28 @@ class OSC::Machete::Status
|
|
84
99
|
end
|
85
100
|
|
86
101
|
# @!method undetermined?
|
87
|
-
#
|
88
|
-
|
102
|
+
# @return [Boolean] true if undetermined
|
103
|
+
|
89
104
|
# @!method not_submitted?
|
90
|
-
#
|
105
|
+
# @return [Boolean] true if not_submitted
|
106
|
+
|
91
107
|
# @!method failed?
|
92
|
-
#
|
108
|
+
# @return [Boolean] true if failed
|
109
|
+
|
93
110
|
# @!method passed?
|
94
|
-
#
|
111
|
+
# @return [Boolean] true if passed
|
112
|
+
|
95
113
|
# @!method held?
|
96
|
-
#
|
114
|
+
# @return [Boolean] true if held
|
115
|
+
|
97
116
|
# @!method queued?
|
98
|
-
#
|
117
|
+
# @return [Boolean] true if queued
|
118
|
+
|
99
119
|
# @!method running?
|
100
|
-
#
|
120
|
+
# @return [Boolean] true if running
|
121
|
+
|
101
122
|
# @!method suspended?
|
102
|
-
#
|
123
|
+
# @return [Boolean] true if suspended
|
103
124
|
VALUES_HASH.each do |char, name|
|
104
125
|
define_method("#{name}?") do
|
105
126
|
self == OSC::Machete::Status.new(char)
|
@@ -12,22 +12,27 @@ class OSC::Machete::TorqueHelper
|
|
12
12
|
BIN = ENV['TORQUE_BIN'] || '/opt/torque/bin'
|
13
13
|
HOSTS = {
|
14
14
|
'oakley' => 'oak-batch.osc.edu',
|
15
|
-
'ruby' => 'ruby-batch.osc.edu',
|
16
|
-
'quick' => 'quick-batch.osc.edu',
|
17
|
-
'owens' => 'owens-batch.ten.osc.edu'
|
15
|
+
'ruby' => 'ruby-batch.ten.osc.edu',
|
16
|
+
'quick' => 'quick-batch.ten.osc.edu',
|
17
|
+
'owens' => 'owens-batch.ten.osc.edu',
|
18
|
+
:default => 'oak-batch.osc.edu'
|
18
19
|
}
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
21
|
+
class << self
|
22
|
+
#@!attribute default
|
23
|
+
# @return [TorqueHelper] default TorqueHelper instance to use
|
24
|
+
attr_writer :default
|
25
|
+
def default
|
26
|
+
@default ||= self::new()
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
# Returns an OSC::Machete::Status ValueObject for a char
|
26
31
|
#
|
27
32
|
# @param [String] char The Torque status char
|
28
33
|
#
|
29
|
-
# @example
|
30
|
-
# status_for_char("C") #=> OSC::Machete::Status.
|
34
|
+
# @example Passed
|
35
|
+
# status_for_char("C") #=> OSC::Machete::Status.passed
|
31
36
|
# @example Queued
|
32
37
|
# status_for_char("W") #=> OSC::Machete::Status.queued
|
33
38
|
#
|
@@ -60,16 +65,6 @@ class OSC::Machete::TorqueHelper
|
|
60
65
|
#
|
61
66
|
# Bills against the project specified by the primary group of the user.
|
62
67
|
def qsub(script, host: nil, depends_on: {}, account_string: nil)
|
63
|
-
# if the script is set to run on Oakley in PBS headers
|
64
|
-
# this is to obviate current torque filter defect in which
|
65
|
-
# a script with PBS header set to specify oak-batch ends
|
66
|
-
# isn't properly handled and the job gets limited to 4GB
|
67
|
-
pbs = PBS::Batch.new(
|
68
|
-
host: HOSTS.fetch( host || host_from_script_pbs_header(script) ),
|
69
|
-
lib: LIB,
|
70
|
-
bin: BIN
|
71
|
-
)
|
72
|
-
|
73
68
|
headers = { depend: qsub_dependencies_header(depends_on) }
|
74
69
|
headers.clear if headers[:depend].empty?
|
75
70
|
|
@@ -83,7 +78,7 @@ class OSC::Machete::TorqueHelper
|
|
83
78
|
headers[PBS::ATTR[:A]] = default_account_string
|
84
79
|
end
|
85
80
|
|
86
|
-
pbs.submit_script(script, headers: headers, qsub: true)
|
81
|
+
pbs(host: host, script: script).submit_script(script, headers: headers, qsub: true)
|
87
82
|
end
|
88
83
|
|
89
84
|
# convert dependencies hash to a PBS header string
|
@@ -117,13 +112,7 @@ class OSC::Machete::TorqueHelper
|
|
117
112
|
# @return [Status] The job state
|
118
113
|
def qstat(pbsid, host: nil)
|
119
114
|
id = pbsid.to_s
|
120
|
-
|
121
|
-
host: HOSTS.fetch( host || host_from_pbsid(id) ),
|
122
|
-
lib: LIB,
|
123
|
-
bin: BIN
|
124
|
-
)
|
125
|
-
|
126
|
-
status = pbs.get_job(id, filters: [:job_state])
|
115
|
+
status = pbs(host: host, id: id).get_job(id, filters: [:job_state])
|
127
116
|
status_for_char status[id][:job_state][0] # get status from status char value
|
128
117
|
rescue PBS::UnkjobidError
|
129
118
|
OSC::Machete::Status.passed
|
@@ -136,15 +125,28 @@ class OSC::Machete::TorqueHelper
|
|
136
125
|
# @return [nil]
|
137
126
|
def qdel(pbsid, host: nil)
|
138
127
|
id = pbsid.to_s
|
139
|
-
pbs
|
140
|
-
|
128
|
+
pbs(host: host, id: id).delete_job(id)
|
129
|
+
rescue PBS::UnkjobidError
|
130
|
+
# Common use case where trying to delete a job that is no longer in the system.
|
131
|
+
end
|
132
|
+
|
133
|
+
def pbs(host: nil, id: nil, script: nil)
|
134
|
+
if host
|
135
|
+
# actually check if host is "oakley" i.e. a cluster key
|
136
|
+
host = HOSTS.fetch(host.to_s, host.to_s)
|
137
|
+
else
|
138
|
+
# try to determine host
|
139
|
+
key = host_from_pbsid(id) if id
|
140
|
+
key = host_from_script_pbs_header(script) if script && key.nil?
|
141
|
+
|
142
|
+
host = HOSTS.fetch(key, HOSTS.fetch(:default))
|
143
|
+
end
|
144
|
+
|
145
|
+
PBS::Batch.new(
|
146
|
+
host: host,
|
141
147
|
lib: LIB,
|
142
148
|
bin: BIN
|
143
149
|
)
|
144
|
-
|
145
|
-
pbs.delete_job(id)
|
146
|
-
rescue PBS::UnkjobidError
|
147
|
-
# Common use case where trying to delete a job that is no longer in the system.
|
148
150
|
end
|
149
151
|
|
150
152
|
private
|
@@ -159,8 +161,6 @@ class OSC::Machete::TorqueHelper
|
|
159
161
|
"quick"
|
160
162
|
elsif (File.open(script) { |f| f.read =~ /#PBS -q @owens-batch/ })
|
161
163
|
"owens"
|
162
|
-
else
|
163
|
-
"oakley" # DEFAULT
|
164
164
|
end
|
165
165
|
end
|
166
166
|
|
@@ -174,8 +174,6 @@ class OSC::Machete::TorqueHelper
|
|
174
174
|
"quick"
|
175
175
|
elsif (pbsid =~ /owens/ )
|
176
176
|
"owens"
|
177
|
-
else
|
178
|
-
"oakley" # DEFAULT
|
179
177
|
end
|
180
178
|
end
|
181
179
|
end
|
data/lib/osc/machete/user.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# Class that maintains the name and home identifiers of a User.
|
2
2
|
# Helper methods provided use the Etc module underneath.
|
3
3
|
#
|
4
|
+
# @deprecated Please use {http://www.rubydoc.info/gems/ood_support/OodSupport/User OodSupport::User} instead.
|
4
5
|
class OSC::Machete::User
|
5
6
|
|
6
7
|
attr_reader :name
|
@@ -19,6 +20,8 @@ class OSC::Machete::User
|
|
19
20
|
#
|
20
21
|
def initialize(username = Etc.getpwuid.name)
|
21
22
|
@name = username
|
23
|
+
|
24
|
+
warn "[DEPRECATION] `OSC::Machete::User` is deprecated. Please use `OodSupport::User` instead (see ood_support gem)."
|
22
25
|
end
|
23
26
|
|
24
27
|
# factory method to produce a User from specified uid
|
data/lib/osc/machete/version.rb
CHANGED
data/osc-machete.gemspec
CHANGED
@@ -18,9 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
|
-
spec.required_ruby_version = '
|
21
|
+
spec.required_ruby_version = '>= 2.7'
|
22
22
|
|
23
|
-
spec.add_development_dependency "bundler", "~>
|
23
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
spec.add_development_dependency "mocha"
|
26
26
|
spec.add_development_dependency "minitest", ">= 5.0"
|
data/test/fixtures/quick.sh
CHANGED
data/test/test_job_dir.rb
CHANGED
@@ -34,6 +34,6 @@ class TestJobDir < Minitest::Test
|
|
34
34
|
# Create unique directory
|
35
35
|
new_jobdir = OSC::Machete::JobDir.new(@parent).new_jobdir
|
36
36
|
Dir.mkdir(new_jobdir)
|
37
|
-
assert Dir.
|
37
|
+
assert Dir.exist?("#{@parent}/9"), "Directory was not created: #{@parent}/9"
|
38
38
|
end
|
39
39
|
end
|
data/test/test_location.rb
CHANGED
@@ -24,41 +24,41 @@ class TestLocation < Minitest::Test
|
|
24
24
|
def test_render_default_replace_template
|
25
25
|
setup_render
|
26
26
|
@location1.render("")
|
27
|
-
assert_equal true, File.
|
28
|
-
assert_equal false, File.
|
27
|
+
assert_equal true, File.exist?("#{@dir1}/file.txt")
|
28
|
+
assert_equal false, File.exist?("#{@dir1}/file.txt.mustache")
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_render_user_replace_template
|
32
32
|
setup_render
|
33
33
|
@location1.render("", {replace: true})
|
34
|
-
assert_equal true, File.
|
35
|
-
assert_equal false, File.
|
34
|
+
assert_equal true, File.exist?("#{@dir1}/file.txt")
|
35
|
+
assert_equal false, File.exist?("#{@dir1}/file.txt.mustache")
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_render_user_doesnt_replace_template
|
39
39
|
setup_render
|
40
40
|
@location1.render("", {replace: false})
|
41
|
-
assert_equal true, File.
|
42
|
-
assert_equal true, File.
|
41
|
+
assert_equal true, File.exist?("#{@dir1}/file.txt")
|
42
|
+
assert_equal true, File.exist?("#{@dir1}/file.txt.mustache")
|
43
43
|
end
|
44
44
|
|
45
45
|
def test_copy_to_shouldnt_copy_developer_files
|
46
46
|
setup_copy_to
|
47
47
|
|
48
48
|
@location1.copy_to(@dir2)
|
49
|
-
assert_equal true, Dir.
|
50
|
-
assert_equal false, Dir.
|
51
|
-
assert_equal false, Dir.
|
52
|
-
assert_equal false, Dir.
|
53
|
-
assert_equal true, Dir.
|
54
|
-
assert_equal true, File.
|
55
|
-
assert_equal false, File.
|
56
|
-
assert_equal true, File.
|
57
|
-
assert_equal false, File.
|
58
|
-
assert_equal false, File.
|
59
|
-
assert_equal false, File.
|
60
|
-
assert_equal true, File.
|
61
|
-
assert_equal false, File.
|
49
|
+
assert_equal true, Dir.exist?("#{@dir2}")
|
50
|
+
assert_equal false, Dir.exist?("#{@dir2}/.git")
|
51
|
+
assert_equal false, Dir.exist?("#{@dir2}/.svn")
|
52
|
+
assert_equal false, Dir.exist?("#{@dir2}/test.dir.1")
|
53
|
+
assert_equal true, Dir.exist?("#{@dir2}/test.dir.2")
|
54
|
+
assert_equal true, File.exist?("#{@dir2}/test.1")
|
55
|
+
assert_equal false, File.exist?("#{@dir2}/test.2")
|
56
|
+
assert_equal true, File.exist?("#{@dir2}/test.3")
|
57
|
+
assert_equal false, File.exist?("#{@dir2}/test.4")
|
58
|
+
assert_equal false, File.exist?("#{@dir2}/test.dir.2/test.1")
|
59
|
+
assert_equal false, File.exist?("#{@dir2}/test.dir.2/test.2")
|
60
|
+
assert_equal true, File.exist?("#{@dir2}/test.dir.2/test.4")
|
61
|
+
assert_equal false, File.exist?("#{@dir2}/.gitignore")
|
62
62
|
end
|
63
63
|
|
64
64
|
|
data/test/test_torque_helper.rb
CHANGED
@@ -106,7 +106,7 @@ class TestTorqueHelper < Minitest::Test
|
|
106
106
|
# Test that qdel works for quick batch
|
107
107
|
def test_qdel_quick
|
108
108
|
PBS::Batch.any_instance.stubs(:delete_job).returns(true)
|
109
|
-
assert_equal true, @shell.qdel("123.quick-batch.osc.edu")
|
109
|
+
assert_equal true, @shell.qdel("123.quick-batch.ten.osc.edu")
|
110
110
|
PBS::Batch.any_instance.unstub(:delete_job)
|
111
111
|
end
|
112
112
|
|
@@ -120,18 +120,18 @@ class TestTorqueHelper < Minitest::Test
|
|
120
120
|
# Test that qdel throws exception on PBS exception
|
121
121
|
def test_qdel_throws_exception
|
122
122
|
PBS::Batch.any_instance.stubs(:delete_job).raises(PBS::Error)
|
123
|
-
assert_raises(PBS::Error) { @shell.qdel("123.quick-batch.osc.edu") }
|
123
|
+
assert_raises(PBS::Error) { @shell.qdel("123.quick-batch.ten.osc.edu") }
|
124
124
|
PBS::Batch.any_instance.unstub(:delete_job)
|
125
125
|
|
126
126
|
PBS::Batch.any_instance.stubs(:delete_job).raises(PBS::SystemError)
|
127
|
-
assert_raises(PBS::SystemError) { @shell.qdel("123.quick-batch.osc.edu") }
|
127
|
+
assert_raises(PBS::SystemError) { @shell.qdel("123.quick-batch.ten.osc.edu") }
|
128
128
|
PBS::Batch.any_instance.unstub(:delete_job)
|
129
129
|
end
|
130
130
|
|
131
131
|
# Test that qdel doesn't throw exception if Unknown Job Id exception
|
132
132
|
def test_qdel_doesnt_throw_exception_on_unknown_job_id
|
133
133
|
PBS::Batch.any_instance.stubs(:delete_job).raises(PBS::UnkjobidError)
|
134
|
-
@shell.qdel("123.quick-batch.osc.edu")
|
134
|
+
@shell.qdel("123.quick-batch.ten.osc.edu")
|
135
135
|
PBS::Batch.any_instance.unstub(:delete_job)
|
136
136
|
end
|
137
137
|
|
@@ -206,4 +206,49 @@ class TestTorqueHelper < Minitest::Test
|
|
206
206
|
PBS::Batch.any_instance.unstub(:submit_script)
|
207
207
|
@shell.unstub(:default_account_string)
|
208
208
|
end
|
209
|
+
|
210
|
+
def test_pbs_default_host
|
211
|
+
s = @shell.pbs
|
212
|
+
assert_equal 'oak-batch.osc.edu', s.host
|
213
|
+
assert_equal OSC::Machete::TorqueHelper::LIB, s.lib.to_s
|
214
|
+
assert_equal OSC::Machete::TorqueHelper::BIN, s.bin.to_s
|
215
|
+
end
|
216
|
+
|
217
|
+
def test_pbs_host_variations
|
218
|
+
# you can use the cluster ids
|
219
|
+
assert_equal 'ruby-batch.ten.osc.edu', @shell.pbs(host: 'ruby').host
|
220
|
+
|
221
|
+
# or you can use the host itself
|
222
|
+
assert_equal 'ruby-batch.osc.edu', @shell.pbs(host: 'ruby-batch.osc.edu').host
|
223
|
+
assert_equal '@ruby-batch', @shell.pbs(host: '@ruby-batch').host
|
224
|
+
|
225
|
+
assert_equal 'ruby-batch.ten.osc.edu', @shell.pbs(id: '4567').host
|
226
|
+
assert_equal 'ruby-batch.ten.osc.edu', @shell.pbs(script: @script_ruby).host
|
227
|
+
assert_equal 'oak-batch.osc.edu', @shell.pbs(script: @script_oakley).host
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_setting_default_torque_helper
|
231
|
+
d = OSC::Machete::TorqueHelper.default
|
232
|
+
|
233
|
+
assert_equal 'oak-batch.osc.edu', OSC::Machete::TorqueHelper.default.pbs.host
|
234
|
+
|
235
|
+
# this is an example of how you can quickly modify the default behavior of
|
236
|
+
# a TorqueHelper instance to provide a new host, id, and script
|
237
|
+
d2 = OSC::Machete::TorqueHelper.new
|
238
|
+
class << d2
|
239
|
+
def pbs(host: nil, id: nil, script: nil)
|
240
|
+
PBS::Batch.new(
|
241
|
+
host: "ruby-batch.osc.edu",
|
242
|
+
lib: LIB,
|
243
|
+
bin: BIN
|
244
|
+
)
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
OSC::Machete::TorqueHelper.default = d2
|
249
|
+
|
250
|
+
assert_equal 'ruby-batch.osc.edu', OSC::Machete::TorqueHelper.default.pbs.host
|
251
|
+
|
252
|
+
OSC::Machete::TorqueHelper.default = d
|
253
|
+
end
|
209
254
|
end
|
@@ -71,7 +71,7 @@ class TestTorqueHelperLive < Minitest::Test
|
|
71
71
|
|
72
72
|
# Qstat it to make sure it's queued.
|
73
73
|
live_status = torque.qstat(live_job)
|
74
|
-
|
74
|
+
assert_includes OSC::Machete::Status.active_values, live_status
|
75
75
|
|
76
76
|
# Delete it and assert true returned.
|
77
77
|
live_delete_status = torque.qdel(live_job)
|
@@ -102,7 +102,7 @@ class TestTorqueHelperLive < Minitest::Test
|
|
102
102
|
|
103
103
|
# Qstat it to make sure it's queued.
|
104
104
|
live_status = torque.qstat(live_job)
|
105
|
-
|
105
|
+
assert_includes OSC::Machete::Status.active_values, live_status
|
106
106
|
|
107
107
|
# Delete it and assert true returned.
|
108
108
|
live_delete_status = torque.qdel(live_job)
|
@@ -128,11 +128,11 @@ class TestTorqueHelperLive < Minitest::Test
|
|
128
128
|
if Socket.gethostname == @submit_host
|
129
129
|
# Submit a small job.
|
130
130
|
live_job = torque.qsub(@script_ruby)
|
131
|
-
assert_match
|
131
|
+
assert_match(/^\d+$/, live_job)
|
132
132
|
|
133
133
|
# Qstat it to make sure it's queued.
|
134
134
|
live_status = torque.qstat(live_job)
|
135
|
-
|
135
|
+
assert_includes OSC::Machete::Status.active_values, live_status
|
136
136
|
|
137
137
|
# Delete it and assert true returned.
|
138
138
|
live_delete_status = torque.qdel(live_job)
|
@@ -157,11 +157,11 @@ class TestTorqueHelperLive < Minitest::Test
|
|
157
157
|
if Socket.gethostname == @submit_host
|
158
158
|
# Submit a small job.
|
159
159
|
live_job = torque.qsub(@script_quick, host: 'quick')
|
160
|
-
assert_match
|
160
|
+
assert_match(/\d+.quick-batch.ten.osc.edu/, live_job)
|
161
161
|
|
162
162
|
# Qstat it to make sure it's queued.
|
163
163
|
live_status = torque.qstat(live_job)
|
164
|
-
|
164
|
+
assert_includes OSC::Machete::Status.active_values, live_status
|
165
165
|
|
166
166
|
# Delete it and assert true returned.
|
167
167
|
live_delete_status = torque.qdel(live_job)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: osc-machete
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Franz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '2.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,6 +102,7 @@ executables: []
|
|
102
102
|
extensions: []
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
|
+
- ".github/workflows/publish.yml"
|
105
106
|
- ".gitignore"
|
106
107
|
- CHANGELOG.md
|
107
108
|
- Gemfile
|
@@ -144,17 +145,16 @@ require_paths:
|
|
144
145
|
- lib
|
145
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
146
147
|
requirements:
|
147
|
-
- - "
|
148
|
+
- - ">="
|
148
149
|
- !ruby/object:Gem::Version
|
149
|
-
version: '2.
|
150
|
+
version: '2.7'
|
150
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
151
152
|
requirements:
|
152
|
-
- - "
|
153
|
+
- - ">="
|
153
154
|
- !ruby/object:Gem::Version
|
154
|
-
version:
|
155
|
+
version: '0'
|
155
156
|
requirements: []
|
156
|
-
|
157
|
-
rubygems_version: 2.4.5
|
157
|
+
rubygems_version: 3.1.2
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Common interface for working with HPC batch jobs (currently OSC specific)
|
@@ -175,4 +175,3 @@ test_files:
|
|
175
175
|
- test/test_status.rb
|
176
176
|
- test/test_torque_helper.rb
|
177
177
|
- test/test_torque_helper_live.rb
|
178
|
-
has_rdoc:
|