Skip to content

Commit

Permalink
Squash for revert
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxJa4 committed Aug 23, 2023
1 parent 955f98e commit e9b617b
Show file tree
Hide file tree
Showing 7 changed files with 111 additions and 60 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ jobs:
steps:
- uses: actions/checkout@v3

- name: Add hosts to /etc/hosts
run: |
sudo echo "127.0.0.1 host.docker.internal" | sudo tee -a /etc/hosts
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

Expand Down
2 changes: 1 addition & 1 deletion internal/storage/dropbox/dropbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewStorageBackend(opts Config, logFunc storage.Log) (storage.Backend, error
},
}

logFunc(storage.LogLevelInfo, "Dropbox", "Fetching fresh access token for Dropbox storage backend.")
logFunc(storage.LogLevelInfo, "Dropbox", "Fetching fresh access token from Dropbox OAuth2 endpoint '%s'...", tokenUrl)
tkSource := conf.TokenSource(context.Background(), &oauth2.Token{RefreshToken: opts.RefreshToken})
token, err := tkSource.Token()
if err != nil {
Expand Down
102 changes: 102 additions & 0 deletions test/adropbox/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
version: '3'

services:
openapi_mock:
image: muonsoft/openapi-mock
environment:
OPENAPI_MOCK_USE_EXAMPLES: if_present
OPENAPI_MOCK_SPECIFICATION_URL: '/etc/openapi/user_v2.yaml'
ports:
- 8080:8080
volumes:
- ./user_v2.yaml:/etc/openapi/user_v2.yaml
networks:
mocking:
ipv4_address: 172.16.238.11

oauth2_mock:
image: ghcr.io/navikt/mock-oauth2-server:1.0.0
ports:
- 8090:8090
environment:
PORT: '8090'
SERVER_HOSTNAME: '172.16.238.10'
JSON_CONFIG: >
'{
"issuer":"http://localhost:8090/default",
"authorization_endpoint":"http://localhost:8090/default/authorize",
"token_endpoint":"http://localhost:8090/default/token",
"response_types_supported":[
"query",
"fragment",
"form_post"
],
"subject_types_supported":[
"public"
],
"id_token_signing_alg_values_supported":[
"ES256",
"ES384",
"RS256",
"RS384",
"RS512",
"PS256",
"PS384",
"PS512"
],
"code_challenge_methods_supported":[
"plain",
"S256"
]
}'
hostname: host.docker.internal
networks:
mocking:
ipv4_address: 172.16.238.10

backup:
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
hostname: host.docker.internal
depends_on:
- openapi_mock
- oauth2_mock
restart: always
environment:
BACKUP_FILENAME_EXPAND: 'true'
BACKUP_FILENAME: test-$$HOSTNAME.tar.gz
BACKUP_CRON_EXPRESSION: 0 0 5 31 2 ?
BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-7}
BACKUP_PRUNING_LEEWAY: 5s
BACKUP_PRUNING_PREFIX: test
DROPBOX_ENDPOINT: http://openapi_mock:8080
DROPBOX_OAUTH2_ENDPOINT: http://172.16.238.10:8090
DROPBOX_REFRESH_TOKEN: test
DROPBOX_APP_KEY: test
DROPBOX_APP_SECRET: test
DROPBOX_REMOTE_PATH: /test
DROPBOX_CONCURRENCY_LEVEL: 6
volumes:
- app_data:/backup/app_data:ro
- /var/run/docker.sock:/var/run/docker.sock
networks:
mocking:
ipv4_address: 172.16.238.12
extra_hosts:
- "host.docker.internal:host-gateway"

offen:
image: offen/offen:latest
labels:
- docker-volume-backup.stop-during-backup=true
volumes:
- app_data:/var/opt/offen

volumes:
app_data:

networks:
mocking:
driver: default
ipam:
config:
- subnet: 172.16.238.0/24
File renamed without changes.
7 changes: 4 additions & 3 deletions test/dropbox/run.sh → test/adropbox/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ cd "$(dirname "$0")"
current_test=$(basename $(pwd))

docker compose up -d
sleep 5
sleep 10

logs=$(docker compose exec -T backup backup)
#logs=$(docker compose exec -T backup backup)
docker compose exec backup backup

sleep 5

Expand All @@ -26,7 +27,7 @@ fi
# is set to 0 days (which it should not as it would mean all backups get deleted)
# TODO: find out if we can test actual deletion without having to wait for a day
BACKUP_RETENTION_DAYS="0" docker compose up -d
sleep 5
sleep 10

logs=$(docker compose exec -T backup backup)

Expand Down
File renamed without changes.
56 changes: 0 additions & 56 deletions test/dropbox/docker-compose.yml

This file was deleted.

0 comments on commit e9b617b

Please sign in to comment.