@@ -19,6 +19,14 @@ func TestMatchOffers(t *testing.T) {
19
19
CPU : 1000 ,
20
20
GPU : 1000 ,
21
21
RAM : 1024 ,
22
+ GPUs : []data.GPUSpec {
23
+ {
24
+ Name : "NVIDIA RTX 4090" ,
25
+ Vendor : "NVIDIA" ,
26
+ VRAM : 24576 , // MB
27
+ },
28
+ },
29
+ Disk : 2924295844659 , // Bytes
22
30
},
23
31
DefaultPricing : data.DealPricing {
24
32
InstructionPrice : 10 ,
@@ -29,9 +37,11 @@ func TestMatchOffers(t *testing.T) {
29
37
30
38
basicJobOffer := data.JobOffer {
31
39
Spec : data.MachineSpec {
32
- CPU : 1000 ,
33
- GPU : 1000 ,
34
- RAM : 1024 ,
40
+ CPU : 1000 ,
41
+ GPU : 1000 ,
42
+ RAM : 1024 ,
43
+ GPUs : []data.GPUSpec {},
44
+ Disk : 0 , // Bytes
35
45
},
36
46
Mode : data .MarketPrice ,
37
47
Services : services ,
@@ -51,6 +61,13 @@ func TestMatchOffers(t *testing.T) {
51
61
Path : "/lilypad_module.json.tmpl" ,
52
62
}
53
63
64
+ sdxlModuleConfig := data.ModuleConfig {
65
+ Name : "" ,
66
+ Repo : "https://github.com/Lilypad-Tech/lilypad-module-sdxl" ,
67
+ Hash : "v0.9-lilypad1" ,
68
+ Path : "/lilypad_module.json.tmpl" ,
69
+ }
70
+
54
71
testCases := []struct {
55
72
name string
56
73
resourceOffer func (offer data.ResourceOffer ) data.ResourceOffer
@@ -100,6 +117,96 @@ func TestMatchOffers(t *testing.T) {
100
117
},
101
118
shouldMatch : false ,
102
119
},
120
+ {
121
+ name : "VRAM match when job creator specifies VRAM" ,
122
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
123
+ offer .Spec .GPUs = []data.GPUSpec {{VRAM : 24576 }}
124
+ return offer
125
+ },
126
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
127
+ offer .Module = sdxlModuleConfig
128
+ offer .Spec .GPUs = []data.GPUSpec {{VRAM : 20000 }}
129
+ return offer
130
+ },
131
+ shouldMatch : true ,
132
+ },
133
+ {
134
+ name : "VRAM match when job creator does not specify VRAM" ,
135
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
136
+ offer .Spec .GPUs = []data.GPUSpec {{VRAM : 24576 }}
137
+ return offer
138
+ },
139
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
140
+ offer .Module = sdxlModuleConfig
141
+ offer .Spec .GPUs = []data.GPUSpec {}
142
+ return offer
143
+ },
144
+ shouldMatch : true ,
145
+ },
146
+ {
147
+ name : "VRAM requested is more than resource offer VRAM" ,
148
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
149
+ offer .Spec .GPUs = []data.GPUSpec {{VRAM : 24576 }}
150
+ return offer
151
+ },
152
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
153
+ offer .Module = sdxlModuleConfig
154
+ offer .Spec .GPUs = []data.GPUSpec {{VRAM : 40000 }}
155
+ return offer
156
+ },
157
+ shouldMatch : false ,
158
+ },
159
+ {
160
+ name : "VRAM requested but resource offer has none" ,
161
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
162
+ offer .Spec .GPUs = []data.GPUSpec {}
163
+ return offer
164
+ },
165
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
166
+ offer .Module = sdxlModuleConfig
167
+ offer .Spec .GPUs = []data.GPUSpec {{VRAM : 49152 }}
168
+ return offer
169
+ },
170
+ shouldMatch : false ,
171
+ },
172
+ {
173
+ name : "Disk space match when job creator specifies disk space" ,
174
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
175
+ offer .Spec .Disk = 2924295844659 // Bytes
176
+ return offer
177
+ },
178
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
179
+ offer .Module = sdxlModuleConfig
180
+ offer .Spec .Disk = 1000000000000
181
+ return offer
182
+ },
183
+ shouldMatch : true ,
184
+ },
185
+ {
186
+ name : "Disk space match when job creator does not specify disk space" ,
187
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
188
+ offer .Spec .Disk = 2924295844659 // Bytes
189
+ return offer
190
+ },
191
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
192
+ offer .Module = sdxlModuleConfig
193
+ offer .Spec .Disk = 0 // zero-value
194
+ return offer
195
+ },
196
+ shouldMatch : true ,
197
+ },
198
+ {
199
+ name : "Disk space requested is more than resource offer disk space" ,
200
+ resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
201
+ offer .Spec .Disk = 2924295844659 // Bytes
202
+ return offer
203
+ },
204
+ jobOffer : func (offer data.JobOffer ) data.JobOffer {
205
+ offer .Spec .Disk = 4000000000000
206
+ return offer
207
+ },
208
+ shouldMatch : false ,
209
+ },
103
210
{
104
211
name : "Resource provider supports module" ,
105
212
resourceOffer : func (offer data.ResourceOffer ) data.ResourceOffer {
@@ -212,7 +319,7 @@ func TestMatchOffers(t *testing.T) {
212
319
t .Run (tc .name , func (t * testing.T ) {
213
320
result := matchOffers (tc .resourceOffer (basicResourceOffer ), tc .jobOffer (basicJobOffer ))
214
321
if result .matched () != tc .shouldMatch {
215
- t .Errorf ("Expected match to be %v, but got %v" , tc .shouldMatch , result )
322
+ t .Errorf ("Expected match to be %v, but got %+ v" , tc .shouldMatch , result )
216
323
}
217
324
})
218
325
}
0 commit comments