aglinxinyuan commented on code in PR #4566: URL: https://github.com/apache/texera/pull/4566#discussion_r3171185324
########## amber/src/test/scala/org/apache/texera/amber/engine/architecture/scheduling/SchedulingUtilsSpec.scala: ########## @@ -0,0 +1,140 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.apache.texera.amber.engine.architecture.scheduling + +import org.apache.texera.amber.core.executor.OpExecInitInfo +import org.apache.texera.amber.core.virtualidentity.{ + ExecutionIdentity, + OperatorIdentity, + PhysicalOpIdentity, + WorkflowIdentity +} +import org.apache.texera.amber.core.workflow.PhysicalOp +import org.jgrapht.graph.DirectedAcyclicGraph +import org.scalatest.flatspec.AnyFlatSpec + +import scala.jdk.CollectionConverters.CollectionHasAsScala + +class SchedulingUtilsSpec extends AnyFlatSpec { + + private def region(regionId: Long, opId: String): Region = { + val physicalOp = PhysicalOp( + PhysicalOpIdentity(OperatorIdentity(opId), "main"), + WorkflowIdentity(0), + ExecutionIdentity(0), + OpExecInitInfo.Empty + ) + Region(RegionIdentity(regionId), Set(physicalOp), Set.empty) + } + + private def newGraph(): DirectedAcyclicGraph[Region, RegionLink] = + new DirectedAcyclicGraph[Region, RegionLink](classOf[RegionLink]) + + "SchedulingUtils.replaceVertex" should "replace an isolated vertex with no incident edges" in { + val graph = newGraph() + val oldVertex = region(1, "a") + val newVertex = region(1, "a-prime") + graph.addVertex(oldVertex) + + SchedulingUtils.replaceVertex(graph, oldVertex, newVertex) + + assert(!graph.containsVertex(oldVertex)) + assert(graph.containsVertex(newVertex)) + assert(graph.edgeSet().isEmpty) + } Review Comment: noted as TODO in code comment. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
