Module: Offshore::Snapshot::Template

Extended by:
Template
Included in:
Template
Defined in:
lib/offshore/server/snapshot.rb

Constant Summary collapse

SNAPSHOT_KEY =
"snapshot:checksum"

Instance Method Summary collapse

Instance Method Details

#createObject



38
39
40
41
42
43
# File 'lib/offshore/server/snapshot.rb', line 38

def create
  use_db(test_db)
  use_db(template_db)
  clone(test_db, template_db)
  record_checksum(test_db)
end

#rollbackObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/offshore/server/snapshot.rb', line 45

def rollback
  use_db(test_db)
  stored = Offshore.redis.get(SNAPSHOT_KEY)
  sum = db_checksum(test_db)
  
  if stored == sum
    Logger.info("   Snapshot checksum equal - not cloning")
  else
    Logger.info("   Snapshot checksum not equal - cloning")
    use_db(template_db)
    clone(template_db, test_db)
    record_checksum(test_db) unless stored
  end
end

#rollback2Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/offshore/server/snapshot.rb', line 61

def rollback2
  use_db(test_db)
  use_db(template_db)
  if equal_checksum?(template_db, test_db)
    Logger.info("   Snapshot checksum equal - not cloning")
  else
    Logger.info("   Snapshot checksum not equal - cloning")
    clone(template_db, test_db)
  end
end