@@ -70,4 +70,121 @@ TEST_CASE ("Match basic jobspec", "[match C++]")
70
70
REQUIRE (at == 0 );
71
71
}
72
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;
83
+ }
84
+
85
+ jbuffer << jobspecfile.rdbuf ();
86
+ std::string jobspec = jbuffer.str ();
87
+
88
+ if (!jobspecfile.is_open ()) {
89
+ std::cerr << " Error opening file!" << std::endl;
90
+ }
91
+
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
188
+ }
189
+
73
190
} // namespace Flux::resource_model::detail
0 commit comments