private def waitForTableToBecomeAvailable()

in src/it/scala/com/gu/kinesis/KinesisResourceManager.scala [155:174]


  private def waitForTableToBecomeAvailable(tableName: String, dynamoDb: DynamoDbClient): Unit = {
    println("Waiting for " + tableName + " to become ACTIVE...")
    val startTime = System.currentTimeMillis
    val endTime = startTime + 10.minutes.toMillis
    while ({ System.currentTimeMillis < endTime }) {
      Thread.sleep(20.seconds.toMillis)
      try {
        val table = dynamoDb
          .describeTable(DescribeTableRequest.builder().tableName(tableName).build())
          .table()
        val tableStatus = table.tableStatus()
        if (tableStatus == TableStatus.ACTIVE) return
      } catch {
        case ase: AmazonServiceException =>
          if (!ase.getErrorCode.equalsIgnoreCase("ResourceNotFoundException"))
            throw ase
      }
    }
    throw new RuntimeException("Table " + tableName + " never went active")
  }