@@ -50,141 +50,156 @@ TEST_CASE ("Match basic jobspec", "[match C++]")
50
50
ctx = std::make_shared<resource_query_t > (rgraph, options);
51
51
REQUIRE (ctx);
52
52
53
- match_op_t match_op = match_op_t ::MATCH_ALLOCATE;
54
- bool reserved = false ;
55
- std::string R = " " ;
56
- uint64_t jobid = 1 ;
57
- double ov = 0.0 ;
58
- int64_t at = 0 ;
59
-
60
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
61
- match_op,
62
- jobspec,
63
- jobid,
64
- reserved,
65
- R,
66
- at,
67
- ov);
68
- REQUIRE (rc == 0 );
69
- REQUIRE (reserved == false );
70
- REQUIRE (at == 0 );
71
- }
72
-
73
- TEST_CASE (" Match basic jobspec without allocating" , " [match C++]" )
74
- {
75
- int rc = -1 ;
76
- const std::string options = " {}" ;
77
- std::stringstream gbuffer, jbuffer;
78
- std::ifstream graphfile (" ../../../t/data/resource/grugs/tiny.graphml" );
79
- std::ifstream jobspecfile (" ../../../t/data/resource/jobspecs/basics/test006.yaml" );
80
-
81
- if (!graphfile.is_open ()) {
82
- std::cerr << " Error opening file!" << std::endl;
53
+ SECTION (" MATCH_ALLOCATE" )
54
+ {
55
+ match_op_t match_op = match_op_t ::MATCH_ALLOCATE;
56
+ bool reserved = false ;
57
+ std::string R = " " ;
58
+ uint64_t jobid = 1 ;
59
+ double ov = 0.0 ;
60
+ int64_t at = 0 ;
61
+
62
+ rc =
63
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
64
+ REQUIRE (rc == 0 );
65
+ REQUIRE (reserved == false );
66
+ REQUIRE (at == 0 );
83
67
}
84
68
85
- jbuffer << jobspecfile.rdbuf ();
86
- std::string jobspec = jbuffer.str ();
87
-
88
- if (!jobspecfile.is_open ()) {
89
- std::cerr << " Error opening file!" << std::endl;
69
+ SECTION (" MATCH_WITHOUT_ALLOCATING" )
70
+ {
71
+ bool reserved = false ;
72
+ std::string R = " " ;
73
+ uint64_t jobid = 1 ;
74
+ double ov = 0.0 ;
75
+ int64_t at = 0 ;
76
+
77
+ match_op_t match_op = match_op_t ::MATCH_WITHOUT_ALLOCATING;
78
+
79
+ rc =
80
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
81
+ REQUIRE (rc == 0 );
82
+ REQUIRE (reserved == false );
83
+ REQUIRE (at == 0 );
84
+
85
+ match_op = match_op_t ::MATCH_ALLOCATE;
86
+
87
+ rc =
88
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
89
+ REQUIRE (rc == 0 );
90
+ REQUIRE (reserved == false );
91
+ REQUIRE (at == 0 );
92
+ rc =
93
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
94
+ REQUIRE (rc == 0 );
95
+ REQUIRE (reserved == false );
96
+ REQUIRE (at == 0 );
97
+ rc =
98
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
99
+ REQUIRE (rc == 0 );
100
+ REQUIRE (reserved == false );
101
+ REQUIRE (at == 0 );
102
+ rc =
103
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
104
+ REQUIRE (rc == 0 );
105
+ REQUIRE (reserved == false );
106
+ REQUIRE (at == 0 );
107
+ rc =
108
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
109
+ REQUIRE (rc == -1 ); // The tiny graph should be full
110
+
111
+ match_op = match_op_t ::MATCH_WITHOUT_ALLOCATING;
112
+
113
+ rc =
114
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
115
+ REQUIRE (rc == 0 );
116
+ REQUIRE (reserved == false );
117
+ REQUIRE (at == 3600 ); // MWOA should match the next available time
90
118
}
91
119
92
- gbuffer << graphfile.rdbuf ();
93
- std::string rgraph = gbuffer.str ();
94
-
95
- std::shared_ptr<resource_query_t > ctx = nullptr ;
96
- ctx = std::make_shared<resource_query_t > (rgraph, options);
97
- REQUIRE (ctx);
98
-
99
- bool reserved = false ;
100
- std::string R = " " ;
101
- uint64_t jobid = 1 ;
102
- double ov = 0.0 ;
103
- int64_t at = 0 ;
104
-
105
- match_op_t match_op = match_op_t ::MATCH_WITHOUT_ALLOCATING;
106
-
107
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
108
- match_op,
109
- jobspec,
110
- jobid,
111
- reserved,
112
- R,
113
- at,
114
- ov);
115
- REQUIRE (rc == 0 );
116
- REQUIRE (reserved == false );
117
- REQUIRE (at == 0 );
118
-
119
- match_op = match_op_t ::MATCH_ALLOCATE;
120
-
121
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
122
- match_op,
123
- jobspec,
124
- jobid,
125
- reserved,
126
- R,
127
- at,
128
- ov);
129
- REQUIRE (rc == 0 );
130
- REQUIRE (reserved == false );
131
- REQUIRE (at == 0 );
132
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
133
- match_op,
134
- jobspec,
135
- jobid,
136
- reserved,
137
- R,
138
- at,
139
- ov);
140
- REQUIRE (rc == 0 );
141
- REQUIRE (reserved == false );
142
- REQUIRE (at == 0 );
143
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
144
- match_op,
145
- jobspec,
146
- jobid,
147
- reserved,
148
- R,
149
- at,
150
- ov);
151
- REQUIRE (rc == 0 );
152
- REQUIRE (reserved == false );
153
- REQUIRE (at == 0 );
154
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
155
- match_op,
156
- jobspec,
157
- jobid,
158
- reserved,
159
- R,
160
- at,
161
- ov);
162
- REQUIRE (rc == 0 );
163
- REQUIRE (reserved == false );
164
- REQUIRE (at == 0 );
165
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
166
- match_op,
167
- jobspec,
168
- jobid,
169
- reserved,
170
- R,
171
- at,
172
- ov);
173
- REQUIRE (rc == -1 ); // The tiny graph should be full
174
-
175
- match_op = match_op_t ::MATCH_WITHOUT_ALLOCATING;
176
-
177
- rc = detail::reapi_cli_t::match_allocate (ctx.get (),
178
- match_op,
179
- jobspec,
180
- jobid,
181
- reserved,
182
- R,
183
- at,
184
- ov);
185
- REQUIRE (rc == 0 );
186
- REQUIRE (reserved == false );
187
- REQUIRE (at == 3600 ); // MWOA should match the next available time
120
+ SECTION (" Match only within some duration" )
121
+ {
122
+ bool reserved = false ;
123
+ std::string R = " " ;
124
+ uint64_t jobid = 1 ;
125
+ double ov = 0.0 ;
126
+ int64_t at = 0 ;
127
+
128
+ match_op_t match_op = match_op_t ::MATCH_ALLOCATE;
129
+
130
+ rc =
131
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
132
+ REQUIRE (rc == 0 );
133
+ REQUIRE (reserved == false );
134
+ REQUIRE (at == 0 );
135
+ rc =
136
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
137
+ REQUIRE (rc == 0 );
138
+ REQUIRE (reserved == false );
139
+ REQUIRE (at == 0 );
140
+ rc =
141
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
142
+ REQUIRE (rc == 0 );
143
+ REQUIRE (reserved == false );
144
+ REQUIRE (at == 0 );
145
+ rc =
146
+ reapi_cli_t::match_allocate (ctx.get (), match_op, jobspec, jobid, reserved, R, at, ov);
147
+ REQUIRE (rc == 0 );
148
+ REQUIRE (reserved == false );
149
+ REQUIRE (at == 0 );
150
+
151
+ // Fail to match within 3599 units (first avail at 3600)
152
+ match_op = match_op_t ::MATCH_ALLOCATE_ORELSE_RESERVE;
153
+ rc = reapi_cli_t::match_allocate (ctx.get (),
154
+ match_op,
155
+ jobspec,
156
+ jobid,
157
+ reserved,
158
+ R,
159
+ at,
160
+ ov,
161
+ 3599 );
162
+ REQUIRE (rc != 0 );
163
+ match_op = match_op_t ::MATCH_WITHOUT_ALLOCATING;
164
+ rc = reapi_cli_t::match_allocate (ctx.get (),
165
+ match_op,
166
+ jobspec,
167
+ jobid,
168
+ reserved,
169
+ R,
170
+ at,
171
+ ov,
172
+ 3599 );
173
+ REQUIRE (rc != 0 );
174
+
175
+ // Successfully match within 3600 units (first avail at 3600)
176
+ match_op = match_op_t ::MATCH_ALLOCATE_ORELSE_RESERVE;
177
+ rc = reapi_cli_t::match_allocate (ctx.get (),
178
+ match_op,
179
+ jobspec,
180
+ jobid,
181
+ reserved,
182
+ R,
183
+ at,
184
+ ov,
185
+ 3600 );
186
+ REQUIRE (rc == 0 );
187
+ REQUIRE (reserved == true );
188
+ REQUIRE (at == 3600 );
189
+ match_op = match_op_t ::MATCH_WITHOUT_ALLOCATING;
190
+ rc = reapi_cli_t::match_allocate (ctx.get (),
191
+ match_op,
192
+ jobspec,
193
+ jobid,
194
+ reserved,
195
+ R,
196
+ at,
197
+ ov,
198
+ 3600 );
199
+ REQUIRE (rc == 0 );
200
+ REQUIRE (reserved == false );
201
+ REQUIRE (at == 3600 );
202
+ }
188
203
}
189
204
190
205
} // namespace Flux::resource_model::detail
0 commit comments