Skip to content

Commit

Permalink
RUM-988 Implement the SR payloads update gradle task
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusc83 committed Sep 5, 2023
1 parent 1dfff18 commit 7fe45a8
Show file tree
Hide file tree
Showing 28 changed files with 237 additions and 1,648 deletions.
10 changes: 10 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,16 @@ Because we sometimes need to reuse some setup or assertions in our tests, we ten

### Nightly Tests

### Update Session Replay functional tests payloads

Session Replay has a suite of functional tests which can be found in the `instrumentation:integration` module.
Those tests are assessing the recorded payload for a specific scenario against a given payload from `assets/session_replay_payloads` in the `androidTest` source set.
In case you need to update these payloads given a change in the SDK, you can run the following command:

```shell
./gradlew :instrumented:integration:srPayloadUpdate
```

#### Implementation

Each public API method in the SDK is covered by a test case in the `nightly-tests` module. All test cases are executed on a Bitrise emulator by a Datadog Synthetic Test every 12 hours. Each test case
Expand Down
4 changes: 4 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ gradlePlugin {
id = "transitiveDependencies" // the alias
implementationClass = "com.datadog.gradle.plugin.transdeps.TransitiveDependenciesPlugin"
}
register("srPayloadUpdate") {
id = "srPayloadUpdate" // the alias
implementationClass = "com.datadog.gradle.plugin.srpayloadupdate.SrPayloadUpdatePlugin"
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.gradle.plugin.srpayloadupdate

import org.gradle.api.tasks.Exec

open class SrPayloadCreateTask : Exec() {

init {
group = "datadog"
description = "Update the Session Replay integration tests payloads"
setCommandLine(
"adb", "shell", "am", "instrument", "-w", "-r",
"-e", "debug", "false",
"-e", "updateSrPayloads", "true",
"-e", "package", "com.datadog.android.sdk.integration.sessionreplay",
"com.datadog.android.sdk.integration.test/androidx.test.runner.AndroidJUnitRunner"
)
}

override fun exec() {
println("Executing command: ${commandLine.joinToString(" ")}")
super.exec()
}

companion object {
const val TASK_NAME = "srPayloadCreate"
const val SR_PAYLOADS_FOLDER = ""
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.gradle.plugin.srpayloadupdate

import org.gradle.api.tasks.Exec
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.OutputDirectory

open class SrPayloadOverrideTask : Exec() {

@OutputDirectory
val payloadUpdateDirectory = project.file("./src/androidTest/assets/session_replay_payloads/")

@Suppress("MaxLineLength")
@Input
val payloadInputDirectoryPath: String = "storage/emulated/0/Android/data/com.datadog.android.sdk.integration/cache/session_replay_payloads/."

init {
group = "datadog"
description = "Override the Session Replay integration tests payloads"
setCommandLine(
"adb",
"pull",
payloadInputDirectoryPath,
payloadUpdateDirectory.absolutePath
)
}

companion object {
const val TASK_NAME = "srPayloadUpdate"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/

package com.datadog.gradle.plugin.srpayloadupdate

import org.gradle.api.Plugin
import org.gradle.api.Project

class SrPayloadUpdatePlugin : Plugin<Project> {

override fun apply(target: Project) {
target.tasks.register(SrPayloadCreateTask.TASK_NAME, SrPayloadCreateTask::class.java) {
dependsOn(
"assembleDebug",
"installDebug",
"assembleDebugAndroidTest",
"installDebugAndroidTest"
)
mustRunAfter("installDebugAndroidTest")
}
target.tasks.register(SrPayloadOverrideTask.TASK_NAME, SrPayloadOverrideTask::class.java) {
dependsOn(SrPayloadCreateTask.TASK_NAME)
mustRunAfter(SrPayloadCreateTask.TASK_NAME)
// make sure this task is always out - of - date
outputs.upToDateWhen { false }
}
}
}
1 change: 1 addition & 0 deletions instrumented/integration/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import com.datadog.gradle.config.kotlinConfig
plugins {
id("com.android.application")
kotlin("android")
id("srPayloadUpdate")
}

android {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":4,"data":{"width":411,"height":914}}, {"type":6,"data":{"has_focus":true}}, {"type":10,"data":{"wireframes":[{"width":411,"height":914,"shapeStyle":{"backgroundColor":"#303030ff","opacity":1.0},"type":"shape"},{"width":172,"height":19,"type":"text","text":"Welcome to Session Replay","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#00ddffff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":88,"height":48,"border":{"color":"#000000ff","width":1},"type":"text","text":"Click Me","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":14,"bottom":14,"left":11,"right":11},"alignment":{"horizontal":"center","vertical":"center"}}},{"width":411,"height":56,"type":"placeholder","label":"Toolbar"}]}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":4,"data":{"width":411,"height":914}}, {"type":6,"data":{"has_focus":true}}, {"type":10,"data":{"wireframes":[{"width":411,"height":914,"shapeStyle":{"backgroundColor":"#303030ff","opacity":1.0},"type":"shape"},{"width":395,"height":19,"type":"text","text":"Default Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#a538afff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":19,"type":"text","text":"Material Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#cc0000ff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":19,"type":"text","text":"App Compat Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":44,"type":"text","text":"Edit Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"Default Auto Complete Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#ffbb33ff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"App Compat Edit Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#ffbb33ff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"App Compat Auto Complete Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"Material Auto Complete Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":32,"type":"text","text":"Checked Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":0,"bottom":12,"left":0,"right":32},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":19,"height":19,"border":{"color":"#ffffffff","width":1},"type":"shape"},{"width":395,"height":32,"type":"text","text":"App Compat Checked Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":0,"bottom":12,"left":0,"right":32},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":19,"height":19,"shapeStyle":{"backgroundColor":"#ffffffff","opacity":1.0},"border":{"color":"#ffffffff","width":1},"type":"shape"},{"width":411,"height":56,"type":"placeholder","label":"Toolbar"}]}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":4,"data":{"width":411,"height":914}}, {"type":6,"data":{"has_focus":true}}, {"type":10,"data":{"wireframes":[{"width":411,"height":914,"shapeStyle":{"backgroundColor":"#303030ff","opacity":1.0},"type":"shape"},{"width":395,"height":19,"type":"text","text":"xxxxxxx xxxx xxxx","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#a538afff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":19,"type":"text","text":"xxxxxxxx xxxx xxxx","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#cc0000ff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":19,"type":"text","text":"xxx xxxxxx xxxx xxxx","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":44,"type":"text","text":"***","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"***","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#ffbb33ff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"***","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#ffbb33ff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"***","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"***","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":32,"type":"text","text":"xxxxxxx xxxx xxxx","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":0,"bottom":12,"left":0,"right":32},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":19,"height":19,"border":{"color":"#ffffffff","width":1},"type":"shape"},{"width":395,"height":32,"type":"text","text":"xxx xxxxxx xxxxxxx xxxx xxxx","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":0,"bottom":12,"left":0,"right":32},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":19,"height":19,"border":{"color":"#ffffffff","width":1},"type":"shape"},{"width":411,"height":56,"type":"placeholder","label":"Toolbar"}]}}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{"type":4,"data":{"width":411,"height":914}}, {"type":6,"data":{"has_focus":true}}, {"type":10,"data":{"wireframes":[{"width":411,"height":914,"shapeStyle":{"backgroundColor":"#303030ff","opacity":1.0},"type":"shape"},{"width":395,"height":19,"type":"text","text":"Default Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#a538afff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":19,"type":"text","text":"Material Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#cc0000ff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":19,"type":"text","text":"App Compat Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":0,"bottom":0,"left":0,"right":0},"alignment":{"horizontal":"left","vertical":"top"}}},{"width":395,"height":44,"type":"text","text":"Edit Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"Default Auto Complete Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#ffbb33ff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"App Compat Edit Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#ffbb33ff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#ffbb33ff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"App Compat Auto Complete Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":44,"type":"text","text":"Material Auto Complete Text View","textStyle":{"family":"roboto, sans-serif","size":17,"color":"#a538afff"},"textPosition":{"padding":{"top":9,"bottom":11,"left":3,"right":3},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":395,"height":1,"shapeStyle":{"backgroundColor":"#a538afff","opacity":1.0},"type":"shape"},{"width":395,"height":32,"type":"text","text":"Checked Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":0,"bottom":12,"left":0,"right":32},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":19,"height":19,"border":{"color":"#ffffffff","width":1},"type":"shape"},{"width":395,"height":32,"type":"text","text":"App Compat Checked Text View","textStyle":{"family":"roboto, sans-serif","size":14,"color":"#ffffffff"},"textPosition":{"padding":{"top":0,"bottom":12,"left":0,"right":32},"alignment":{"horizontal":"left","vertical":"center"}}},{"width":19,"height":19,"border":{"color":"#ffffffff","width":1},"type":"shape"},{"width":411,"height":56,"type":"placeholder","label":"Toolbar"}]}}]
Loading

0 comments on commit 7fe45a8

Please sign in to comment.