Skip to content

Commit 1f0e12e

Browse files
authored
Fix object store API tests (#9420)
* Fix object store CI tests by uploading required files in test setup * Address review comments
1 parent 8205d00 commit 1f0e12e

1 file changed

Lines changed: 49 additions & 19 deletions

File tree

Tests/Api/ObjectStoreTests.cs

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,41 @@
2323
namespace QuantConnect.Tests.API
2424
{
2525
[TestFixture, Explicit("Requires configured api access and available backtest node to run on"), Parallelizable(ParallelScope.Fixtures)]
26-
public class ObjectStoreTests: ApiTestBase
26+
public class ObjectStoreTests : ApiTestBase
2727
{
28-
private const string _key = "/Ricardo";
28+
private const string _ciTestFolder = "/CI_TEST";
29+
private const string _key = _ciTestFolder + "/Ricardo";
2930
private readonly byte[] _data = new byte[3] { 1, 2, 3 };
3031

32+
private static readonly string[] _keysToSetUp = new[]
33+
{
34+
"/filename.zip",
35+
"/mm_test.csv",
36+
"/model",
37+
"/trades_test.json",
38+
"/profile_results.json",
39+
"/CustomData/placeholder.txt",
40+
"/log.txt",
41+
"/l1_model.p",
42+
"/latency_1_False.txt",
43+
"/portfolio-targets2.csv",
44+
"/Regressor",
45+
"/example_data_2.zip"
46+
};
47+
48+
[OneTimeSetUp]
49+
public void SetUpObjectStoreFiles()
50+
{
51+
foreach (var key in _keysToSetUp)
52+
{
53+
var fullKey = _ciTestFolder + key;
54+
if (!ApiClient.GetObjectStoreProperties(TestOrganization, fullKey).Success)
55+
{
56+
ApiClient.SetObjectStore(TestOrganization, fullKey, _data);
57+
}
58+
}
59+
}
60+
3161
[TestCaseSource(nameof(GetObjectStoreWorksAsExpectedTestCases))]
3262
public void GetObjectStoreWorksAsExpected(string testName, List<string> keys, bool isSuccessExpected)
3363
{
@@ -45,12 +75,12 @@ public void GetObjectStoreWorksAsExpected(string testName, List<string> keys, bo
4575
}
4676
}
4777

48-
[TestCase("/filename.zip", true)]
49-
[TestCase("/orats_2024-02-32.json", false)]
50-
[TestCase("/mrm8488", false)]
51-
[TestCase("/mm_test.csv", true)]
52-
[TestCase("/model", true)]
53-
[TestCase("/trades_test.json", true)]
78+
[TestCase(_ciTestFolder + "/filename.zip", true)]
79+
[TestCase(_ciTestFolder + "/orats_2024-02-32.json", false)]
80+
[TestCase(_ciTestFolder + "/mrm8488", false)]
81+
[TestCase(_ciTestFolder + "/mm_test.csv", true)]
82+
[TestCase(_ciTestFolder + "/model", true)]
83+
[TestCase(_ciTestFolder + "/trades_test.json", true)]
5484
public void GetObjectStorePropertiesWorksAsExpected(string key, bool isSuccessExpected)
5585
{
5686
var result = ApiClient.GetObjectStoreProperties(TestOrganization, key);
@@ -121,19 +151,19 @@ public void ListObjectStoreWorksAsExpected()
121151

122152
private static object[] GetObjectStoreWorksAsExpectedTestCases =
123153
{
124-
new object[] { "Two keys present", new List<string> { "/trades_test.json", "/profile_results.json" }, true},
154+
new object[] { "Two keys present", new List<string> { _ciTestFolder + "/trades_test.json", _ciTestFolder + "/profile_results.json" }, true},
125155
new object[] { "No key is given", new List<string> {}, false},
126-
new object[] { "One key is present and the other one not", new List<string> { "/trades_test.json", "/orats_2024-02-32.json" }, true},
127-
new object[] { "The key is not present", new List<string> { "/orats_2024-02-32.json" }, false},
128-
new object[] { "The type of the object store file is directory", new List<string> { "/CustomData" }, true},
129-
new object[] { "The type of the object store file is text/plain", new List<string> { "/log.txt" }, true},
130-
new object[] { "The type of the object store file is application/octet-stream", new List<string> { "/model" }, true},
131-
new object[] { "The type of the object store file is P", new List<string> { "/l1_model.p" }, true},
156+
new object[] { "One key is present and the other one not", new List<string> { _ciTestFolder + "/trades_test.json", _ciTestFolder + "/orats_2024-02-32.json" }, true},
157+
new object[] { "The key is not present", new List<string> { _ciTestFolder + "/orats_2024-02-32.json" }, false},
158+
new object[] { "The type of the object store file is directory", new List<string> { _ciTestFolder + "/CustomData" }, true},
159+
new object[] { "The type of the object store file is text/plain", new List<string> { _ciTestFolder + "/log.txt" }, true},
160+
new object[] { "The type of the object store file is application/octet-stream", new List<string> { _ciTestFolder + "/model" }, true},
161+
new object[] { "The type of the object store file is P", new List<string> { _ciTestFolder + "/l1_model.p" }, true},
132162
new object[] { "Heavy object store files", new List<string> {
133-
"/latency_1_False.txt",
134-
"/portfolio-targets2.csv",
135-
"/Regressor",
136-
"/example_data_2.zip"
163+
_ciTestFolder + "/latency_1_False.txt",
164+
_ciTestFolder + "/portfolio-targets2.csv",
165+
_ciTestFolder + "/Regressor",
166+
_ciTestFolder + "/example_data_2.zip"
137167
}, true}
138168
};
139169
}

0 commit comments

Comments
 (0)