Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ commands:
type: string
default: "Client.Test"
steps:
- checkout
- run:
name: Install Dependencies
command: |
Expand Down Expand Up @@ -53,13 +52,32 @@ jobs:
docker:
- image: &default-dotnet-image "mcr.microsoft.com/dotnet/sdk:8.0"
steps:
- checkout
- client-test:
project: "Client.Test"
tests-integration:
working_directory: ~/repo
docker:
- image: *default-dotnet-image
- image: influxdb:3-core
environment:
- INFLUXDB3_NODE_IDENTIFIER_PREFIX=node01
- INFLUXDB3_OBJECT_STORE=file
- INFLUXDB3_DB_DIR=/var/lib/influxdb3/data
steps:
- checkout
- run:
name: Install jq
command: |
apt-get update
apt-get install -y jq
- run:
name: Setup InfluxDB service
command: |
./Scripts/influxdb-setup.sh \
--export-url-as TESTING_INFLUXDB_URL \
--export-db-as TESTING_INFLUXDB_DATABASE \
--export-token-as TESTING_INFLUXDB_TOKEN
- client-test:
project: "Client.Test.Integration"

Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Features

1. [#164](https://github.com/InfluxCommunity/influxdb3-csharp/pull/164): Add function to get InfluxDB version.
1. [#168](https://github.com/InfluxCommunity/influxdb3-csharp/pull/168): Run integration tests against a locally started InfluxDB 3 Core server.

## 1.2.0 [2025-05-22]

Expand Down
7 changes: 6 additions & 1 deletion Client.Test.Integration/QueryWriteTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public async Task QueryWriteParameters()
}

[Test]
public void MaxReceiveMessageSize()
public async Task MaxReceiveMessageSize()
{
using var client = new InfluxDBClient(new ClientConfig
{
Expand All @@ -154,6 +154,11 @@ public void MaxReceiveMessageSize()
}
});

// Make sure the measurement exists
var testId = DateTime.UtcNow.Millisecond;
await client.WriteRecordAsync($"integration_test,type=used value=1234.0,testId={testId}");


var ex = Assert.ThrowsAsync<RpcException>(async () =>
{
await foreach (var _ in client.Query("SELECT value FROM integration_test"))
Expand Down
123 changes: 123 additions & 0 deletions Scripts/influxdb-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/usr/bin/env bash
#
# The MIT License
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#

set -e

DEFAULT_INFLUXDB_DATABASE=my-db
INFLUXDB_DATABASE="${INFLUXDB_DATABASE:-$DEFAULT_INFLUXDB_DATABASE}"

#
# Parse command line arguments
#
EXPORT_URL_ENV_VAR=""
EXPORT_DB_ENV_VAR=""
EXPORT_TOKEN_ENV_VAR=""
while [[ $# -gt 0 ]]; do
case $1 in
--export-url-as)
EXPORT_URL_ENV_VAR="$2"
shift 2
;;
--export-db-as)
EXPORT_DB_ENV_VAR="$2"
shift 2
;;
--export-token-as)
EXPORT_TOKEN_ENV_VAR="$2"
shift 2
;;
*)
echo "Unknown option $1"
exit 1
;;
esac
done

#
# Check prerequisites
#
for cmd in curl jq; do
command -v ${cmd} &>/dev/null || { echo "'${cmd}' is not installed"; exit 1; }
done

echo
echo "Wait to start InfluxDB 3.0"
echo
for i in {1..30}; do
if curl -s -o /dev/null -w "%{http_code}" http://localhost:8181/ping | grep -q "401"; then
break
fi
echo "Attempt $i/30: Waiting for InfluxDB to respond with 401..."
sleep 1
done
echo "Done"

echo
echo "Create admin token"
echo
ADMIN_TOKEN=$(curl -s -X POST http://localhost:8181/api/v3/configure/token/admin | jq -r '.token')
if [[ -z "$ADMIN_TOKEN" || "$ADMIN_TOKEN" == "null" ]]; then
echo "Failed to create admin token"
exit 1
fi
echo "ADMIN_TOKEN=$ADMIN_TOKEN"

echo
echo "Test the token"
echo
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Authorization: Bearer ${ADMIN_TOKEN}" http://localhost:8181/ping)
if [[ "$HTTP_CODE" != "200" ]]; then
echo "Token test failed with HTTP $HTTP_CODE"
exit 1
fi
echo "Done"

echo
echo "Create database"
echo
HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -X POST "http://localhost:8181/api/v3/configure/database" \
-H "Authorization: Bearer ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d "{\"db\":\"${INFLUXDB_DATABASE}\"}")
if [[ "$HTTP_CODE" != "200" ]]; then
echo "Database creation failed with HTTP $HTTP_CODE"
exit 1
fi
echo "Done"

#
# Export results
#

export_var() {
local var_name="$1" var_value="$2"
[[ -n "$var_name" ]] || return
[[ -n "$BASH_ENV" ]] || { echo "\$BASH_ENV not available (not in CircleCI), cannot export variables."; exit 1; }
echo "Exporting $var_name=$var_value"
echo "export $var_name=$var_value" >> "$BASH_ENV"
}

echo
export_var "$EXPORT_URL_ENV_VAR" "http://localhost:8181"
export_var "$EXPORT_DB_ENV_VAR" "$INFLUXDB_DATABASE"
export_var "$EXPORT_TOKEN_ENV_VAR" "$ADMIN_TOKEN"
Loading