|
58 | 58 | } |
59 | 59 |
|
60 | 60 | before do |
61 | | - stack_name = create_request[:lifecycle][:data][:stack] || VCAP::CloudController::Stack.default.name |
62 | | - stack = VCAP::CloudController::Stack.find(name: stack_name) || |
63 | | - VCAP::CloudController::Stack.make(name: stack_name) |
64 | | - # putting stack in the App.make call leads to an "App doesn't have a primary key" error |
65 | | - # message from sequel. |
66 | | - process = VCAP::CloudController::ProcessModel.make(app: app_model, memory: 1024, disk_quota: 1536) |
67 | | - process.stack = stack |
68 | | - process.save |
69 | 61 | allow_any_instance_of(CloudController::Blobstore::UrlGenerator).to receive(:package_download_url).and_return('some-string') |
70 | 62 | allow_any_instance_of(CloudController::Blobstore::UrlGenerator).to receive(:package_droplet_upload_url).and_return('some-string') |
71 | 63 | CloudController::DependencyLocator.instance.register(:bbs_stager_client, bbs_stager_client) |
|
168 | 160 | expect(last_response.status).to(eq(201), last_response.body) |
169 | 161 | expect(parsed_response['lifecycle']['type']).to eq 'kpack' |
170 | 162 | expect(parsed_response['state']).to eq 'STAGING' |
| 163 | + |
| 164 | + expect(k8s_api_client).to have_received(:create_image) |
171 | 165 | end |
172 | 166 |
|
173 | 167 | context 'with buildpacks specified' do |
|
192 | 186 | expect(parsed_response['lifecycle']['type']).to eq 'kpack' |
193 | 187 | expect(parsed_response['lifecycle']['data']['buildpacks']).to eq ['paketo-buildpacks/java', 'paketo-community/ruby'] |
194 | 188 | expect(parsed_response['state']).to eq 'STAGING' |
195 | | - end |
196 | | - end |
197 | | - end |
198 | 189 |
|
199 | | - describe 'app kpack lifecycle' do |
200 | | - let(:kpack_app_model) { VCAP::CloudController::AppModel.make(:kpack, space: space) } |
201 | | - let(:package) do |
202 | | - VCAP::CloudController::PackageModel.make( |
203 | | - app_guid: kpack_app_model.guid, |
204 | | - type: VCAP::CloudController::PackageModel::BITS_TYPE, |
205 | | - state: VCAP::CloudController::PackageModel::READY_STATE |
206 | | - ) |
207 | | - end |
208 | | - let(:request) do |
209 | | - { |
210 | | - package: { |
211 | | - guid: package.guid |
212 | | - }, |
213 | | - } |
214 | | - end |
215 | | - let(:k8s_buildpacks) do |
216 | | - [ |
217 | | - OpenStruct.new(name: 'paketo-buildpacks/java'), |
218 | | - OpenStruct.new(name: 'paketo-community/ruby'), |
219 | | - OpenStruct.new(name: 'paketo-buildpacks/httpd'), |
220 | | - ] |
| 190 | + expect(k8s_api_client).to have_received(:create_custom_builder) |
| 191 | + end |
221 | 192 | end |
222 | | - let(:k8s_api_client) { instance_double(Kubernetes::ApiClient) } |
223 | 193 |
|
224 | | - before do |
225 | | - allow(CloudController::DependencyLocator.instance).to receive(:k8s_api_client).and_return(k8s_api_client) |
226 | | - allow(k8s_api_client).to receive(:create_image) |
227 | | - allow(k8s_api_client).to receive(:create_custom_builder) |
228 | | - allow(k8s_api_client).to receive(:get_image) |
229 | | - allow(k8s_api_client).to receive(:get_custom_builder).and_return(Kubeclient::Resource.new({ |
230 | | - spec: { |
231 | | - stack: 'cflinuxfs3-stack', |
232 | | - store: 'cf-buildpack-store', |
233 | | - serviceAccount: 'gcr-service-account' |
| 194 | + context 'inheriting lifecycle from app' do |
| 195 | + let(:app_model) { VCAP::CloudController::AppModel.make(:kpack, space_guid: space.guid, name: 'my-app') } |
| 196 | + let(:package) do |
| 197 | + VCAP::CloudController::PackageModel.make( |
| 198 | + app_guid: app_model.guid, |
| 199 | + type: VCAP::CloudController::PackageModel::BITS_TYPE, |
| 200 | + state: VCAP::CloudController::PackageModel::READY_STATE |
| 201 | + ) |
| 202 | + end |
| 203 | + let(:create_request) do |
| 204 | + { |
| 205 | + package: { |
| 206 | + guid: package.guid |
| 207 | + }, |
234 | 208 | } |
235 | | - })) |
236 | | - allow_any_instance_of(VCAP::CloudController::KpackBuildpackListFetcher).to receive(:fetch_all).and_return(k8s_buildpacks) |
237 | | - end |
| 209 | + end |
238 | 210 |
|
239 | | - context 'when build has no lifecycle specified' do |
240 | | - context 'when app has kpack lifecycle' do |
241 | | - it 'uses the kpack lifecycle' do |
242 | | - post 'v3/builds', request.to_json, developer_headers |
| 211 | + context 'when build has no lifecycle specified' do |
| 212 | + context 'when app has kpack lifecycle' do |
| 213 | + it 'uses the kpack lifecycle' do |
| 214 | + post 'v3/builds', create_request.to_json, developer_headers |
243 | 215 |
|
244 | | - expect(last_response.status).to eq(201) |
245 | | - expect(parsed_response['lifecycle']['type']).to eq 'kpack' |
| 216 | + expect(last_response.status).to eq(201) |
| 217 | + expect(parsed_response['lifecycle']['type']).to eq 'kpack' |
| 218 | + end |
246 | 219 | end |
247 | 220 | end |
248 | 221 | end |
|
0 commit comments