Skip to content

Commit

Permalink
Merge pull request #243 from guardian/longer-catalog-timeout
Browse files Browse the repository at this point in the history
extend Zuora Catalog timeout
  • Loading branch information
johnduffell committed Jan 10, 2019
2 parents b0db129 + afadad9 commit 60efe86
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class EmailBatchTest extends FlatSpec {
}

"EmailBatch.fromWire" should "throw a jsresult exception when a required field is missing" in {
val sampleBatch =
val sampleBatch =
"""
|{
| "batch_items":
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.gu.catalogService

import com.amazonaws.services.s3.model.{PutObjectRequest, PutObjectResult}
import com.gu.effects.{GetFromS3, RawEffects}
import com.gu.effects.{GetFromS3, Http, RawEffects}
import com.gu.util.Logging
import com.gu.util.config.LoadConfigModule.StringFromS3
import com.gu.util.config.{LoadConfigModule, Stage, ZuoraEnvironment}
Expand All @@ -14,7 +14,13 @@ object Handler extends Logging {
// this is the entry point
// it's referenced by the cloudformation so make sure you keep it in step
def apply(): Unit = {
runWithEffects(RawEffects.response, RawEffects.stage, RawEffects.zuoraEnvironment, GetFromS3.fetchString, RawEffects.s3Write)
runWithEffects(
Http.responseWithTimeout(120),
RawEffects.stage,
RawEffects.zuoraEnvironment,
GetFromS3.fetchString,
RawEffects.s3Write
)
}

// this does the wiring except side effects but not any decisions, so can be used for an end to end test
Expand All @@ -29,7 +35,7 @@ object Handler extends Logging {
zuoraRestConfig <- LoadConfigModule(zuoraEnvironment.stageToLoad, fetchString)[ZuoraRestConfig].leftMap(_.error)
zuoraRequests = ZuoraRestRequestMaker(response, zuoraRestConfig)
fetchCatalogAttempt <- ZuoraReadCatalog(zuoraRequests).toDisjunction.leftMap(_.message)
uploadCatalogAttempt <- S3UploadCatalog(stage, zuoraEnvironment, fetchCatalogAttempt, s3Write)
_ <- S3UploadCatalog(stage, zuoraEnvironment, fetchCatalogAttempt, s3Write)
} yield ()
attempt.fold(failureReason => throw CatalogServiceException(failureReason), identity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.scalatest.{FlatSpec, Matchers}

import scala.util.{Success, Try}

class S3UploadFileTest extends FlatSpec with Matchers{
class S3UploadFileTest extends FlatSpec with Matchers {
val testPath = S3Path(BucketName("someBucket"), None)
val testFile = File(FileName("someName"), FileContent("these are the file contents"))
val successS3Result = Success(new PutObjectResult())
Expand Down
6 changes: 4 additions & 2 deletions lib/effects/src/main/scala/com/gu/effects/Http.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ import okio.Buffer

object Http extends Logging {

val response: Request => Response = {
val response: Request => Response = responseWithTimeout(15)

def responseWithTimeout(timeout: Int): Request => Response = {
val restClient = new OkHttpClient().newBuilder()
.readTimeout(15, TimeUnit.SECONDS)
.readTimeout(timeout, TimeUnit.SECONDS)
.build()

def bodySummary(requestBody: RequestBody) = {
Expand Down

0 comments on commit 60efe86

Please sign in to comment.