Merge remote-tracking branch 'origin/main' into fix/restart-recovery

Signed-off-by: Hector Ventura <hectorvent@gmail.com>
This commit is contained in:
Hector Ventura committed 2026-11-04 01:02:20 -06:00
commit 5ce87783c1
6 files changed
+124 -5

No files matched your search

+85 -2
View File
@@ -11,6 +11,69 @@ expected="${2:-}"
"$bin" version
work=$(mktemp -d)
profile="floci-smoke-$$"
cleanup() {
"$bin" config profile delete "$profile" > /dev/null 2>&1 || true
rm -rf "$work"
}
trap cleanup EXIT
expect_exit() {
local expected_code="$1"
shift
local actual_code=0
"$@" > "$work/out" 2> "$work/err" || actual_code=$?
if [ "$actual_code" -ne "$expected_code" ]; then
cat "$work/out" "$work/err"
echo "::error::command exited $actual_code, expected $expected_code: $*"
exit 1
fi
}
# A bare grep or test would stop the script under set -e with nothing in the CI log saying why.
require_output() {
local pattern="$1" file="$2" what="$3"
if ! grep -q "$pattern" "$file"; then
cat "$file"
echo "::error::$what: expected output matching '$pattern'"
exit 1
fi
}
# The shorthand and the plain-marks flag parse in the shipped binary. What --no-emoji does cannot
# be seen here: piped output is already plain. ErgonomicsTest covers that.
reported=$("$bin" version --json --no-emoji | tr -d ' \r\n')
case "$reported" in
*'"cli":'*) ;;
*) echo "::error::version --json did not return a version object: $reported"; exit 1 ;;
esac
"$bin" completion bash > "$work/completion"
[ -s "$work/completion" ] || { echo "::error::completion bash printed nothing"; exit 1; }
expect_exit 2 "$bin" completion fish
require_output 'Use bash or zsh' "$work/err" "completion fish"
# SnakeYAML aliases/merge keys must also work in a native image, not just the JVM.
cat > "$work/compose.yml" <<'YAML'
x-emulator: &emulator
image: floci/floci:latest
ports: ["14566:4566"]
volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
services:
floci:
<<: *emulator
YAML
validated=$("$bin" aws config validate --file "$work/compose.yml" --json | tr -d ' \r\n')
case "$validated" in
*'"valid":true'*'"errors":[]'*) ;;
*) echo "::error::native Compose validation failed: $validated"; exit 1 ;;
esac
# A rejected snapshot name and a declined reset must finish without contacting Docker/server.
expect_exit 2 "$bin" snapshot save bad/name
expect_exit 2 "$bin" reset --endpoint http://127.0.0.1:1 < /dev/null
if [ -n "$expected" ]; then
reported=$("$bin" version -o json | tr -d ' \r\n')
case "$reported" in
@@ -25,8 +88,6 @@ done
# A profile round trip: Jackson writes it and reads it back. Listing alone proves little on a
# fresh runner, where there is nothing to read. The name is unique and the profile is deleted.
profile="floci-smoke-$$"
trap '"$bin" config profile delete "$profile" > /dev/null 2>&1 || true' EXIT
"$bin" config profile create "$profile" --container floci-smoke --port 14566 > /dev/null
shown=$("$bin" config show --profile "$profile" -o json | tr -d ' \r\n')
case "$shown" in
@@ -36,6 +97,28 @@ esac
"$bin" config profile list -o json | grep -q "$profile" \
|| { echo "::error::profile $profile is missing from 'config profile list'"; exit 1; }
# Edit through a real child process, then read its new value via Jackson in the binary. Not on
# Windows: launching 'sh' with a Git Bash path from a native exe has not been proven there, and
# this script runs on Windows only while a release is being cut, so a false failure would stop it.
case "$(uname -s)" in
MINGW*|MSYS*|CYGWIN*) echo "skipping profile edit on Windows" ;;
*)
cat > "$work/editor.sh" <<'SH'
printf 'container: floci-smoke\nport: 14566\nnamespace: smoke-native\n' > "$1"
SH
edited=$(VISUAL="sh \"$work/editor.sh\"" EDITOR="sh \"$work/editor.sh\"" \
"$bin" config profile edit "$profile" --json | tr -d ' \r\n')
case "$edited" in
*'"action":"edited"'*) ;;
*) echo "::error::profile edit did not report success: $edited"; exit 1 ;;
esac
"$bin" config profile show "$profile" --json > "$work/profile.json"
require_output 'smoke-native' "$work/profile.json" "profile show after edit"
;;
esac
"$bin" config show --profile "$profile" -o yaml > "$work/config.yaml"
require_output 'container: "\{0,1\}floci-smoke' "$work/config.yaml" "config show -o yaml"
# An unknown profile is a usage error: exit 2, not a crash.
set +e
"$bin" start --profile floci-smoke-no-such-profile > /dev/null 2>&1
+5
View File
@@ -38,6 +38,11 @@ mvn package # fat JAR → target/floci.jar
mvn package -Pnative -DskipTests # native binary → target/floci (requires GraalVM)
```
The native CI and release jobs run `.github/scripts/smoke.sh ./target/floci`. It checks
completion, rejected input, JSON and YAML output, profile create/edit/read/delete, reset's
confirmation guard and Compose validation with YAML anchors and merge keys. It needs no
emulator or Docker daemon. It skips profile edit on Windows. Run it after building the native binary when changing these paths.
### Try it against a real emulator
```bash
+4
View File
@@ -555,6 +555,10 @@ Variables exported (per enabled service):
| `SECRET_MANAGER_EMULATOR_HOST` | Secret Manager |
| `IAM_EMULATOR_HOST` | IAM |
SDK support for these variables varies by service and language. Python Secret Manager ignores
`SECRET_MANAGER_EMULATOR_HOST`; set an explicit emulator endpoint and anonymous credentials.
See the [Python Secret Manager recipe](skills/floci/references/gcp.md#python-secret-manager).
### `floci az env`
Prints Azure connection variables for the running Floci Azure instance.
+3 -1
View File
@@ -35,11 +35,13 @@ services:
app:
build: .
environment:
# Client libraries skip credentials when these are set. Storage needs the scheme.
# SDK support varies by service. Storage needs the scheme.
STORAGE_EMULATOR_HOST: http://floci-gcp:4588
PUBSUB_EMULATOR_HOST: floci-gcp:4588
FIRESTORE_EMULATOR_HOST: floci-gcp:4588
DATASTORE_EMULATOR_HOST: floci-gcp:4588
# Python Secret Manager needs explicit endpoint + anonymous credentials; see gcp.md.
# This variable alone does not configure that SDK.
SECRET_MANAGER_EMULATOR_HOST: floci-gcp:4588
GOOGLE_CLOUD_PROJECT: floci-local
depends_on:
+3 -1
View File
@@ -143,7 +143,9 @@ Ask before running `docker compose down -v`: `-v` deletes the data volume. Plain
- **GCP**: `STORAGE_EMULATOR_HOST=http://floci-gcp:4588` (with scheme) and
`PUBSUB_EMULATOR_HOST`, `FIRESTORE_EMULATOR_HOST`, `DATASTORE_EMULATOR_HOST`,
`SECRET_MANAGER_EMULATOR_HOST` set to `floci-gcp:4588` (no scheme). Set both
`FLOCI_GCP_HOSTNAME` and `FLOCI_GCP_BASE_URL` on the emulator.
`FLOCI_GCP_HOSTNAME` and `FLOCI_GCP_BASE_URL` on the emulator. SDK support varies:
Python Secret Manager ignores its emulator variable; use the explicit REST endpoint
`http://floci-gcp:4588` with anonymous credentials (see [gcp.md](gcp.md)).
- **Azure**: a connection string with the service name in each endpoint (see `azure.yml`).
The control plane (`az`, ARM, Terraform) needs TLS on and the CA trusted: from the host run
`floci az setup --container <container name>`; inside another container, read
+24 -1
View File
@@ -19,7 +19,9 @@ silently, so check the output):
| `SECRET_MANAGER_EMULATOR_HOST` | Secret Manager |
| `IAM_EMULATOR_HOST` | IAM |
Client libraries skip credentials when these are set.
Emulator-variable support depends on the service and SDK. Do not assume an exported
variable redirects a client or disables credential lookup. Python Secret Manager ignores
`SECRET_MANAGER_EMULATOR_HOST`: configure its endpoint and credentials explicitly, as below.
Pass `project="floci-local"` (or any id) explicitly to clients. Firebase Auth uses
`FIREBASE_AUTH_EMULATOR_HOST=localhost:4588`, which `floci gcp env` does not export: set it
yourself when the app uses the Firebase Admin SDK.
@@ -29,6 +31,27 @@ etc.) need the endpoint set on the client: `http://localhost:4588` for REST, `lo
plaintext for gRPC, with no credentials (`NoCredentialsProvider` in Java,
`AnonymousCredentials` in Python, `ClientOptions(api_endpoint=...)`).
### Python Secret Manager
Use the REST transport with an explicit endpoint and anonymous credentials. On the host,
use `http://localhost:4588`; from the Compose app service use `http://floci-gcp:4588`.
Setting `SECRET_MANAGER_EMULATOR_HOST` alone does not configure this client.
```python
from google.auth.credentials import AnonymousCredentials
from google.cloud import secretmanager_v1
client = secretmanager_v1.SecretManagerServiceClient(
transport="rest",
credentials=AnonymousCredentials(),
client_options={"api_endpoint": "http://localhost:4588"},
)
```
Before making requests, check `client.transport._host` in a local test. It must be your
emulator endpoint. For gRPC, provide an explicit plaintext channel instead of the default
TLS channel. See the [Python client source](https://github.com/googleapis/google-cloud-python/blob/main/packages/google-cloud-secret-manager/google/cloud/secretmanager_v1/services/secret_manager_service/client.py).
## Wiring for gcloud (important)
**gcloud does not honor `*_EMULATOR_HOST`.** Without the overrides below, `gcloud` commands go