Re-enable SFTP integration tests (#550)

This commit is contained in:
Toni Spets
2023-12-25 15:31:30 +02:00
committed by GitHub
parent a47d955e3f
commit e71e6856d0
2 changed files with 46 additions and 29 deletions

View File

@@ -183,34 +183,47 @@ jobs:
LITESTREAM_ABS_ACCOUNT_KEY: ${{ secrets.LITESTREAM_ABS_ACCOUNT_KEY }} LITESTREAM_ABS_ACCOUNT_KEY: ${{ secrets.LITESTREAM_ABS_ACCOUNT_KEY }}
LITESTREAM_ABS_BUCKET: integration LITESTREAM_ABS_BUCKET: integration
## this doesn't yet work sftp-integration-test:
# sftp-integration-test: name: Run SFTP Integration Tests
# name: Run SFTP Integration Tests runs-on: ubuntu-latest
# runs-on: ubuntu-latest needs: build
# needs: build steps:
# if: github.ref == 'refs/heads/main' - name: Prepare OpenSSH server
# concurrency: run: |-
# group: integration-test-sftp sudo mkdir -p /test/etc/ssh /test/home /run/sshd /test/data/
# steps: sudo ssh-keygen -t ed25519 -f /test/etc/ssh/id_ed25519_host -N ""
# - name: Extract SSH key sudo ssh-keygen -t ed25519 -f /test/etc/ssh/id_ed25519 -N ""
# run: 'echo "$LITESTREAM_SFTP_KEY" > /opt/id_ed25519' sudo chmod 0600 /test/etc/ssh/id_ed25519_host /test/etc/ssh/id_ed25519
# shell: bash sudo chmod 0644 /test/etc/ssh/id_ed25519_host.pub /test/etc/ssh/id_ed25519.pub
# env: sudo cp /test/etc/ssh/id_ed25519 /test/id_ed25519
# LITESTREAM_SFTP_KEY: ${{secrets.LITESTREAM_SFTP_KEY}} sudo chown $USER /test/id_ed25519
sudo tee /test/etc/ssh/sshd_config <<EOF
Port 2222
HostKey /test/etc/ssh/id_ed25519_host
AuthorizedKeysFile /test/etc/ssh/id_ed25519.pub
AuthenticationMethods publickey
Subsystem sftp internal-sftp
UsePAM no
LogLevel DEBUG
EOF
sudo /usr/sbin/sshd -e -f /test/etc/ssh/sshd_config -E /test/debug.log
# - uses: actions/checkout@v4 - name: Test OpenSSH server works with pubkey auth
run: ssh -v -i /test/id_ed25519 -o StrictHostKeyChecking=accept-new -p 2222 root@localhost whoami || (sudo cat /test/debug.log && exit 1)
# - uses: actions/setup-go@v4 - uses: actions/checkout@v4
# with:
# go-version: ${{ env.GO_VERSION }}
# - run: go env - uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
# - run: go install ./cmd/litestream - run: go env
# - run: go test -v ./replica_client_test.go -integration sftp - run: go install ./cmd/litestream
# env:
# LITESTREAM_SFTP_HOST: ${{ secrets.LITESTREAM_SFTP_HOST }} - run: go test -v ./replica_client_test.go -integration sftp
# LITESTREAM_SFTP_USER: ${{ secrets.LITESTREAM_SFTP_USER }} env:
# LITESTREAM_SFTP_KEY_PATH: /opt/id_ed25519 LITESTREAM_SFTP_HOST: "localhost:2222"
# LITESTREAM_SFTP_PATH: ${{ secrets.LITESTREAM_SFTP_PATH }} LITESTREAM_SFTP_USER: "root"
LITESTREAM_SFTP_KEY_PATH: /test/id_ed25519
LITESTREAM_SFTP_PATH: /test/data

View File

@@ -75,10 +75,14 @@ func TestReplicaClient_Generations(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// Verify returned generations. // Fetch and sort generations.
if got, err := c.Generations(context.Background()); err != nil { got, err := c.Generations(context.Background())
if err != nil {
t.Fatal(err) t.Fatal(err)
} else if want := []string{"155fe292f8333c72", "5efbd8d042012dca", "b16ddcf5c697540f"}; !reflect.DeepEqual(got, want) { }
sort.Strings(got)
if want := []string{"155fe292f8333c72", "5efbd8d042012dca", "b16ddcf5c697540f"}; !reflect.DeepEqual(got, want) {
t.Fatalf("Generations()=%v, want %v", got, want) t.Fatalf("Generations()=%v, want %v", got, want)
} }
}) })