Skip to content

Commit

Permalink
change production protocol to v1_33.0 (#2452)
Browse files Browse the repository at this point in the history
* change production protocol to v1_33.0

* update test with new protocol version

* fixing test

* make sure all tests use protocol constant

* fixing tests

* Update TestSDLCLoader.java

* fixing checkstyle
  • Loading branch information
elopezcastro authored Nov 10, 2023
1 parent f5cfc42 commit 2152c27
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ public class TestSDLCLoader

private static final MockTracer tracer = new MockTracer();

private static final String CLIENT_VERSION = "v1_33_0";

@BeforeClass
public static void setUpClass()
{
Expand Down Expand Up @@ -85,7 +87,7 @@ public void testSdlcLoaderRetriesOnSomeHttpResponses() throws Exception
configureWireMockForRetries();
SDLCLoader sdlcLoader = createSDLCLoader();

PureModelContextData pmcdLoaded = sdlcLoader.load(Lists.fixedSize.empty(), pointer, "v1_32_0", tracer.activeSpan());
PureModelContextData pmcdLoaded = sdlcLoader.load(Lists.fixedSize.empty(), pointer, CLIENT_VERSION, tracer.activeSpan());
Assert.assertNotNull(pmcdLoaded);

Object tries = tracer.finishedSpans()
Expand All @@ -109,7 +111,7 @@ public void testSdlcLoaderDoesNotRetryOnHardFailures() throws Exception

try
{
sdlcLoader.load(Lists.fixedSize.empty(), pointer, "v1_32_0", tracer.activeSpan());
sdlcLoader.load(Lists.fixedSize.empty(), pointer, CLIENT_VERSION, tracer.activeSpan());
Assert.fail("Should throw");
}
catch (EngineException e)
Expand All @@ -131,7 +133,7 @@ public void testSdlcLoaderForWorkspacesWithoutDependency() throws Exception

configureWireMockForRetries();
SDLCLoader sdlcLoader = createSDLCLoader();
PureModelContextData pmcdLoaded = sdlcLoader.load(Lists.fixedSize.empty(), pointer, "v1_32_0", tracer.activeSpan());
PureModelContextData pmcdLoaded = sdlcLoader.load(Lists.fixedSize.empty(), pointer, CLIENT_VERSION, tracer.activeSpan());
Assert.assertNotNull(pmcdLoaded);
Assert.assertEquals(1, pmcdLoaded.getElements().size());
Assert.assertEquals("pkg::pkg::myClass", pmcdLoaded.getElements().get(0).getPath());
Expand All @@ -153,7 +155,7 @@ public void testSdlcLoaderForWorkspacesWithDependency() throws Exception

ModelManager modelManager = new ModelManager(DeploymentMode.TEST, tracer, sdlcLoader);

PureModelContextData pmcdLoaded = modelManager.loadData(pointer, "v1_32_0", Lists.fixedSize.empty());
PureModelContextData pmcdLoaded = modelManager.loadData(pointer, CLIENT_VERSION, Lists.fixedSize.empty());

Assert.assertNotNull(pmcdLoaded);
Assert.assertEquals(2, pmcdLoaded.getElements().size());
Expand Down Expand Up @@ -204,19 +206,19 @@ private static void configureWireMockForRetries() throws JsonProcessingException
PureModelContextData data = PureModelContextData.newPureModelContextData(new Protocol(), new PureModelContextPointer(), Lists.fixedSize.empty());
String pmcdJson = objectMapper.writeValueAsString(data);

WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=v1_32_0")
WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=" + CLIENT_VERSION)
.inScenario("RETRY_FAILURES")
.whenScenarioStateIs(Scenario.STARTED)
.willReturn(WireMock.aResponse().withStatus(503).withBody("a failure"))
.willSetStateTo("FAILED_1"));

WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=v1_32_0")
WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=" + CLIENT_VERSION)
.inScenario("RETRY_FAILURES")
.whenScenarioStateIs("FAILED_1")
.willReturn(WireMock.aResponse().withStatus(503).withBody("a failure"))
.willSetStateTo("FAILED_2"));

WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=v1_32_0")
WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=" + CLIENT_VERSION)
.inScenario("RETRY_FAILURES")
.whenScenarioStateIs("FAILED_2")
.willReturn(WireMock.okJson(pmcdJson))
Expand Down Expand Up @@ -247,13 +249,13 @@ private static void configureWireMockForRetries() throws JsonProcessingException
WireMock.stubFor(WireMock.get("/sdlc/api/projects/proj-1235/workspaces/workspaceAbc/revisions/HEAD/upstreamProjects")
.willReturn(WireMock.okJson("[{\"projectId\": \"org.finos.legend.dependency:models\",\"versionId\": \"2.0.1\"}]")));

WireMock.stubFor(WireMock.get("/alloy/projects/org.finos.legend.dependency/models/versions/2.0.1/pureModelContextData?clientVersion=v1_32_0")
WireMock.stubFor(WireMock.get("/alloy/projects/org.finos.legend.dependency/models/versions/2.0.1/pureModelContextData?clientVersion=" + CLIENT_VERSION)
.willReturn(WireMock.okJson(pmcdJsonDep)));
}

private static void configureWireMockForNoRetries() throws JsonProcessingException
{
WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=v1_32_0")
WireMock.stubFor(WireMock.get("/alloy/projects/groupId/artifactId/versions/1.0.0/pureModelContextData?clientVersion=" + CLIENT_VERSION)
.willReturn(WireMock.aResponse().withStatus(400).withBody("a failure")));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class PureClientVersions
assert !hasRepeatedVersions(versions) : "Repeated version id :" + versions.toBag().selectByOccurrences(i -> i > 1).toSet().makeString("[", ", ", "]");
}

public static String production = "v1_32_0";
public static String production = "v1_33_0";

static boolean hasRepeatedVersions(ImmutableList<String> versions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@ public class TestProtocolUpdates
public void testProductionProtocolVersion()
{
String productionProtocolVersion = PureClientVersions.production;
Assert.assertEquals("v1_32_0", productionProtocolVersion);
Assert.assertEquals("v1_33_0", productionProtocolVersion);
}
}

0 comments on commit 2152c27

Please sign in to comment.