Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support flavors for catalog bundles with Orchestration #535

Merged

Conversation

davidtluong
Copy link
Contributor

@davidtluong davidtluong commented May 14, 2019

Adds functionality so that catalog bundles now have access to flavors.

Thank you @gmcculloug and @NickLaMuro for improving on my original if conditional for this.

https://bugzilla.redhat.com/show_bug.cgi?id=1708638

@coveralls
Copy link

coveralls commented May 14, 2019

Pull Request Test Coverage Report for Build 3116

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.003%) to 96.93%

Totals Coverage Status
Change from base Build 3114: 0.003%
Covered Lines: 2936
Relevant Lines: 3029

💛 - Coveralls

@davidtluong davidtluong force-pushed the make-flavors-available-for-bundle branch 4 times, most recently from f4fcca0 to c437b03 Compare May 15, 2019 17:31
@davidtluong
Copy link
Contributor Author

davidtluong commented May 15, 2019

So I noticed that the spec was failing unless unless service.try(:service_templates).nil? was added, so the method doesn't error out there's no service_templates object for the ServiceTemplate.

That being said, even though it passed, I would assume the spec file is still missing the test for checking my new functionality for catalog bundles, since it was non existent before. After taking a look at the spec file, it was beyond my understanding, so someone else would have to edit that file or teach me how to test my new functionality correctly. Either way is good with me, I'm always up for learning something new.

@gmcculloug gmcculloug changed the title [Bug 1708638] https://bugzilla.redhat.com/show_bug.cgi?id=1708638 Support flavors for catalog bundles for Orchestration May 16, 2019
@gmcculloug gmcculloug changed the title Support flavors for catalog bundles for Orchestration Support flavors for catalog bundles with Orchestration May 16, 2019
@@ -17,10 +17,15 @@ def main

private

def orchestration_manager_from_bundle(service)
service.try(:service_templates).detect(&:orchestration_manager).try(:orchestration_manager) unless service.try(:service_templates).nil?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reduce the complexity a little:

service.service_templates.detect(&:orchestration_manager).try(:orchestration_manager) if service.respond_to?(:service_templates)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack, made the change.

@davidtluong davidtluong force-pushed the make-flavors-available-for-bundle branch from c437b03 to 1d6e395 Compare May 17, 2019 15:01
@d-m-u
Copy link
Contributor

d-m-u commented May 17, 2019

Hey @rh-dluong sorry, it was just a little bit of a pain

    context 'bundled service' do
      before do
        service_template.add_resource!(service_template_child)
      end
       
      let(:service_template) do
        FactoryBot.create(:service_template_orchestration)
      end

      let(:service_template_child) do
        FactoryBot.create(:service_template_orchestration, :orchestration_manager => ems)
      end

      let(:default_desc) { "<select>" }
      let(:flavor1) { FactoryBot.create(:flavor, :name => 'flavor1') }
      let(:flavor2) { FactoryBot.create(:flavor, :name => 'flavor2') }
      let(:ems) { FactoryBot.create(:ems_openstack, :flavors => [flavor1, flavor2]) }

      let(:svc_model_flavor1) do
        MiqAeMethodService::MiqAeServiceFlavor.find(flavor1.id)
      end

      let(:svc_model_flavor2) do
        MiqAeMethodService::MiqAeServiceFlavor.find(flavor2.id)
      end

      let(:svc_model_orchestration_manager) do
        MiqAeMethodService::MiqAeServiceExtManagementSystem.find(ems.id)
      end

      let(:svc_model_service) do
        root_hash["service_template"] || root_hash["service"]
      end

      it "finds all the flavors and populates the list" do
        allow(ae_service.root).to receive(:attributes)
        .and_return("service_template" => svc_model_service)
        allow(svc_model_service).to receive(:orchestration_manager)
        .and_return(nil)
        allow(svc_model_orchestration_manager).to receive(:flavors)
        .and_return([svc_model_flavor1, svc_model_flavor2])
        described_class.new(ae_service).main

        expect(ae_service["values"]).to include(
          nil          => default_desc,
          flavor1.name => flavor1.name,
          flavor2.name => flavor2.name
        )
        expect(ae_service["default_value"]).to be_nil
      end
    end

@gmcculloug
Copy link
Member

Nice job @d-m-u!

@davidtluong davidtluong force-pushed the make-flavors-available-for-bundle branch 3 times, most recently from 6dfc54f to 6f5ae96 Compare May 20, 2019 15:29
Copy link
Contributor

@d-m-u d-m-u left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @rh-dluong

@davidtluong davidtluong force-pushed the make-flavors-available-for-bundle branch 3 times, most recently from 2a04926 to 7e61c25 Compare May 20, 2019 17:21
@davidtluong
Copy link
Contributor Author

Thanks @d-m-u for modifying the spec!

@davidtluong davidtluong force-pushed the make-flavors-available-for-bundle branch from 7e61c25 to dc2109d Compare May 20, 2019 18:41
@davidtluong davidtluong force-pushed the make-flavors-available-for-bundle branch from dc2109d to e8c56cf Compare May 20, 2019 18:54
@miq-bot
Copy link
Member

miq-bot commented May 20, 2019

Checked commit davidtluong@e8c56cf with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 0 offenses detected
Everything looks fine. ⭐

@gmcculloug gmcculloug merged commit 2eb7cfd into ManageIQ:master May 20, 2019
@gmcculloug gmcculloug added this to the Sprint 112 Ending May 27, 2019 milestone May 20, 2019
@davidtluong davidtluong deleted the make-flavors-available-for-bundle branch May 20, 2019 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants