Ditto Server
Testing in a cloud environment offers scalability, flexibility, and cost efficiency by allowing dynamic resource allocation and parallel testing. It provides consistent, reproducible environments for reliable results and supports advanced automated and performance testing capabilities. Ditto Server isolates each app from one another by default in a multi-tenant architecture, ensuring robust security and data privacy. This design allows multiple tenants to share the same infrastructure while keeping their data and applications completely separate. The following approaches allow multiple developers to work on Ditto in parallel, without conflict.- App per environment (dev, stage, prod), prefix collections with developer environment
- Each developer can work within the same app
- Running tests in isolation can be done by prefixing the collection with a unique identifier specific to that developer
- For example, a Collection named
john_smith.orders.v3
- App per developer
- Each developer creates their own “app” within an organization. This creates a sandbox for a developer to isolate work and data from other developers
- Starting a new test would require changing the Database ID on the Small Peer
How do I migrate data between databases?
Please contact your dedicated support engineer to help migrate data between apps.
- Ditto Portal:
- Log in to your account on the Ditto Portal
- The Support Portal is located in the upper right hand side of the portal
- Email: Send an email to our support team at support@ditto.com
- Please include the details of the apps you wish to help migrate data between.
Small Peer
To test Small Peer integration in isolation, we suggest using a wrapper library that includes an interface and mock implementation for unit testing. Ditto can be injected with an offline-only instance using an offline license token, and building a wrapper library includes an interface and a mock implementation for unit testing. This allows you to test small peer logic and syncing between small peers without relying on the availability of Ditto Server, which is great for testing within a CI/CD pipeline.Identity Switching
When testing the production readiness of your app, it is best practice to incorporate dynamic identity switching to debug potential issues related to roles, permissions, sync, and authentication workflows, such as cleanup and resource management when changing identities within your app. In dynamic identity switching, end-user types adjust in realtime as a response to specific contexts or situations, without requiring an app restart or code change. From the end-user perspective, this automatic process means no interruptions or inconveniences like needing to log in again.While testing with different digital identities is recommended during pre-production testing, this practice is not recommended for production environments due to potential performance and security concerns.
- Swift
- Kotlin
- JS
- Java
- C#
- C++
- Rust
- Go
DittoManager method class configures, manages, and interacts with authentication functionality in the app.
Simulating Offline and Disconnected Scenarios
When testing how your app behaves without a connection to Ditto Server, you have two approaches: blocking the connection at the network level, or disabling cloud sync programmatically via the transport configuration.Approach 1: Block Ditto Server at the Network Level
To simulate a cloud outage while keeping other internet access and peer-to-peer sync active, block connections to*.cloud.ditto.live using a firewall rule, DNS sinkhole, or proxy configuration on the test device or network.
1
Start the app and allow it to authenticate
Launch your app normally and confirm that the Ditto SDK has successfully authenticated and started sync. This ensures the device has a valid auth token cached locally.
2
Block connections to Ditto Server
Apply a firewall rule or DNS block for
*.cloud.ditto.live on the test device or network. The device will lose its connection to Ditto Server but retain all other internet access.3
Test your app's offline behavior
Exercise your app’s functionality. Data reads, writes, and peer-to-peer sync with nearby devices should continue working normally. Verify that your app handles the absence of cloud sync gracefully.
4
Restore the connection
Remove the firewall rule or DNS block. The SDK will automatically reconnect to Ditto Server and sync any changes that were made while disconnected.
Approach 2: Disable Cloud Sync via Transport Configuration
You can programmatically disable cloud sync by removing WebSocket URLs from the transport configuration. This keeps peer-to-peer transports active while preventing any connection to Ditto Server.Changing the transport configuration via
updateTransportConfig takes effect immediately — you do not need to stop and restart sync. To re-enable cloud sync, add the WebSocket URL back to the configuration. See Customizing Transport Configurations for more details.FAQ
Can I mock the Ditto server for CI use?
Can I mock the Ditto server for CI use?
We don’t have anything to provide today. Stay tuned for Ditto Edge Server.
Can I run the Ditto Server on my local laptop?
Can I run the Ditto Server on my local laptop?
We don’t have this yet, but it’s on the roadmap.
Is it a problem to have multiple apps?
Is it a problem to have multiple apps?
No, it is designed for multi-tenancy.