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

Set the switch types for VMware switches #180

Merged
merged 1 commit into from
Apr 5, 2018

Conversation

agrare
Copy link
Member

@agrare agrare commented Mar 16, 2018

Update existing switches to set their types to either
DistributedVirtualSwitch for shared switches or HostVirtualSwitch for
non-shared switches.

Depends: ManageIQ/manageiq-providers-vmware#212

@agrare
Copy link
Member Author

agrare commented Mar 29, 2018

@miq-bot assign @Fryguy

@gtanzillo
Copy link
Member

@Fryguy You ok with merging this one?


class Host < ActiveRecord::Base
self.inheritance_column = :_type_disabled
has_many :host_switches
Copy link
Member

Choose a reason for hiding this comment

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

You have to add :class => "UpdateSwitchTypes::HostSwitch" so that it resolves correctly. Frankly, I'm surprised this doesn't fail in specs.

Copy link
Member

Choose a reason for hiding this comment

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

Wait, these relationships aren't used anywhere in this migration. If they're only here for testing I would remove them, as we try to keep models in tests down to the bare essentials. You can just query the table directly on the foreign_key column in the tests.

Copy link
Member Author

Choose a reason for hiding this comment

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

Moved Host and HostSwitch over to the test

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah idk I didn't need to set :class_name for running the tests or for running the migrations against a live db, just added it to be safe

let(:host_stub) { migration_stub(:Host) }

migration_context :up do
it "migrates a series of representative rows" do
Copy link
Member

@Fryguy Fryguy Mar 29, 2018

Choose a reason for hiding this comment

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

Do you have any tests for the non-nil switch type case? ( to show they aren't affected )

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 added one here

@agrare agrare force-pushed the set_switch_types branch 2 times, most recently from 47acfef to e2e649d Compare March 29, 2018 22:55
Copy link
Member

@Fryguy Fryguy left a comment

Choose a reason for hiding this comment

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

LGTM but something is wrong with the tests...it's possible the .joins(:hosts) requires the host model to be defined in the migration.

Update existing switches to set their types to either
DistributedVirtualSwitch for shared switches or HostVirtualSwitch for
non-shared switches.
@agrare agrare force-pushed the set_switch_types branch from e2e649d to 10edec6 Compare April 2, 2018 19:12
@miq-bot
Copy link
Member

miq-bot commented Apr 2, 2018

Checked commit agrare@10edec6 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
2 files checked, 3 offenses detected

db/migrate/20180316164826_update_switch_types.rb

@gtanzillo gtanzillo added this to the Sprint 83 Ending Apr 9, 2018 milestone Apr 5, 2018
@gtanzillo gtanzillo merged commit edf2043 into ManageIQ:master Apr 5, 2018
@agrare agrare deleted the set_switch_types branch April 5, 2018 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants