Skip to content

Commit

Permalink
update test to pass on Windows 11 (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
creativeprojects authored Apr 6, 2024
1 parent a05ad39 commit e6eed3d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
33 changes: 22 additions & 11 deletions docs/content/configuration/priority.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: "Priority"
tags: ["v0.27.0"]
weight: 35
---

Expand All @@ -11,18 +12,27 @@ You can lower the priority of restic to avoid slowing down other processes. This

You can use these values for the `priority` parameter:

| String value | "nice" equivalent on unixes |
|-------|-------------------|
| Idle | 19 |
| Background | 15 |
| Low | 10 |
| Normal | 0 |
| High | -10 |
| Highest | -20 |
| String value | "nice" equivalent on unixes | Notes |
|--------------|-----------------------------|------|
| Idle | 19 | |
| Background [^background] | 15 | **This mode is NOT recommended on Windows 11 [^background]** |
| Low | 10 | |
| Normal | 0 | Default priority when unspecified |
| High | -10 | |
| Highest | -20 | |

[^background]: It seems that the implementation of the background mode is broken in Windows 11. Even though undocumented, it is widely reported that the process has a limit of 32MB of memory. Please use `Idle` or `Low` on Windows 11.

## IO Nice

This setting is only available on Linux. It allows you to set the IO priority of restic.
This setting is only available on Linux. It allows you to set the disks IO priority of restic.

{{% notice style="info" %}}

This setting is only affecting access to local disks. It has no effect on any network access.

{{% /notice %}}

More information about ionice "class" and "level" can be found [here](https://linux.die.net/man/1/ionice).

## Examples
Expand Down Expand Up @@ -76,15 +86,16 @@ global {

## Warnings

In some cases, resticprofile will not be able to set the priority of restic.
In some cases (mostly before version `v0.27.0`), resticprofile won't be able to set the priority of restic.

A warning message like this will be displayed:

```
cannot set process group priority, restic will run with the default priority: operation not permitted
```

This usually means:
This either means:
- resticprofile is running inside docker
- you are using a tight security linux distribution which is launching every process inside a new container
- resticprofile is running in WSL
- you're running an older version of resticprofile (< `v0.27.0`)
8 changes: 3 additions & 5 deletions priority/prority_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import (
)

func TestStartProcessWithPriority(t *testing.T) {

// Run these 3 tests inside one test, so we don't have any concurrency issue
t.Run("WithNormalPriority", func(t *testing.T) {
err := SetClass(Normal)
if err != nil {
Expand Down Expand Up @@ -52,8 +50,8 @@ func TestStartProcessWithPriority(t *testing.T) {
})
time.Sleep(30 * time.Millisecond)

t.Run("WithBackgroundPriority", func(t *testing.T) {
err := SetClass(Background)
t.Run("WithIdlePriority", func(t *testing.T) {
err := SetClass(Idle)
if err != nil {
t.Error(err)
}
Expand All @@ -66,7 +64,7 @@ func TestStartProcessWithPriority(t *testing.T) {
if platform.IsWindows() {
assert.Contains(t, output, "Priority class: IDLE")
} else {
assert.Contains(t, output, "Process Priority: 15")
assert.Contains(t, output, "Process Priority: 19")
}
})
time.Sleep(30 * time.Millisecond)
Expand Down

0 comments on commit e6eed3d

Please sign in to comment.