|
699 | 699 | end |
700 | 700 |
|
701 | 701 | context 'when the loadbalancing-algorithm is supported' do |
702 | | - context 'when a new route is added' do |
703 | | - let(:yml_manifest) do |
704 | | - { |
705 | | - 'applications' => [ |
706 | | - { 'name' => app1_model.name, |
707 | | - 'routes' => [ |
708 | | - { 'route' => "https://round-robin-app.#{shared_domain.name}", |
709 | | - 'options' => { |
710 | | - 'loadbalancing-algorithm' => 'round-robin' |
711 | | - } } |
712 | | - ] } |
713 | | - ] |
714 | | - }.to_yaml |
715 | | - end |
716 | | - |
717 | | - it 'adds and removes the loadbalancing-algorithm to the route' do |
718 | | - post "/v3/spaces/#{space.guid}/actions/apply_manifest", yml_manifest, yml_headers(user_header) |
| 702 | + let(:yml_manifest) do |
| 703 | + { |
| 704 | + 'applications' => [ |
| 705 | + { 'name' => app1_model.name, |
| 706 | + 'routes' => [ |
| 707 | + { 'route' => "https://round-robin-app.#{shared_domain.name}", |
| 708 | + 'options' => { |
| 709 | + 'loadbalancing-algorithm' => 'round-robin' |
| 710 | + } } |
| 711 | + ] } |
| 712 | + ] |
| 713 | + }.to_yaml |
| 714 | + end |
719 | 715 |
|
720 | | - expect(last_response.status).to eq(202) |
721 | | - job_guid = VCAP::CloudController::PollableJobModel.last.guid |
| 716 | + it 'adds and updates the loadbalancing-algorithm' do |
| 717 | + post "/v3/spaces/#{space.guid}/actions/apply_manifest", yml_manifest, yml_headers(user_header) |
722 | 718 |
|
723 | | - Delayed::Worker.new.work_off |
724 | | - expect(VCAP::CloudController::PollableJobModel.find(guid: job_guid)).to be_complete, VCAP::CloudController::PollableJobModel.find(guid: job_guid).cf_api_error |
| 719 | + expect(last_response.status).to eq(202) |
| 720 | + job_guid = VCAP::CloudController::PollableJobModel.last.guid |
725 | 721 |
|
726 | | - app1_model.reload |
727 | | - expect(app1_model.routes.first.options).to eq({ 'lb_algo' => 'round-robin' }) |
728 | | - # expect(route.route_mappings_dataset.first(app: app1_model).protocol).to eq('http1') |
729 | | - # expect(second_route.route_mappings_dataset.first(app: app1_model).protocol).to eq('http2') |
| 722 | + Delayed::Worker.new.work_off |
| 723 | + expect(VCAP::CloudController::PollableJobModel.find(guid: job_guid)).to be_complete, VCAP::CloudController::PollableJobModel.find(guid: job_guid).cf_api_error |
730 | 724 |
|
731 | | - ### remove the loadbalancing-algorithm from the route |
| 725 | + app1_model.reload |
| 726 | + expect(app1_model.routes.first.options).to eq({ 'lb_algo' => 'round-robin' }) |
732 | 727 |
|
733 | | - yml_manifest = { |
734 | | - 'applications' => [ |
735 | | - { 'name' => app1_model.name, |
736 | | - 'routes' => [ |
737 | | - { 'route' => "https://round-robin-app.#{shared_domain.name}" } |
738 | | - ] } |
739 | | - ] |
740 | | - }.to_yaml |
| 728 | + ### update the loadbalancing-algorithm from the route |
741 | 729 |
|
742 | | - post "/v3/spaces/#{space.guid}/actions/apply_manifest", yml_manifest, yml_headers(user_header) |
| 730 | + yml_manifest = { |
| 731 | + 'applications' => [ |
| 732 | + { 'name' => app1_model.name, |
| 733 | + 'routes' => [ |
| 734 | + { 'route' => "https://round-robin-app.#{shared_domain.name}", |
| 735 | + 'options' => { |
| 736 | + 'loadbalancing-algorithm' => 'least-connections' |
| 737 | + } } |
| 738 | + ] } |
| 739 | + ] |
| 740 | + }.to_yaml |
743 | 741 |
|
744 | | - expect(last_response.status).to eq(202) |
745 | | - job_guid = VCAP::CloudController::PollableJobModel.last.guid |
| 742 | + post "/v3/spaces/#{space.guid}/actions/apply_manifest", yml_manifest, yml_headers(user_header) |
746 | 743 |
|
747 | | - Delayed::Worker.new.work_off |
748 | | - expect(VCAP::CloudController::PollableJobModel.find(guid: job_guid)).to be_complete, VCAP::CloudController::PollableJobModel.find(guid: job_guid).cf_api_error |
| 744 | + expect(last_response.status).to eq(202) |
| 745 | + job_guid = VCAP::CloudController::PollableJobModel.last.guid |
749 | 746 |
|
750 | | - app1_model.reload |
751 | | - expect(app1_model.routes.first.options).to eq({}) |
| 747 | + Delayed::Worker.new.work_off |
| 748 | + expect(VCAP::CloudController::PollableJobModel.find(guid: job_guid)).to be_complete, VCAP::CloudController::PollableJobModel.find(guid: job_guid).cf_api_error |
752 | 749 |
|
753 | | - end |
| 750 | + app1_model.reload |
| 751 | + expect(app1_model.routes.first.options).to eq({ 'lb_algo' => 'least-connections' }) |
754 | 752 |
|
755 | 753 | end |
756 | 754 | end |
|
0 commit comments