Skip to content

Commit

Permalink
Update the app version when memory changes
Browse files Browse the repository at this point in the history
[finishes #43524631]

Change-Id: I3b9fbd1ff376a3467a146e071e8110ab7b26db1e
  • Loading branch information
Nate Clark committed Feb 1, 2013
1 parent 5c07b49 commit c8b9bdc
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
2 changes: 1 addition & 1 deletion config/cloud_controller.yml
Expand Up @@ -70,7 +70,7 @@ quota_definitions:
paid:
non_basic_services_allowed: true
total_services: 500
memory_limit: 204800 # 20 GB
memory_limit: 204800 # 200 GB

default_quota_definition: free

Expand Down
2 changes: 1 addition & 1 deletion lib/cloud_controller/models/app.rb
Expand Up @@ -92,7 +92,7 @@ def before_save
# We might start populating this with the vcap request guid of an api
# request.

if column_changed?(:state) && started?
if (column_changed?(:state) || column_changed?(:memory)) && started?
self.version = SecureRandom.uuid if !column_changed?(:version)
end

Expand Down
41 changes: 23 additions & 18 deletions spec/models/app_spec.rb
Expand Up @@ -338,18 +338,9 @@ module VCAP::CloudController
app.version.should_not be_nil
end

it "should not update the version when changing :memory" do
orig_version = app.version
app.memory = 1024
app.save
app.version.should == orig_version
end

it "should update the version when changing :state" do
orig_version = app.version
app.state = "STARTED"
app.save
app.version.should_not == orig_version
expect { app.save }.to change(app, :version)
end

it "should not update the version if the caller set it" do
Expand All @@ -359,16 +350,30 @@ module VCAP::CloudController
app.version.should == "my-version"
end

it "should not update the version on update of :memory" do
orig_version = app.version
app.update(:memory => 999)
app.version.should == orig_version
it "should update the version on update of :state" do
expect { app.update(:state => "STARTED") }.to change(app, :version)
end

it "should update the version on update of :state" do
orig_version = app.version
app.update(:state => "STARTED")
app.version.should_not == orig_version
context "for a started app" do
before { app.update(:state => "STARTED") }

it "should update the version when changing :memory" do
app.memory = 1024
expect { app.save }.to change(app, :version)
end

it "should update the version on update of :memory" do
expect { app.update(:memory => 999) }.to change(app, :version)
end

it "should not update the version when changing :instances" do
app.instances = 8
expect { app.save }.to_not change(app, :version)
end

it "should not update the version on update of :instances" do
expect { app.update(:instances => 8) }.to_not change(app, :version)
end
end
end

Expand Down

0 comments on commit c8b9bdc

Please sign in to comment.