Skip to content

Commit

Permalink
feat: add new image files for end-to-end testing of burst and upgrade…
Browse files Browse the repository at this point in the history
… low-quality scenarios
  • Loading branch information
simulot committed Mar 9, 2025
1 parent 4ba7c22 commit 00ea156
Show file tree
Hide file tree
Showing 66 changed files with 837 additions and 3 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions internal/e2eTests/tests/DATA/compress.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Define the source and destination directories
SOURCE_DIR="high_jpg"
DEST_DIR="low"

# Create the destination directory if it doesn't exist
mkdir -p "$DEST_DIR"

# Loop through all image files in the source directory
for IMAGE in "$SOURCE_DIR"/*; do
# Get the base name and extension of the image file
BASENAME=$(basename "$IMAGE")
EXTENSION="${BASENAME##*.}"
NAME="${BASENAME%.*}"

# Recompress the image with very bad quality and save it to the destination directory
convert "$IMAGE" -quality 10 "$DEST_DIR/$NAME".jpg
done

echo "Recompression complete. Recompressed images are saved in the 'low' subfolder."
19 changes: 19 additions & 0 deletions internal/e2eTests/tests/DATA/convert.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# file.sh

# Define the input and output folders
SOURCE_DIR="high"
DEST_DIR="high_jpg"


# Create the output folder if it doesn't exist
mkdir -p "$DEST_DIR"

# Iterate through all files in the input folder
for IMAGE in "$SOURCE_DIR"/*; do
BASENAME=$(basename "$IMAGE")
EXTENSION="${BASENAME##*.}"
NAME="${BASENAME%.*}"
convert "$IMAGE" "$DEST_DIR/$NAME".jpg
done

19 changes: 19 additions & 0 deletions internal/e2eTests/tests/DATA/convertHEIC.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
# file.sh

# Define the input and output folders
SOURCE_DIR="high"
DEST_DIR="high_heic"


# Create the output folder if it doesn't exist
mkdir -p "$DEST_DIR"

# Iterate through all files in the input folder
for IMAGE in "$SOURCE_DIR"/*; do
BASENAME=$(basename "$IMAGE")
EXTENSION="${BASENAME##*.}"
NAME="${BASENAME%.*}"
convert "$IMAGE" "$DEST_DIR/$NAME".HEIC
done

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions internal/e2eTests/tests/DATA/setTime.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

# Check if the correct number of arguments is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <timestamp>"
exit 1
fi

# Get the timestamp from the argument
timestamp="$1"

# Find all files in subfolders (excluding the current directory) and set their modified time
find . -mindepth 2 -type f -exec touch -d "$timestamp" {} \;

echo "All files in subfolders have been set to the modified time: $timestamp"
35 changes: 35 additions & 0 deletions internal/e2eTests/tests/DATA/stamp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# add_text_to_images.sh

# Check if the correct number of arguments is provided
if [ "$#" -ne 2 ]; then
echo "Usage: $0 <folder_path> <text>"
exit 1
fi

FOLDER_PATH=$1
TEXT=$2

# Check if the folder exists
if [ ! -d "$FOLDER_PATH" ]; then
echo "Folder $FOLDER_PATH does not exist."
exit 1
fi

# Create a temporary text image
TEXT_IMAGE="text_image.png"
convert -background none -fill white -pointsize 24 -gravity SouthEast label:"$TEXT" "$TEXT_IMAGE"

# Loop through each image in the folder
for IMAGE in "$FOLDER_PATH"/*; do
if [ -f "$IMAGE" ]; then
# Add text to the lower right part of the image
composite -gravity SouthEast "$TEXT_IMAGE" "$IMAGE" "$IMAGE"
echo "Processed $IMAGE"
fi
done

# Remove the temporary text image
rm "$TEXT_IMAGE"

echo "All images processed."
274 changes: 274 additions & 0 deletions internal/e2eTests/tests/burst_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
//go:build e2e

package tests

import (
"context"
"reflect"
"testing"

"github.com/simulot/immich-go/app/cmd"
"github.com/simulot/immich-go/internal/e2eTests/e2e"
"github.com/simulot/immich-go/internal/fileevent"
)

func TestBurstsFolders(t *testing.T) {
t.Run("camera burst raw+jpg, Stack", func(t *testing.T) {
const source = "DATA/bursts/jpg"
e2e.InitMyEnv()
e2e.ResetImmich(t)
// client, err := e2e.GetImmichClient()
// if err != nil {
// t.Fatal(err)
// return
// }

ctx := context.Background()
c, a := cmd.RootImmichGoCommand(ctx)
c.SetArgs([]string{
"upload", "from-folder",
"--server=" + e2e.MyEnv("IMMICHGO_SERVER"),
"--api-key=" + e2e.MyEnv("IMMICHGO_APIKEY"),
"--no-ui",
"--api-trace",
"--log-level=debug",
"--manage-burst=Stack",
source,
})
err := c.ExecuteContext(ctx)
if err != nil && a.Log().GetSLog() != nil {
a.Log().Error(err.Error())
}

if err != nil {
t.Error("Unexpected error", err)
return
}

e2e.CheckResults(t, map[fileevent.Code]int64{
fileevent.Uploaded: 11,
fileevent.Stacked: 7,
}, false, a.Jnl())

// sourceDir := e2e.ScanDirectory(t, source)
// serverAssets := e2e.ImmichScan(t, client)
// upFiles := e2e.ExtensionFilter(sourceDir, []string{".cr3"})
// if !reflect.DeepEqual(serverAssets, upFiles) {
// t.Error("Unexpected assets on server", serverAssets, "expected", upFiles)
// }
})
t.Run("camera burst raw+jpg Stack", func(t *testing.T) {
e2e.InitMyEnv()
e2e.ResetImmich(t)

ctx := context.Background()
c, a := cmd.RootImmichGoCommand(ctx)
c.SetArgs([]string{
"upload", "from-folder",
"--server=" + e2e.MyEnv("IMMICHGO_SERVER"),
"--api-key=" + e2e.MyEnv("IMMICHGO_APIKEY"),
"--no-ui",
"--api-trace",
"--log-level=debug",
"--manage-burst=Stack",
"DATA/bursts/raw-jpg",
})
err := c.ExecuteContext(ctx)
if err != nil && a.Log().GetSLog() != nil {
a.Log().Error(err.Error())
}

if err != nil {
t.Error("Unexpected error", err)
return
}

e2e.CheckResults(t, map[fileevent.Code]int64{
fileevent.Uploaded: 8,
fileevent.Stacked: 8,
}, false, a.Jnl())
})
t.Run("camera burst raw+jpg, stack StackKeepRaw", func(t *testing.T) {
const source = "DATA/bursts/raw-jpg"
e2e.InitMyEnv()
e2e.ResetImmich(t)
client, err := e2e.GetImmichClient()
if err != nil {
t.Fatal(err)
return
}

ctx := context.Background()
c, a := cmd.RootImmichGoCommand(ctx)
c.SetArgs([]string{
"upload", "from-folder",
"--server=" + e2e.MyEnv("IMMICHGO_SERVER"),
"--api-key=" + e2e.MyEnv("IMMICHGO_APIKEY"),
"--no-ui",
"--api-trace",
"--log-level=debug",
"--manage-burst=StackKeepRaw",
source,
})
err = c.ExecuteContext(ctx)
if err != nil && a.Log().GetSLog() != nil {
a.Log().Error(err.Error())
}

if err != nil {
t.Error("Unexpected error", err)
return
}

e2e.CheckResults(t, map[fileevent.Code]int64{
fileevent.Uploaded: 4,
fileevent.Stacked: 4,
fileevent.DiscoveredDiscarded: 4,
}, false, a.Jnl())

sourceDir := e2e.ScanDirectory(t, source)
serverAssets := e2e.ImmichScan(t, client)
upFiles := e2e.ExtensionFilter(sourceDir, []string{".cr3"})
if !reflect.DeepEqual(serverAssets, upFiles) {
t.Error("Unexpected assets on server", serverAssets, "expected", upFiles)
}
})

t.Run("camera burst raw+jpg, stack StackKeepJPEG", func(t *testing.T) {
const source = "DATA/bursts/raw-jpg"
e2e.InitMyEnv()
e2e.ResetImmich(t)
client, err := e2e.GetImmichClient()
if err != nil {
t.Fatal(err)
return
}

ctx := context.Background()
c, a := cmd.RootImmichGoCommand(ctx)
c.SetArgs([]string{
"upload", "from-folder",
"--server=" + e2e.MyEnv("IMMICHGO_SERVER"),
"--api-key=" + e2e.MyEnv("IMMICHGO_APIKEY"),
"--no-ui",
"--api-trace",
"--log-level=debug",
"--manage-burst=StackKeepJPEG",
source,
})
err = c.ExecuteContext(ctx)
if err != nil && a.Log().GetSLog() != nil {
a.Log().Error(err.Error())
}

if err != nil {
t.Error("Unexpected error", err)
return
}

e2e.CheckResults(t, map[fileevent.Code]int64{
fileevent.Uploaded: 4,
fileevent.Stacked: 4,
fileevent.DiscoveredDiscarded: 4,
}, false, a.Jnl())

sourceDir := e2e.ScanDirectory(t, source)
serverAssets := e2e.ImmichScan(t, client)
upFiles := e2e.ExtensionFilter(sourceDir, []string{".jpg"})
if !reflect.DeepEqual(serverAssets, upFiles) {
t.Error("Unexpected assets on server", serverAssets, "expected", upFiles)
}
})

t.Run("phone burst", func(t *testing.T) {
const source = "DATA/bursts/phone"
e2e.InitMyEnv()
e2e.ResetImmich(t)
client, err := e2e.GetImmichClient()
if err != nil {
t.Fatal(err)
return
}

ctx := context.Background()
c, a := cmd.RootImmichGoCommand(ctx)
c.SetArgs([]string{
"upload", "from-folder",
"--server=" + e2e.MyEnv("IMMICHGO_SERVER"),
"--api-key=" + e2e.MyEnv("IMMICHGO_APIKEY"),
"--no-ui",
"--api-trace",
"--log-level=debug",
"--manage-burst=Stack",
source,
})
err = c.ExecuteContext(ctx)
if err != nil && a.Log().GetSLog() != nil {
a.Log().Error(err.Error())
}

if err != nil {
t.Error("Unexpected error", err)
return
}

e2e.CheckResults(t, map[fileevent.Code]int64{
fileevent.Uploaded: 7,
fileevent.Stacked: 7,
fileevent.DiscoveredDiscarded: 0,
}, false, a.Jnl())

sourceDir := e2e.ScanDirectory(t, source)
serverAssets := e2e.ImmichScan(t, client)
upFiles := e2e.ExtensionFilter(sourceDir, []string{".jpg"})
if !reflect.DeepEqual(serverAssets, upFiles) {
t.Error("Unexpected assets on server", serverAssets, "expected", upFiles)
}
})

t.Run("phone jpg burst but keepRaw ", func(t *testing.T) {
const source = "DATA/bursts/phone"
e2e.InitMyEnv()
e2e.ResetImmich(t)
client, err := e2e.GetImmichClient()
if err != nil {
t.Fatal(err)
return
}

ctx := context.Background()
c, a := cmd.RootImmichGoCommand(ctx)
c.SetArgs([]string{
"upload", "from-folder",
"--server=" + e2e.MyEnv("IMMICHGO_SERVER"),
"--api-key=" + e2e.MyEnv("IMMICHGO_APIKEY"),
"--no-ui",
"--api-trace",
"--log-level=debug",
"--manage-burst=StackKeepRaw",
source,
})
err = c.ExecuteContext(ctx)
if err != nil && a.Log().GetSLog() != nil {
a.Log().Error(err.Error())
}

if err != nil {
t.Error("Unexpected error", err)
return
}

e2e.CheckResults(t, map[fileevent.Code]int64{
fileevent.Uploaded: 7,
fileevent.Stacked: 7,
fileevent.DiscoveredDiscarded: 0,
}, false, a.Jnl())

sourceDir := e2e.ScanDirectory(t, source)
serverAssets := e2e.ImmichScan(t, client)
upFiles := e2e.ExtensionFilter(sourceDir, []string{".jpg"})
if !reflect.DeepEqual(serverAssets, upFiles) {
t.Error("Unexpected assets on server", serverAssets, "expected", upFiles)
}
})
}
Loading

0 comments on commit 00ea156

Please # to comment.