Skip to content

Commit

Permalink
Re-enable SFTP integration tests
Browse files Browse the repository at this point in the history
Removed dependency on external server. Test also expected the order
which was removed from the promise earlier.
  • Loading branch information
hifi committed Dec 25, 2023
1 parent a47d955 commit 92d2f31
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 34 deletions.
71 changes: 40 additions & 31 deletions .github/workflows/commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -183,34 +183,43 @@ jobs:
LITESTREAM_ABS_ACCOUNT_KEY: ${{ secrets.LITESTREAM_ABS_ACCOUNT_KEY }}
LITESTREAM_ABS_BUCKET: integration

## this doesn't yet work
# sftp-integration-test:
# name: Run SFTP Integration Tests
# runs-on: ubuntu-latest
# needs: build
# if: github.ref == 'refs/heads/main'
# concurrency:
# group: integration-test-sftp
# steps:
# - name: Extract SSH key
# run: 'echo "$LITESTREAM_SFTP_KEY" > /opt/id_ed25519'
# shell: bash
# env:
# LITESTREAM_SFTP_KEY: ${{secrets.LITESTREAM_SFTP_KEY}}

# - uses: actions/checkout@v4

# - uses: actions/setup-go@v4
# with:
# go-version: ${{ env.GO_VERSION }}

# - run: go env

# - run: go install ./cmd/litestream

# - run: go test -v ./replica_client_test.go -integration sftp
# env:
# LITESTREAM_SFTP_HOST: ${{ secrets.LITESTREAM_SFTP_HOST }}
# LITESTREAM_SFTP_USER: ${{ secrets.LITESTREAM_SFTP_USER }}
# LITESTREAM_SFTP_KEY_PATH: /opt/id_ed25519
# LITESTREAM_SFTP_PATH: ${{ secrets.LITESTREAM_SFTP_PATH }}
sftp-integration-test:
name: Run SFTP Integration Tests
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}

- run: |-
sudo mkdir -p /opt/ssh/etc/ssh /opt/ssh/home /run/sshd /opt/ssh/test/
sudo chmod 0700 /opt/ssh/etc/ssh
sudo ssh-keygen -t ed25519 -f /opt/ssh/etc/ssh/id_ed25519_host -N ""
sudo ssh-keygen -t ed25519 -f /opt/ssh/etc/ssh/id_ed25519 -N ""
sudo chmod 0600 /opt/ssh/etc/ssh/id_ed25519_host /opt/ssh/etc/ssh/id_ed25519
sudo chmod 0644 /opt/ssh/etc/ssh/id_ed25519_host.pub /opt/ssh/etc/ssh/id_ed25519.pub
sudo cat > /opt/ssh/etc/ssh/sshd_config <<EOF
Port 2222
HostKey /opt/ssh/etc/ssh/id_ed25519_host
AuthorizedKeysFile /opt/ssh/etc/ssh/id_ed25519.pub
AuthenticationMethods publickey
Subsystem sftp internal-sftp
UsePAM no
LogLevel DEBUG
EOF
sudo /usr/sbin/sshd -e -f /opt/ssh/etc/ssh/sshd_config -E /opt/ssh/debug.log
- run: sudo ssh -v -i /opt/ssh/etc/ssh/id_ed25519 -o StrictHostKeyChecking=accept-new -p 2222 root@localhost whoami || sudo cat /opt/ssh/debug.log

- run: go env

- run: go install ./cmd/litestream

- run: go test -v ./replica_client_test.go -integration sftp
env:
LITESTREAM_SFTP_HOST: "localhost:2222"
LITESTREAM_SFTP_USER: "root"
LITESTREAM_SFTP_KEY_PATH: /opt/ssh/etc/ssh/id_ed25519
LITESTREAM_SFTP_PATH: /opt/ssh/test
10 changes: 7 additions & 3 deletions replica_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,14 @@ func TestReplicaClient_Generations(t *testing.T) {
t.Fatal(err)
}

// Verify returned generations.
if got, err := c.Generations(context.Background()); err != nil {
// Fetch and sort generations.
got, err := c.Generations(context.Background())
if err != nil {
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)
}
})
Expand Down

0 comments on commit 92d2f31

Please sign in to comment.