mirror of
https://github.com/SlimeVR/SlimeVR-Server.git
synced 2026-11-24 02:51:20 -08:00
Added tests, Added checksums.
This commit is contained in:
1 parent
2fa949d156
commit
ca499d33be
7 files changed
+62
-20
No files matched your search
+1
-1
Submodule solarxr-protocol updated: b629d120c6...3ffd218a83.
@@ -13,10 +13,10 @@ class Linux(
|
||||
|
||||
private val path = Paths.get("").toAbsolutePath().toString()
|
||||
|
||||
suspend fun updateLinux(currentVersionTag: String, versionTag: String, configDir: String, vrConfig: String, serverUrl: String, openVRDriverUrl: String) {
|
||||
suspend fun updateLinux(currentVersionTag: String, versionTag: String, configDir: String, vrConfig: String, serverUrl: String, serverChecksum: String, openVRDriverUrl: String) {
|
||||
backupConfig(currentVersionTag, configDir, vrConfig)
|
||||
restoreConfig(versionTag, configDir, vrConfig)
|
||||
updateServer(serverUrl)
|
||||
updateServer(serverUrl, serverChecksum)
|
||||
updateLinuxSteamVRDriver(openVRDriverUrl)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ class Linux(
|
||||
}
|
||||
TerminalUtil.info("Downloading SteamVR Driver")
|
||||
|
||||
io.downloadFile(openVRDriverUrl, LINUXSTEAMVRDRIVERNAME)
|
||||
io.downloadFile(openVRDriverUrl, LINUXSTEAMVRDRIVERNAME, "")
|
||||
|
||||
state.update {
|
||||
subText = "Unzipping SteamVR Driver"
|
||||
@@ -125,7 +125,7 @@ class Linux(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateServer(serverUrl: String) {
|
||||
suspend fun updateServer(serverUrl: String, serverChecksum: String) {
|
||||
TerminalUtil.info("Updating server")
|
||||
state.update {
|
||||
statusText = "Updating Server"
|
||||
@@ -137,7 +137,7 @@ class Linux(
|
||||
subText = "Downloading Server"
|
||||
}
|
||||
TerminalUtil.info("Downloading server")
|
||||
io.downloadFile(serverUrl, LINUXSERVERNAME)
|
||||
io.downloadFile(serverUrl, LINUXSERVERNAME, serverChecksum)
|
||||
|
||||
state.update {
|
||||
subProgress = 1f
|
||||
@@ -149,6 +149,7 @@ class Linux(
|
||||
val command = listOf("chmod", "+x", LINUXSERVERNAME)
|
||||
|
||||
//TerminalUtil.info(io.executeShellCommand("chmod +x ${LINUXSERVERNAME}"))
|
||||
io.unzip("slimevr-openvr-driver-x64-linux.zip")
|
||||
}
|
||||
|
||||
// Legacy
|
||||
@@ -157,7 +158,7 @@ class Linux(
|
||||
statusText = "Downloading Feeder App"
|
||||
}
|
||||
|
||||
io.downloadFile(LINUXFEEDERURL, LINUXFEEDERNAME)
|
||||
io.downloadFile(LINUXFEEDERURL, LINUXFEEDERNAME, "")
|
||||
|
||||
state.update {
|
||||
statusText = "Unzipping Feeder App"
|
||||
|
||||
@@ -71,8 +71,10 @@ class Updater(
|
||||
}
|
||||
state.versionTag = selectedVersion.version
|
||||
|
||||
|
||||
when (os.currentPlatform) {
|
||||
OperatingSystem.WINDOWS -> {
|
||||
//TODO: Change back to windows, for testing only
|
||||
OperatingSystem.LINUX -> {
|
||||
val windows = Windows(state, updaterIO)
|
||||
windows.updateWindows(
|
||||
currentVersionTag,
|
||||
@@ -80,11 +82,12 @@ class Updater(
|
||||
configDir,
|
||||
vrConfig,
|
||||
selectedVersion.url,
|
||||
selectedVersion.checksum,
|
||||
"https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-win64.zip"
|
||||
)
|
||||
}
|
||||
|
||||
OperatingSystem.LINUX -> {
|
||||
OperatingSystem.WINDOWS -> {
|
||||
val linux = Linux(state, updaterIO)
|
||||
linux.updateLinux(
|
||||
currentVersionTag,
|
||||
@@ -92,6 +95,7 @@ class Updater(
|
||||
configDir,
|
||||
vrConfig,
|
||||
selectedVersion.url,
|
||||
selectedVersion.checksum,
|
||||
"https://github.com/SlimeVR/SlimeVR-OpenVR-Driver/releases/latest/download/slimevr-openvr-driver-x64-linux.zip"
|
||||
)
|
||||
}
|
||||
@@ -113,6 +117,7 @@ class Updater(
|
||||
if (featureFlags.restartServer) {
|
||||
launchServer()
|
||||
}
|
||||
exitProcess(0)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -157,7 +162,13 @@ class Updater(
|
||||
}
|
||||
|
||||
companion object {
|
||||
val CDN = "http://127.0.0.1:8080"
|
||||
const val CDN = "http://127.0.0.1:3000"
|
||||
//val CDN = "https://updates.slimevr.io"
|
||||
const val CDN_RELEASES = "$CDN/releases"
|
||||
const val CDN_VERSIONS = "$CDN/versions"
|
||||
const val CDN_CHANNELS = "$CDN/channels"
|
||||
const val CDN_DOWNLOAD = "$CDN/download"
|
||||
|
||||
fun launchServer() {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package dev.slimevr.updater
|
||||
|
||||
import dev.slimevr.updater.Updater.Companion.CDN_RELEASES
|
||||
import io.ktor.client.HttpClient
|
||||
import io.ktor.client.call.body
|
||||
import io.ktor.client.engine.cio.CIO
|
||||
@@ -64,13 +65,14 @@ class UpdaterIO(
|
||||
})
|
||||
}
|
||||
}
|
||||
val releases: List<Release> = client.get("http://localhost:3000/releases").body()
|
||||
TerminalUtil.info(CDN_RELEASES)
|
||||
val releases: List<Release> = client.get(CDN_RELEASES).body()
|
||||
|
||||
return releases
|
||||
}
|
||||
|
||||
|
||||
suspend fun downloadFile(fileUrl: String, fileName: String, checksum: String = "") {
|
||||
suspend fun downloadFile(fileUrl: String, fileName: String, checksum: String) {
|
||||
state.subProgress = 0f
|
||||
val targetFile = File(fileName)
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ class Windows(
|
||||
|
||||
private val path = Paths.get("").toAbsolutePath().toString()
|
||||
|
||||
suspend fun updateWindows(currentVersionTag: String, versionTag: String, configDir: String, vrConfig: String, serverUrl: String, openVRDriverUrl: String) {
|
||||
suspend fun updateWindows(currentVersionTag: String, versionTag: String, configDir: String, vrConfig: String, serverUrl: String, serverChecksum: String, openVRDriverUrl: String) {
|
||||
backupConfig(currentVersionTag, configDir, vrConfig)
|
||||
restoreConfig(versionTag, configDir, vrConfig)
|
||||
updateServer(serverUrl)
|
||||
updateServer(serverUrl, serverChecksum)
|
||||
usbDrivers()
|
||||
steamVRDriver()
|
||||
}
|
||||
@@ -52,7 +52,7 @@ class Windows(
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun updateServer(serverUrl: String) {
|
||||
suspend fun updateServer(serverUrl: String, serverChecksum: String) {
|
||||
println("downloading server")
|
||||
state.update {
|
||||
statusText = "Updating SlimeVR"
|
||||
@@ -63,7 +63,7 @@ class Windows(
|
||||
statusText = "Downloading Server"
|
||||
}
|
||||
|
||||
io.downloadFile(serverUrl, WINDOWSSERVERNAME)
|
||||
io.downloadFile(serverUrl, WINDOWSSERVERNAME, serverChecksum)
|
||||
|
||||
state.update {
|
||||
subProgress = 1f
|
||||
@@ -110,6 +110,7 @@ class Windows(
|
||||
io.downloadFile(
|
||||
WINDOWSFEEDERURL,
|
||||
WINDOWSFEEDERNAME,
|
||||
""
|
||||
)
|
||||
|
||||
state.statusText = "Unzipping Feeder App"
|
||||
@@ -162,6 +163,7 @@ class Windows(
|
||||
io.downloadFile(
|
||||
WINDOWSSTEAMVRDRIVERURL,
|
||||
WINDOWSSTEAMVRDRIVERNAME,
|
||||
""
|
||||
)
|
||||
|
||||
state.statusText = "Unzipping SteamVR Driver"
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package dev.slimevr.updater
|
||||
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.runBlocking
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlinx.coroutines.withContext
|
||||
import kotlin.test.Test
|
||||
|
||||
class StressTest {
|
||||
|
||||
@Test
|
||||
fun `test multiple downloads`() {
|
||||
runBlocking {
|
||||
val safeDispatcher = Dispatchers.IO.limitedParallelism(50)
|
||||
withContext(safeDispatcher) {
|
||||
for (i in 1..50) {
|
||||
this.launch {
|
||||
val updateController = UpdaterController()
|
||||
TerminalUtil.info("Launching instance $i")
|
||||
updateController.startGui()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
package dev.slimevr.updater
|
||||
|
||||
import dev.slimevr.updater.ManifestUtils.Companion.getChannels
|
||||
import dev.slimevr.updater.ManifestUtils.Companion.getCurrentVersion
|
||||
import dev.slimevr.updater.ManifestUtils.Companion.getRelease
|
||||
import dev.slimevr.updater.ManifestUtils.Companion.getVersionTags
|
||||
import kotlinx.coroutines.test.runTest
|
||||
import kotlin.test.Test
|
||||
|
||||
/*
|
||||
class UpdaterTest {
|
||||
|
||||
@Test
|
||||
@@ -89,3 +86,5 @@ class UpdaterTest {
|
||||
fun updateToSpecificVersion() {
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
Reference in new issue
Block a user