-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* List clusters by project * Retry IOExceptions from Sam * PR feedback * Fix IOException retry condition
- Loading branch information
Showing
9 changed files
with
193 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ trait CommonTestData{ this: ScalaFutures => | |
val name2 = ClusterName("clustername2") | ||
val name3 = ClusterName("clustername3") | ||
val project = GoogleProject("dsp-leo-test") | ||
val project2 = GoogleProject("dsp-leo-test-2") | ||
val userEmail = WorkbenchEmail("[email protected]") | ||
val userInfo = UserInfo(OAuth2BearerToken("accessToken"), WorkbenchUserId("user1"), userEmail, 0) | ||
val serviceAccountEmail = WorkbenchEmail("[email protected]") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ class LeoRoutesSpec extends FlatSpec with ScalatestRouteTest with CommonTestData | |
implicit val timeout = RouteTestTimeout(5.seconds dilated) | ||
|
||
private val googleProject = GoogleProject("test-project") | ||
private val googleProject2 = GoogleProject("test-project2") | ||
private val clusterName = ClusterName("test-cluster") | ||
|
||
val invalidUserLeoRoutes = new LeoRoutes(leonardoService, proxyService, statusService, swaggerConfig) with MockUserInfoDirectives { | ||
|
@@ -222,6 +223,72 @@ class LeoRoutesSpec extends FlatSpec with ScalatestRouteTest with CommonTestData | |
} | ||
} | ||
|
||
it should "list clusters by project" in isolatedDbTest { | ||
val newCluster = ClusterRequest(Map.empty, None) | ||
|
||
// listClusters should return no clusters initially | ||
Get(s"/api/clusters/${googleProject.value}") ~> timedLeoRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
val responseClusters = responseAs[List[Cluster]] | ||
responseClusters shouldBe List.empty[Cluster] | ||
} | ||
|
||
Get(s"/api/clusters/${googleProject2.value}") ~> timedLeoRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
val responseClusters = responseAs[List[Cluster]] | ||
responseClusters shouldBe List.empty[Cluster] | ||
} | ||
|
||
|
||
for (i <- 1 to 5) { | ||
Put(s"/api/cluster/${googleProject.value}/${clusterName.value}-$i", newCluster.toJson) ~> leoRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
} | ||
} | ||
|
||
for (i <- 6 to 10) { | ||
Put(s"/api/cluster/v2/${googleProject2.value}/${clusterName.value}-$i", newCluster.toJson) ~> leoRoutes.route ~> check { | ||
status shouldEqual StatusCodes.Accepted | ||
} | ||
} | ||
|
||
Get(s"/api/clusters/${googleProject.value}") ~> timedLeoRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
|
||
val responseClusters = responseAs[List[Cluster]] | ||
responseClusters should have size 5 | ||
responseClusters foreach { cluster => | ||
cluster.googleProject shouldEqual googleProject | ||
cluster.serviceAccountInfo.clusterServiceAccount shouldEqual clusterServiceAccount(googleProject) | ||
cluster.serviceAccountInfo.notebookServiceAccount shouldEqual notebookServiceAccount(googleProject) | ||
cluster.labels shouldEqual Map( | ||
"clusterName" -> cluster.clusterName.value, | ||
"creator" -> "[email protected]", | ||
"googleProject" -> googleProject.value) ++ serviceAccountLabels | ||
} | ||
|
||
validateCookie { header[`Set-Cookie`] } | ||
} | ||
|
||
Get(s"/api/clusters/${googleProject2.value}") ~> timedLeoRoutes.route ~> check { | ||
status shouldEqual StatusCodes.OK | ||
|
||
val responseClusters = responseAs[List[Cluster]] | ||
responseClusters should have size 5 | ||
responseClusters foreach { cluster => | ||
cluster.googleProject shouldEqual googleProject2 | ||
cluster.serviceAccountInfo.clusterServiceAccount shouldEqual clusterServiceAccount(googleProject2) | ||
cluster.serviceAccountInfo.notebookServiceAccount shouldEqual notebookServiceAccount(googleProject2) | ||
cluster.labels shouldEqual Map( | ||
"clusterName" -> cluster.clusterName.value, | ||
"creator" -> "[email protected]", | ||
"googleProject" -> googleProject2.value) ++ serviceAccountLabels | ||
} | ||
|
||
validateCookie { header[`Set-Cookie`] } | ||
} | ||
} | ||
|
||
it should "202 when stopping and starting a cluster" in isolatedDbTest { | ||
val newCluster = ClusterRequest(Map.empty, None) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters