From 70cb3a1e6b55ba61916d5f200fc3da604cfd3401 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 19:55:15 +0000 Subject: [PATCH 1/5] Initial plan From 79a649ae827543cea5cbbabdf7c7959f9c3041e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 19:59:42 +0000 Subject: [PATCH 2/5] Add Debian package installation test pipeline with InfluxDB Co-authored-by: bqstony <10487253+bqstony@users.noreply.github.com> --- .../log4tc/test-deb-installation.yaml | 236 ++++++++++++++++++ azure-pipelines-ci.yml | 13 + 2 files changed, 249 insertions(+) create mode 100644 .azure-pipelines/templates/log4tc/test-deb-installation.yaml diff --git a/.azure-pipelines/templates/log4tc/test-deb-installation.yaml b/.azure-pipelines/templates/log4tc/test-deb-installation.yaml new file mode 100644 index 0000000..23c32f1 --- /dev/null +++ b/.azure-pipelines/templates/log4tc/test-deb-installation.yaml @@ -0,0 +1,236 @@ +############################################################## +# Description: +# This pipeline tests the Debian package installation +# It sets up a Debian container with InfluxDB and verifies +# that log4tc can connect successfully +############################################################## + +parameters: +- name: dotnet_framework + type: string + default: 'net10.0' +- name: dotnet_configuration + type: string + default: 'Release' + +steps: +- script: | + # Create docker-compose.yml for test environment + cat > /tmp/log4tc-test/docker-compose.yml << 'EOF' + version: '3.8' + + services: + influxdb: + image: influxdb:1.8-alpine + container_name: log4tc-test-influxdb + ports: + - "8086:8086" + environment: + INFLUXDB_DB: log4tc + INFLUXDB_HTTP_AUTH_ENABLED: "false" + networks: + - log4tc-test-network + healthcheck: + test: ["CMD", "wget", "--quiet", "--tries=1", "--spider", "http://localhost:8086/ping"] + interval: 10s + timeout: 5s + retries: 5 + + debian-test: + image: debian:bookworm + container_name: log4tc-test-debian + depends_on: + influxdb: + condition: service_healthy + networks: + - log4tc-test-network + volumes: + - ./test-scripts:/test-scripts:ro + - ./artifacts:/artifacts + command: > + bash -c " + echo 'Waiting for InfluxDB to be ready...' && + sleep 5 && + echo 'Starting Debian package installation test...' && + bash /test-scripts/test-installation.sh + " + + networks: + log4tc-test-network: + driver: bridge + EOF + displayName: 'Create docker-compose configuration' + workingDirectory: $(Agent.TempDirectory) + +- script: | + mkdir -p /tmp/log4tc-test/test-scripts + mkdir -p /tmp/log4tc-test/artifacts + displayName: 'Create test directories' + +- script: | + # Create the test installation script + cat > /tmp/log4tc-test/test-scripts/test-installation.sh << 'EOF' + #!/bin/bash + set -e + + echo "===================================" + echo "Debian Package Installation Test" + echo "===================================" + + # Update package list + echo "Updating package lists..." + apt-get update -qq + + # Install required dependencies + echo "Installing dependencies..." + apt-get install -y -qq curl ca-certificates systemd + + # Add log4tc repository + echo "Adding log4tc repository..." + cat > /etc/apt/sources.list.d/log4tc.sources << 'APTCONFIG' + Types: deb + URIs: https://mbc-engineering.github.io/log4TC/deb + Suites: stable + Components: main + Trusted: yes + APTCONFIG + + # Update package list with new repository + echo "Updating package lists with log4tc repository..." + apt-get update -qq + + # Install log4tc + echo "Installing Mbc.Log4Tc.Service..." + apt-get install -y -qq Mbc.Log4Tc.Service + + # Configure log4tc to connect to InfluxDB + echo "Configuring log4tc for InfluxDB connection..." + cat > /etc/log4tc/config/appsettings.json << 'JSONCONFIG' + { + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "Outputs": [ + { + "Type": "influxdb", + "Config": { + "Url": "http://influxdb:8086", + "Database": "log4tc", + "Format": "syslog" + } + } + ] + } + JSONCONFIG + + # Create log directory + echo "Creating log directory..." + mkdir -p /var/log/log4tc + chmod 755 /var/log/log4tc + + # Start the service (without systemd, run directly) + echo "Starting log4tc service..." + /usr/local/bin/Mbc.Log4Tc.Service & + SERVICE_PID=$! + + # Wait for service to start and generate logs + echo "Waiting for service to initialize (30 seconds)..." + sleep 30 + + # Check if service is still running + if ps -p $SERVICE_PID > /dev/null; then + echo "✓ Service is running (PID: $SERVICE_PID)" + else + echo "✗ Service failed to start or crashed" + exit 1 + fi + + # Check internal log for connection status + echo "" + echo "Checking internal logs..." + if [ -f /var/log/log4tc/service.log ]; then + echo "✓ Internal log file exists" + echo "" + echo "--- Last 50 lines of internal log ---" + tail -50 /var/log/log4tc/service.log + echo "--- End of log ---" + echo "" + + # Copy logs to artifacts + cp /var/log/log4tc/service.log /artifacts/service.log 2>/dev/null || true + + # Check for InfluxDB connection indicators + if grep -qi "influx" /var/log/log4tc/service.log; then + echo "✓ InfluxDB output plugin appears to be loaded" + fi + + # Check for errors + if grep -qi "error\|exception\|failed" /var/log/log4tc/service.log; then + echo "⚠ Warning: Errors detected in log file" + echo "Showing error lines:" + grep -i "error\|exception\|failed" /var/log/log4tc/service.log || true + else + echo "✓ No errors detected in log file" + fi + + else + echo "✗ Internal log file not found at /var/log/log4tc/service.log" + exit 1 + fi + + # Test InfluxDB connectivity + echo "" + echo "Testing InfluxDB connectivity..." + if curl -s -o /dev/null -w "%{http_code}" http://influxdb:8086/ping | grep -q "204"; then + echo "✓ InfluxDB is accessible from container" + else + echo "✗ Cannot reach InfluxDB" + exit 1 + fi + + # Check if database exists + echo "" + echo "Checking if log4tc database exists in InfluxDB..." + if curl -s http://influxdb:8086/query?q=SHOW%20DATABASES | grep -q "log4tc"; then + echo "✓ log4tc database exists in InfluxDB" + else + echo "⚠ log4tc database not found (may be created on first write)" + fi + + # Stop the service + echo "" + echo "Stopping service..." + kill $SERVICE_PID + wait $SERVICE_PID 2>/dev/null || true + + echo "" + echo "===================================" + echo "✓ Test completed successfully!" + echo "===================================" + EOF + + chmod +x /tmp/log4tc-test/test-scripts/test-installation.sh + displayName: 'Create test installation script' + +- script: | + cd /tmp/log4tc-test + docker-compose up --abort-on-container-exit --exit-code-from debian-test + displayName: 'Run Debian package installation test' + continueOnError: false + +- script: | + cd /tmp/log4tc-test + docker-compose down -v + displayName: 'Clean up Docker containers' + condition: always() + +- task: PublishBuildArtifacts@1 + displayName: 'Publish test logs' + inputs: + PathtoPublish: '/tmp/log4tc-test/artifacts' + ArtifactName: 'debian-test-logs' + condition: always() diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml index b3e1be8..bbef772 100644 --- a/azure-pipelines-ci.yml +++ b/azure-pipelines-ci.yml @@ -25,3 +25,16 @@ stages: - template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/docs/build-job.yaml # tclibrary - template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/tclibrary/build-job.yaml + +- stage: 'test_debian' + displayName: 'Test Debian Package Installation' + dependsOn: 'build' + condition: succeeded() + jobs: + - job: 'test_deb_installation' + displayName: 'Test Debian Package with InfluxDB' + pool: + vmImage: 'ubuntu-24.04' + steps: + - checkout: self + - template: ${{ variables.Pipeline.Workspace }}/.azure-pipelines/templates/log4tc/test-deb-installation.yaml From 90043693c2bfe175f2abe925e098757e585a7585 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 20:01:14 +0000 Subject: [PATCH 3/5] Fix test pipeline: create directories first, remove systemd dependency, fix URL casing Co-authored-by: bqstony <10487253+bqstony@users.noreply.github.com> --- .../log4tc/README-test-deb-installation.md | 40 +++++++++++++++++++ .../log4tc/test-deb-installation.yaml | 12 +++--- 2 files changed, 46 insertions(+), 6 deletions(-) create mode 100644 .azure-pipelines/templates/log4tc/README-test-deb-installation.md diff --git a/.azure-pipelines/templates/log4tc/README-test-deb-installation.md b/.azure-pipelines/templates/log4tc/README-test-deb-installation.md new file mode 100644 index 0000000..33f9c03 --- /dev/null +++ b/.azure-pipelines/templates/log4tc/README-test-deb-installation.md @@ -0,0 +1,40 @@ +# Debian Package Installation Test + +This pipeline template tests the installation and functionality of the log4tc Debian package. + +## What it does + +1. **Sets up test environment** with Docker Compose: + - InfluxDB 1.8 container for log storage + - Debian Bookworm container for package installation testing + +2. **Installs log4tc** from the GitHub Pages APT repository: + - Adds the log4tc repository to apt sources + - Installs the `Mbc.Log4Tc.Service` package + +3. **Configures log4tc** to connect to InfluxDB: + - Creates appsettings.json with InfluxDB output configuration + - Deploys configuration to `/etc/log4tc/config/` + +4. **Validates the installation**: + - Starts the log4tc service + - Checks the internal log at `/var/log/log4tc/service.log` + - Verifies InfluxDB connectivity + - Checks for errors in the service log + +## Requirements + +- Docker and Docker Compose must be available on the build agent +- The log4tc Debian repository must be accessible at https://mbc-engineering.github.io/log4tc/deb + +## Test Results + +Test logs are published as build artifacts under `debian-test-logs`, including: +- `service.log` - The internal log4tc service log + +## Future Enhancements + +This test environment can be extended to support: +- End-to-end tests with TwinCAT Docker containers +- Integration tests with actual PLC log messages +- Performance and load testing diff --git a/.azure-pipelines/templates/log4tc/test-deb-installation.yaml b/.azure-pipelines/templates/log4tc/test-deb-installation.yaml index 23c32f1..1fab363 100644 --- a/.azure-pipelines/templates/log4tc/test-deb-installation.yaml +++ b/.azure-pipelines/templates/log4tc/test-deb-installation.yaml @@ -14,6 +14,11 @@ parameters: default: 'Release' steps: +- script: | + mkdir -p /tmp/log4tc-test/test-scripts + mkdir -p /tmp/log4tc-test/artifacts + displayName: 'Create test directories' + - script: | # Create docker-compose.yml for test environment cat > /tmp/log4tc-test/docker-compose.yml << 'EOF' @@ -62,11 +67,6 @@ steps: displayName: 'Create docker-compose configuration' workingDirectory: $(Agent.TempDirectory) -- script: | - mkdir -p /tmp/log4tc-test/test-scripts - mkdir -p /tmp/log4tc-test/artifacts - displayName: 'Create test directories' - - script: | # Create the test installation script cat > /tmp/log4tc-test/test-scripts/test-installation.sh << 'EOF' @@ -83,7 +83,7 @@ steps: # Install required dependencies echo "Installing dependencies..." - apt-get install -y -qq curl ca-certificates systemd + apt-get install -y -qq curl ca-certificates # Add log4tc repository echo "Adding log4tc repository..." From 7f207767d13cf3d5f379ded7d539b60d844448db Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 20:02:23 +0000 Subject: [PATCH 4/5] Fix URL casing in README to match installation documentation Co-authored-by: bqstony <10487253+bqstony@users.noreply.github.com> --- .../templates/log4tc/README-test-deb-installation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azure-pipelines/templates/log4tc/README-test-deb-installation.md b/.azure-pipelines/templates/log4tc/README-test-deb-installation.md index 33f9c03..ccbe71b 100644 --- a/.azure-pipelines/templates/log4tc/README-test-deb-installation.md +++ b/.azure-pipelines/templates/log4tc/README-test-deb-installation.md @@ -25,7 +25,7 @@ This pipeline template tests the installation and functionality of the log4tc De ## Requirements - Docker and Docker Compose must be available on the build agent -- The log4tc Debian repository must be accessible at https://mbc-engineering.github.io/log4tc/deb +- The log4tc Debian repository must be accessible at https://mbc-engineering.github.io/log4TC/deb ## Test Results From 198cce41c592c27efe571b36da07630a1bec6f28 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Mon, 5 Jan 2026 20:03:37 +0000 Subject: [PATCH 5/5] Improve error detection clarity in test script with informational comments Co-authored-by: bqstony <10487253+bqstony@users.noreply.github.com> --- .../templates/log4tc/test-deb-installation.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.azure-pipelines/templates/log4tc/test-deb-installation.yaml b/.azure-pipelines/templates/log4tc/test-deb-installation.yaml index 1fab363..3893af6 100644 --- a/.azure-pipelines/templates/log4tc/test-deb-installation.yaml +++ b/.azure-pipelines/templates/log4tc/test-deb-installation.yaml @@ -168,13 +168,15 @@ steps: echo "✓ InfluxDB output plugin appears to be loaded" fi - # Check for errors + # Check for errors (note: this is informational only, not a test failure) + # Shows any lines containing common error indicators for troubleshooting if grep -qi "error\|exception\|failed" /var/log/log4tc/service.log; then - echo "⚠ Warning: Errors detected in log file" - echo "Showing error lines:" + echo "⚠ Warning: Potential errors detected in log file" + echo "Showing lines with error indicators:" grep -i "error\|exception\|failed" /var/log/log4tc/service.log || true + echo "(Note: Some matches may be false positives - review context above)" else - echo "✓ No errors detected in log file" + echo "✓ No common error indicators detected in log file" fi else