Skip to content

Commit bf476f8

Browse files
committed
[CM-1580]: Fixed testLogCurveOverwrite() to use two ApiExperiment and existing ApiExperiment for testing to avoid flakiness.
1 parent 6de2d67 commit bf476f8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

comet-java-client/src/test/java/ml/comet/experiment/impl/ApiExperimentTest.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package ml.comet.experiment.impl;
22

33
import ml.comet.experiment.ApiExperiment;
4+
import ml.comet.experiment.ExperimentBuilder;
45
import ml.comet.experiment.OnlineExperiment;
56
import ml.comet.experiment.asset.LoggedExperimentAsset;
67
import ml.comet.experiment.context.ExperimentContext;
@@ -129,25 +130,33 @@ public void testLogCurve() throws Exception {
129130

130131
@Test
131132
public void testLogCurveOverwrite() throws Exception {
133+
String experimentKey;
134+
String fileName = "someCurve";
135+
int pointsCount = 10;
136+
long size;
132137
try (ApiExperiment apiExperiment = createApiExperiment()) {
133-
String fileName = "someCurve";
134-
int pointsCount = 10;
135138
Curve curve = createCurve(fileName, pointsCount);
136139
apiExperiment.logCurve(curve, false, SOME_FULL_CONTEXT);
137140

138141
// check that CURVE asset was saved as expected
139142
List<LoggedExperimentAsset> assets = apiExperiment.getAssetList(CURVE.type());
140143
assertEquals(1, assets.size(), "wrong number of assets returned");
141144

142-
long size = assets.get(0).getSize().orElse((long) -1);
145+
size = assets.get(0).getSize().orElse((long) -1);
143146
assertTrue(size > 0, "wrong asset size");
144147

148+
experimentKey = apiExperiment.getExperimentKey();
149+
}
150+
151+
// create new experiment and overwrite curve
152+
try (ApiExperiment apiExperiment = ExperimentBuilder.ApiExperiment()
153+
.withExistingExperimentKey(experimentKey).withApiKey(API_KEY).build()) {
145154
// overwrite created curve with bigger ones
146155
//
147-
curve = createCurve(fileName, pointsCount * 2);
156+
Curve curve = createCurve(fileName, pointsCount * 2);
148157
apiExperiment.logCurve(curve, true, SOME_FULL_CONTEXT);
149158

150-
assets = apiExperiment.getAssetList(CURVE.type());
159+
List<LoggedExperimentAsset> assets = apiExperiment.getAssetList(CURVE.type());
151160
assertEquals(1, assets.size(), "wrong number of assets returned");
152161

153162
long newSize = assets.get(0).getSize().orElse((long) -1);

0 commit comments

Comments
 (0)