|
73 | 73 | fi |
74 | 74 |
|
75 | 75 |
|
76 | | -############################################### |
77 | | -# Test Case 0002: upload-only does not download |
78 | | -# Uses separate --confdir profiles to avoid sync_dir change resync issues. |
79 | | -############################################### |
80 | | -TC_ID="0002" |
81 | | -TC_NAME="upload-only: uploads local changes, does not download remote-only changes" |
82 | | - |
83 | | -REMOTE_PREFIX="ci_e2e/${RUN_ID}/${E2E_TARGET}/upload_only" |
84 | | - |
85 | | -SEED_DIR="${RUNNER_TEMP:-/tmp}/seed-${E2E_TARGET}-${RUN_ID}" |
86 | | -UP_DIR="${RUNNER_TEMP:-/tmp}/uploadonly-${E2E_TARGET}-${RUN_ID}" |
87 | | -VER_DIR="${RUNNER_TEMP:-/tmp}/verify-${E2E_TARGET}-${RUN_ID}" |
88 | | - |
89 | | -CONF_BASE="${RUNNER_TEMP:-/tmp}/conf-${E2E_TARGET}-${RUN_ID}" |
90 | | -CONF_SEED="${CONF_BASE}/seed" |
91 | | -CONF_UP="${CONF_BASE}/upload" |
92 | | -CONF_VER="${CONF_BASE}/verify" |
93 | | - |
94 | | -SEED_LOG="${OUT_DIR}/tc0002-seed.log" |
95 | | -UP_LOG="${OUT_DIR}/tc0002-uploadonly.log" |
96 | | -VER_LOG="${OUT_DIR}/tc0002-verify.log" |
97 | | - |
98 | | -REMOTE_ONLY_FILE="remote_only_${RUN_ID}.txt" |
99 | | -LOCAL_ONLY_FILE="local_only_${RUN_ID}.txt" |
100 | | - |
101 | | -echo "Running test case ${TC_ID}: ${TC_NAME}" |
102 | | -echo "Remote prefix: ${REMOTE_PREFIX}" |
103 | | - |
104 | | -# Helper: locate the already-injected refresh token (from workflow step) |
105 | | -TOKEN_SRC="" |
106 | | -if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/onedrive/refresh_token" ]; then |
107 | | - TOKEN_SRC="${XDG_CONFIG_HOME:-$HOME/.config}/onedrive/refresh_token" |
108 | | -elif [ -f "$HOME/.config/onedrive/refresh_token" ]; then |
109 | | - TOKEN_SRC="$HOME/.config/onedrive/refresh_token" |
110 | | -fi |
111 | | - |
112 | | -if [ -z "$TOKEN_SRC" ]; then |
113 | | - add_fail "$TC_ID" "$TC_NAME" "Could not locate existing refresh_token to seed confdirs" |
114 | | -else |
115 | | - # Clean state for this test |
116 | | - rm -rf "$SEED_DIR" "$UP_DIR" "$VER_DIR" "$CONF_BASE" |
117 | | - mkdir -p "$SEED_DIR" "$UP_DIR" "$VER_DIR" |
118 | | - mkdir -p "$CONF_SEED" "$CONF_UP" "$CONF_VER" |
119 | | - |
120 | | - # Copy refresh_token into each confdir (confdir becomes the config root) |
121 | | - umask 077 |
122 | | - cp -f "$TOKEN_SRC" "${CONF_SEED}/refresh_token" |
123 | | - cp -f "$TOKEN_SRC" "${CONF_UP}/refresh_token" |
124 | | - cp -f "$TOKEN_SRC" "${CONF_VER}/refresh_token" |
125 | | - |
126 | | - ######################################################## |
127 | | - # Step A: Seeder uploads a "remote-only" file |
128 | | - ######################################################## |
129 | | - echo "Seeder creating remote-only file: ${REMOTE_ONLY_FILE}" |
130 | | - printf "Created by seeder at run %s\n" "$RUN_ID" > "${SEED_DIR}/${REMOTE_ONLY_FILE}" |
131 | | - |
132 | | - set +e |
133 | | - "$ONEDRIVE_BIN" \ |
134 | | - --confdir "$CONF_SEED" \ |
135 | | - --sync \ |
136 | | - --verbose \ |
137 | | - --resync \ |
138 | | - --resync-auth \ |
139 | | - --syncdir "$SEED_DIR" \ |
140 | | - --single-directory "$REMOTE_PREFIX" \ |
141 | | - 2>&1 | tee "$SEED_LOG" |
142 | | - rc_seed=${PIPESTATUS[0]} |
143 | | - set -e |
144 | | - |
145 | | - if [ "$rc_seed" -ne 0 ]; then |
146 | | - add_fail "$TC_ID" "$TC_NAME" "Seeder sync failed (exit code ${rc_seed})" |
147 | | - else |
148 | | - ######################################################## |
149 | | - # Step B: Uploader creates a local-only file |
150 | | - ######################################################## |
151 | | - echo "Uploader creating local-only file: ${LOCAL_ONLY_FILE}" |
152 | | - printf "Created by uploader at run %s\n" "$RUN_ID" > "${UP_DIR}/${LOCAL_ONLY_FILE}" |
153 | | - |
154 | | - ######################################################## |
155 | | - # Step C: Run upload-only from uploader profile |
156 | | - # Must not download REMOTE_ONLY_FILE into UP_DIR. |
157 | | - ######################################################## |
158 | | - set +e |
159 | | - "$ONEDRIVE_BIN" \ |
160 | | - --confdir "$CONF_UP" \ |
161 | | - --sync \ |
162 | | - --verbose \ |
163 | | - --resync \ |
164 | | - --resync-auth \ |
165 | | - --upload-only \ |
166 | | - --syncdir "$UP_DIR" \ |
167 | | - --single-directory "$REMOTE_PREFIX" \ |
168 | | - 2>&1 | tee "$UP_LOG" |
169 | | - rc_up=${PIPESTATUS[0]} |
170 | | - set -e |
171 | | - |
172 | | - if [ "$rc_up" -ne 0 ]; then |
173 | | - add_fail "$TC_ID" "$TC_NAME" "Upload-only sync failed (exit code ${rc_up})" |
174 | | - elif [ -f "${UP_DIR}/${REMOTE_ONLY_FILE}" ]; then |
175 | | - add_fail "$TC_ID" "$TC_NAME" "Upload-only unexpectedly downloaded remote-only file: ${REMOTE_ONLY_FILE}" |
176 | | - else |
177 | | - ######################################################## |
178 | | - # Step D: Verify upload landed online using verifier |
179 | | - ######################################################## |
180 | | - set +e |
181 | | - "$ONEDRIVE_BIN" \ |
182 | | - --confdir "$CONF_VER" \ |
183 | | - --sync \ |
184 | | - --verbose \ |
185 | | - --resync \ |
186 | | - --resync-auth \ |
187 | | - --download-only \ |
188 | | - --syncdir "$VER_DIR" \ |
189 | | - --single-directory "$REMOTE_PREFIX" \ |
190 | | - 2>&1 | tee "$VER_LOG" |
191 | | - rc_ver=${PIPESTATUS[0]} |
192 | | - set -e |
193 | | - |
194 | | - if [ "$rc_ver" -ne 0 ]; then |
195 | | - add_fail "$TC_ID" "$TC_NAME" "Verifier download-only failed (exit code ${rc_ver})" |
196 | | - elif [ ! -f "${VER_DIR}/${LOCAL_ONLY_FILE}" ]; then |
197 | | - add_fail "$TC_ID" "$TC_NAME" "Uploaded file not found online (not downloaded by verifier): ${LOCAL_ONLY_FILE}" |
198 | | - else |
199 | | - # Optional log sanity checks (secondary): |
200 | | - # - UP log should mention the uploaded filename |
201 | | - # - UP log should not mention the remote-only filename |
202 | | - if ! grep -Fq "$LOCAL_ONLY_FILE" "$UP_LOG"; then |
203 | | - add_fail "$TC_ID" "$TC_NAME" "Upload-only log did not mention uploaded file: ${LOCAL_ONLY_FILE}" |
204 | | - elif grep -Fq "$REMOTE_ONLY_FILE" "$UP_LOG"; then |
205 | | - add_fail "$TC_ID" "$TC_NAME" "Upload-only log mentioned remote-only file (possible download): ${REMOTE_ONLY_FILE}" |
206 | | - else |
207 | | - add_pass "$TC_ID" "$TC_NAME" |
208 | | - fi |
209 | | - fi |
210 | | - fi |
211 | | - fi |
212 | | -fi |
213 | | - |
214 | | - |
215 | 76 |
|
216 | 77 |
|
217 | 78 | ############################################### |
|
0 commit comments