-
Notifications
You must be signed in to change notification settings - Fork 898
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
Truncate name of refresh task to 255 #16444
Truncate name of refresh task to 255 #16444
Conversation
spec/models/ems_refresh_spec.rb
Outdated
@@ -280,4 +280,16 @@ def assert_queue_item(expected_targets) | |||
expect(MiqQueue.count).to eq(1) | |||
end | |||
end | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove the whitespace here?
8b4b2c1
to
53a3d1a
Compare
spec/models/ems_refresh_spec.rb
Outdated
|
||
describe ".create_refresh_task" do | ||
it "create refresh task and trancates task name to 255 symbols" do | ||
ems = double("Ems") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create an ems with a factory? e.g. ems = FactoryGirl.create(:ems_vmware, :name => "Ems")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_refresh_task
called fromqueue_merge
, I will move test under queue_merger
context and will use already created instances
spec/models/ems_refresh_spec.rb
Outdated
ems = double("Ems") | ||
ems_name = "SomeTestEmsName" | ||
allow(ems).to receive(:name).and_return(ems_name) | ||
described_class.send(:create_refresh_task, ems, "a" * 1000) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same with the targets, how about:
vm = FactoryGirl.create(:vm_vmware)
targets = 500.times.map { vm }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do the same as with ems
spec/models/ems_refresh_spec.rb
Outdated
ems_name = "SomeTestEmsName" | ||
allow(ems).to receive(:name).and_return(ems_name) | ||
described_class.send(:create_refresh_task, ems, "a" * 1000) | ||
task_name = MiqTask.last.name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EmsRefresh.create_refresh_task
return the task so you don't need to find it, just do task = described_class.send(:create_refresh_task...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
5be442d
to
af182ea
Compare
Checked commits yrudman/manageiq@9333bef~...af182ea with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 |
spec/models/ems_refresh_spec.rb
Outdated
@@ -279,5 +279,14 @@ def assert_queue_item(expected_targets) | |||
EmsRefresh.queue_merge([vm], ems) | |||
expect(MiqQueue.count).to eq(1) | |||
end | |||
|
|||
describe ".create_refresh_task" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a queue_refresh_task context which calls this method, I think that context makes more sense for this test. No need to combine this into the queue_merge context just because it has ems and vm already defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
right, naming of those 2 methods sounds like this test should be under queue_refresh_task
context, but .create_refresh_task
was not invoked from .queue_refresh_taske
, it called only once from .queue_merge
https://github.com/yrudman/manageiq/blob/af182ea3587b445879185490efee03fafc3744ec/app/models/ems_refresh.rb#L181.
This is the reasoin why it was put under .queue_merge
context,
I thought it would be confusing to put test for method under context where it was not invoked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm we still call queue_merge from queue_refresh_task though so it should be fine there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok, will move new test under queue_refresh_task
context.
@miq_bot add-label gaprindashvili/yes, fine/yes |
af182ea
to
37f634d
Compare
…t-255 Truncate name of refresh task to 255 (cherry picked from commit f74530d) https://bugzilla.redhat.com/show_bug.cgi?id=1513123
Gaprindashvili backport details:
|
…t-255 Truncate name of refresh task to 255 (cherry picked from commit f74530d) https://bugzilla.redhat.com/show_bug.cgi?id=1513124
Fine backport details:
|
…hould-fit-255 Truncate name of refresh task to 255 (cherry picked from commit f74530d) https://bugzilla.redhat.com/show_bug.cgi?id=1513124
After migrating older DB datatype
t.string
would have maximum length of 255.See ManageIQ/manageiq-schema#125 for more details.
https://bugzilla.redhat.com/show_bug.cgi?id=1510605
This PR truncate length of string to 255 when attempting to create record in
miq_tasks
@miq-bot add-label bug
@miq-bot assign @agrare
\cc @Fryguy