aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Data/SQLite/SQLiteRegionData.cs30
-rw-r--r--OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs2
-rw-r--r--OpenSim/Data/Tests/BasicRegionTest.cs91
3 files changed, 97 insertions, 26 deletions
diff --git a/OpenSim/Data/SQLite/SQLiteRegionData.cs b/OpenSim/Data/SQLite/SQLiteRegionData.cs
index 41d108e..fef5e3b 100644
--- a/OpenSim/Data/SQLite/SQLiteRegionData.cs
+++ b/OpenSim/Data/SQLite/SQLiteRegionData.cs
@@ -470,20 +470,6 @@ namespace OpenSim.Data.SQLite
470 { 470 {
471 int revision = Util.UnixTimeSinceEpoch(); 471 int revision = Util.UnixTimeSinceEpoch();
472 472
473 // the following is an work around for .NET. The perf
474 // issues associated with it aren't as bad as you think.
475 m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString());
476 String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
477 " values(:RegionUUID, :Revision, :Heightfield)";
478
479 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
480 {
481 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID)));
482 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
483 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
484 cmd.ExecuteNonQuery();
485 }
486
487 // This is added to get rid of the infinitely growing 473 // This is added to get rid of the infinitely growing
488 // terrain databases which negatively impact on SQLite 474 // terrain databases which negatively impact on SQLite
489 // over time. Before reenabling this feature there 475 // over time. Before reenabling this feature there
@@ -493,13 +479,27 @@ namespace OpenSim.Data.SQLite
493 479
494 using ( 480 using (
495 SqliteCommand cmd = 481 SqliteCommand cmd =
496 new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision < :Revision", 482 new SqliteCommand("delete from terrain where RegionUUID=:RegionUUID and Revision <= :Revision",
497 m_conn)) 483 m_conn))
498 { 484 {
499 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID))); 485 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID)));
500 cmd.Parameters.Add(new SqliteParameter(":Revision", revision)); 486 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
501 cmd.ExecuteNonQuery(); 487 cmd.ExecuteNonQuery();
502 } 488 }
489
490 // the following is an work around for .NET. The perf
491 // issues associated with it aren't as bad as you think.
492 m_log.Info("[REGION DB]: Storing terrain revision r" + revision.ToString());
493 String sql = "insert into terrain(RegionUUID, Revision, Heightfield)" +
494 " values(:RegionUUID, :Revision, :Heightfield)";
495
496 using (SqliteCommand cmd = new SqliteCommand(sql, m_conn))
497 {
498 cmd.Parameters.Add(new SqliteParameter(":RegionUUID", Util.ToRawUuidString(regionID)));
499 cmd.Parameters.Add(new SqliteParameter(":Revision", revision));
500 cmd.Parameters.Add(new SqliteParameter(":Heightfield", serializeTerrain(ter)));
501 cmd.ExecuteNonQuery();
502 }
503 } 503 }
504 } 504 }
505 505
diff --git a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
index 94b5bf1..6727b87 100644
--- a/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
+++ b/OpenSim/Data/SQLite/Tests/SQLiteRegionTest.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Data.SQLite.Tests
55 [TestFixtureTearDown] 55 [TestFixtureTearDown]
56 public void Cleanup() 56 public void Cleanup()
57 { 57 {
58 System.IO.File.Delete(file); 58 // System.IO.File.Delete(file);
59 } 59 }
60 } 60 }
61} \ No newline at end of file 61} \ No newline at end of file
diff --git a/OpenSim/Data/Tests/BasicRegionTest.cs b/OpenSim/Data/Tests/BasicRegionTest.cs
index 5fca534..7b5284a 100644
--- a/OpenSim/Data/Tests/BasicRegionTest.cs
+++ b/OpenSim/Data/Tests/BasicRegionTest.cs
@@ -40,17 +40,31 @@ namespace OpenSim.Data.Tests
40 public class BasicRegionTest 40 public class BasicRegionTest
41 { 41 {
42 public IRegionDataStore db; 42 public IRegionDataStore db;
43 public UUID region; 43 public UUID region1;
44 public UUID region2;
45 public double height1;
46 public double height2;
44 47
45 public void SuperInit() 48 public void SuperInit()
46 { 49 {
47 region = UUID.Random(); 50 try
51 {
52 log4net.Config.XmlConfigurator.Configure();
53 }
54 catch (Exception)
55 {
56 // I don't care, just leave log4net off
57 }
58
59 region1 = UUID.Random();
60 height1 = 20;
61 height2 = 100;
48 } 62 }
49 63
50 [Test] 64 [Test]
51 public void T001_LoadEmpty() 65 public void T001_LoadEmpty()
52 { 66 {
53 List<SceneObjectGroup> objs = db.LoadObjects(region); 67 List<SceneObjectGroup> objs = db.LoadObjects(region1);
54 Assert.That(objs.Count, Is.EqualTo(0)); 68 Assert.That(objs.Count, Is.EqualTo(0));
55 } 69 }
56 70
@@ -64,18 +78,18 @@ namespace OpenSim.Data.Tests
64 SceneObjectGroup sog = NewSOG("object1"); 78 SceneObjectGroup sog = NewSOG("object1");
65 SceneObjectGroup sog2 = NewSOG("object2"); 79 SceneObjectGroup sog2 = NewSOG("object2");
66 80
67 db.StoreObject(sog, region); 81 db.StoreObject(sog, region1);
68 db.StoreObject(sog2, region); 82 db.StoreObject(sog2, region1);
69 83
70 // This tests the ADO.NET driver 84 // This tests the ADO.NET driver
71 List<SceneObjectGroup> objs = db.LoadObjects(region); 85 List<SceneObjectGroup> objs = db.LoadObjects(region1);
72 Assert.That(objs.Count, Is.EqualTo(2)); 86 Assert.That(objs.Count, Is.EqualTo(2));
73 } 87 }
74 88
75 [Test] 89 [Test]
76 public void T011_ObjectNames() 90 public void T011_ObjectNames()
77 { 91 {
78 List<SceneObjectGroup> objs = db.LoadObjects(region); 92 List<SceneObjectGroup> objs = db.LoadObjects(region1);
79 foreach (SceneObjectGroup sog in objs) 93 foreach (SceneObjectGroup sog in objs)
80 { 94 {
81 SceneObjectPart p = sog.RootPart; 95 SceneObjectPart p = sog.RootPart;
@@ -88,16 +102,73 @@ namespace OpenSim.Data.Tests
88 public void T012_UpdateObject() 102 public void T012_UpdateObject()
89 { 103 {
90 string text = "object1 text"; 104 string text = "object1 text";
91 SceneObjectGroup sog = FindSOG("object1", region); 105 SceneObjectGroup sog = FindSOG("object1", region1);
92 sog.RootPart.Text = text; 106 sog.RootPart.Text = text;
93 db.StoreObject(sog, region); 107 db.StoreObject(sog, region1);
94 108
95 sog = FindSOG("object1", region); 109 sog = FindSOG("object1", region1);
96 Assert.That(text, Is.EqualTo(sog.RootPart.Text)); 110 Assert.That(text, Is.EqualTo(sog.RootPart.Text));
97 } 111 }
98 112
113 [Test]
114 public void T300_NoTerrain()
115 {
116 double[,] t1 = db.LoadTerrain(region1);
117 }
118
119 [Test]
120 public void T301_CreateTerrain()
121 {
122 double[,] t1 = GenTerrain(height1);
123 db.StoreTerrain(t1, region1);
124 }
125
126 [Test]
127 public void T302_FetchTerrain()
128 {
129 double[,] baseterrain1 = GenTerrain(height1);
130 double[,] baseterrain2 = GenTerrain(height2);
131 double[,] t1 = db.LoadTerrain(region1);
132 Assert.That(CompareTerrain(t1, baseterrain1), Is.True);
133 Assert.That(CompareTerrain(t1, baseterrain2), Is.False);
134 }
135
136 [Test]
137 public void T303_UpdateTerrain()
138 {
139 double[,] baseterrain1 = GenTerrain(height1);
140 double[,] baseterrain2 = GenTerrain(height2);
141 db.StoreTerrain(baseterrain2, region1);
142
143 double[,] t1 = db.LoadTerrain(region1);
144 Assert.That(CompareTerrain(t1, baseterrain1), Is.False);
145 Assert.That(CompareTerrain(t1, baseterrain2), Is.True);
146 }
147
99 // Extra private methods 148 // Extra private methods
100 149
150 private double[,] GenTerrain(double value)
151 {
152 double[,] terret = new double[256,256];
153 terret.Initialize();
154 for (int x = 0; x < 256; x++)
155 for (int y = 0; y < 256; y++)
156 terret[x,y] = value;
157
158 return terret;
159 }
160
161 private bool CompareTerrain(double[,] one, double[,] two)
162 {
163 for (int x = 0; x < 256; x++)
164 for (int y = 0; y < 256; y++)
165 if (one[x,y] != two[x,y])
166 return false;
167
168 return true;
169 }
170
171
101 private SceneObjectGroup FindSOG(string name, UUID r) 172 private SceneObjectGroup FindSOG(string name, UUID r)
102 { 173 {
103 List<SceneObjectGroup> objs = db.LoadObjects(r); 174 List<SceneObjectGroup> objs = db.LoadObjects(r);