File: t-batch-transfer-size.sh

package info (click to toggle)
git-lfs 3.6.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,808 kB
  • sloc: sh: 21,256; makefile: 507; ruby: 417
file content (88 lines) | stat: -rwxr-xr-x 2,459 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env bash

. "$(dirname "$0")/testlib.sh"

begin_test "batch storage upload with small batch size"
(
  set -e

  reponame="batch-storage-upload-small-batch"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" batch-storage-repo-upload

  contents1="storage-upload-batch-1"
  contents2="storage-upload-batch-2"
  contents3="storage-upload-batch-3"
  oid1="$(calc_oid "$contents1")"
  oid2="$(calc_oid "$contents2")"
  oid3="$(calc_oid "$contents3")"
  printf "%s" "$contents1" > a.dat
  printf "%s" "$contents2" > b.dat
  printf "%s" "$contents3" > c.dat

  git lfs track "*.dat"
  git add .gitattributes a.dat b.dat c.dat
  git commit -m "initial commit"

  git config --local lfs.transfer.batchSize 1

  GIT_TRACE=1 git push origin main 2>&1 | tee push.log
  if [ "0" -ne "${PIPESTATUS[0]}" ]; then
    echo >&2 "fatal: expected \`git push origin main\` to succeed ..."
    exit 1
  fi

  actual_count="$(grep -c "tq: sending batch of size 1" push.log)"
  [ "3" = "$actual_count" ]

  assert_server_object "$reponame" "$oid1"
  assert_server_object "$reponame" "$oid2"
  assert_server_object "$reponame" "$oid3"
)
end_test

begin_test "batch storage download with small batch size"
(
  set -e

  reponame="batch-storage-download-small-batch"
  setup_remote_repo "$reponame"
  clone_repo "$reponame" batch-storage-repo-download

  contents1="storage-download-batch-1"
  contents2="storage-download-batch-2"
  contents3="storage-download-batch-3"
  oid1="$(calc_oid "$contents1")"
  oid2="$(calc_oid "$contents2")"
  oid3="$(calc_oid "$contents3")"
  printf "%s" "$contents1" > a.dat
  printf "%s" "$contents2" > b.dat
  printf "%s" "$contents3" > c.dat

  git lfs track "*.dat"
  git add .gitattributes a.dat b.dat c.dat
  git commit -m "initial commit"

  git push origin main
  assert_server_object "$reponame" "$oid1"
  assert_server_object "$reponame" "$oid2"
  assert_server_object "$reponame" "$oid3"

  cd ..
  git config --global lfs.transfer.batchSize 1

  GIT_TRACE=1 git clone "$GITSERVER/$reponame" "${reponame}-assert" 2>&1 | tee clone.log
  if [ "0" -ne "${PIPESTATUS[0]}" ]; then
    echo >&2 "fatal: expected \`git clone\` to succeed ..."
    exit 1
  fi

  actual_count="$(grep -c "tq: sending batch of size 1" clone.log)"
  [ "3" = "$actual_count" ]

  cd "${reponame}-assert"
  assert_local_object "$oid1" "${#contents1}"
  assert_local_object "$oid2" "${#contents2}"
  assert_local_object "$oid3" "${#contents3}"
)
end_test