postgresai 0.14.0-dev.60 → 0.14.0-dev.62
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/postgres-ai.ts +51 -17
- package/bunfig.toml +3 -2
- package/dist/bin/postgres-ai.js +41 -14
- package/lib/metrics-embedded.ts +1 -1
- package/package.json +1 -1
- package/test/checkup.integration.test.ts +5 -4
- package/test/init.integration.test.ts +2 -1
package/bin/postgres-ai.ts
CHANGED
|
@@ -1765,34 +1765,68 @@ mon
|
|
|
1765
1765
|
});
|
|
1766
1766
|
mon
|
|
1767
1767
|
.command("clean")
|
|
1768
|
-
.description("cleanup monitoring services artifacts")
|
|
1769
|
-
.
|
|
1770
|
-
|
|
1768
|
+
.description("cleanup monitoring services artifacts (stops services and removes volumes)")
|
|
1769
|
+
.option("--keep-volumes", "keep data volumes (only stop and remove containers)")
|
|
1770
|
+
.action(async (options: { keepVolumes?: boolean }) => {
|
|
1771
|
+
console.log("Cleaning up monitoring services...\n");
|
|
1771
1772
|
|
|
1772
1773
|
try {
|
|
1773
|
-
//
|
|
1774
|
-
const
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1774
|
+
// First, use docker-compose down to properly stop and remove containers/volumes
|
|
1775
|
+
const downArgs = options.keepVolumes ? ["down"] : ["down", "-v"];
|
|
1776
|
+
console.log(options.keepVolumes
|
|
1777
|
+
? "Stopping and removing containers (keeping volumes)..."
|
|
1778
|
+
: "Stopping and removing containers and volumes...");
|
|
1779
|
+
|
|
1780
|
+
const downCode = await runCompose(downArgs);
|
|
1781
|
+
if (downCode === 0) {
|
|
1782
|
+
console.log("✓ Monitoring services stopped and removed");
|
|
1779
1783
|
} else {
|
|
1780
|
-
console.log("
|
|
1784
|
+
console.log("⚠ Could not stop services (may not be running)");
|
|
1785
|
+
}
|
|
1786
|
+
|
|
1787
|
+
// Remove orphaned volumes from previous installs with different project names
|
|
1788
|
+
if (!options.keepVolumes) {
|
|
1789
|
+
const volumePatterns = [
|
|
1790
|
+
"monitoring_grafana_data",
|
|
1791
|
+
"monitoring_postgres_ai_configs",
|
|
1792
|
+
"monitoring_sink_postgres_data",
|
|
1793
|
+
"monitoring_target_db_data",
|
|
1794
|
+
"monitoring_victoria_metrics_data",
|
|
1795
|
+
"postgres_ai_configs_grafana_data",
|
|
1796
|
+
"postgres_ai_configs_sink_postgres_data",
|
|
1797
|
+
"postgres_ai_configs_target_db_data",
|
|
1798
|
+
"postgres_ai_configs_victoria_metrics_data",
|
|
1799
|
+
"postgres_ai_configs_postgres_ai_configs",
|
|
1800
|
+
];
|
|
1801
|
+
|
|
1802
|
+
const { stdout: existingVolumes } = await execFilePromise("docker", ["volume", "ls", "-q"]);
|
|
1803
|
+
const volumeList = existingVolumes.trim().split('\n').filter(Boolean);
|
|
1804
|
+
const orphanedVolumes = volumeList.filter(v => volumePatterns.includes(v));
|
|
1805
|
+
|
|
1806
|
+
if (orphanedVolumes.length > 0) {
|
|
1807
|
+
let removedCount = 0;
|
|
1808
|
+
for (const vol of orphanedVolumes) {
|
|
1809
|
+
try {
|
|
1810
|
+
await execFilePromise("docker", ["volume", "rm", vol]);
|
|
1811
|
+
removedCount++;
|
|
1812
|
+
} catch {
|
|
1813
|
+
// Volume might be in use, skip silently
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
if (removedCount > 0) {
|
|
1817
|
+
console.log(`✓ Removed ${removedCount} orphaned volume(s) from previous installs`);
|
|
1818
|
+
}
|
|
1819
|
+
}
|
|
1781
1820
|
}
|
|
1782
1821
|
|
|
1783
|
-
// Remove
|
|
1784
|
-
await execFilePromise("docker", ["volume", "prune", "-f"]);
|
|
1785
|
-
console.log("✓ Removed unused volumes");
|
|
1786
|
-
|
|
1787
|
-
// Remove unused networks
|
|
1822
|
+
// Remove any dangling resources
|
|
1788
1823
|
await execFilePromise("docker", ["network", "prune", "-f"]);
|
|
1789
1824
|
console.log("✓ Removed unused networks");
|
|
1790
1825
|
|
|
1791
|
-
// Remove dangling images
|
|
1792
1826
|
await execFilePromise("docker", ["image", "prune", "-f"]);
|
|
1793
1827
|
console.log("✓ Removed dangling images");
|
|
1794
1828
|
|
|
1795
|
-
console.log("\
|
|
1829
|
+
console.log("\n✓ Cleanup completed - ready for fresh install");
|
|
1796
1830
|
} catch (error) {
|
|
1797
1831
|
const message = error instanceof Error ? error.message : String(error);
|
|
1798
1832
|
console.error(`Error during cleanup: ${message}`);
|
package/bunfig.toml
CHANGED
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
# https://bun.sh/docs/runtime/bunfig
|
|
3
3
|
|
|
4
4
|
[test]
|
|
5
|
-
# Default timeout for all tests (
|
|
5
|
+
# Default timeout for all tests (60 seconds)
|
|
6
6
|
# Integration tests that connect to databases need longer timeouts
|
|
7
|
-
|
|
7
|
+
# PostgreSQL startup can take up to 30s in slow CI environments
|
|
8
|
+
timeout = 60000
|
|
8
9
|
|
|
9
10
|
# Coverage settings - enabled by default for test runs
|
|
10
11
|
coverage = true
|
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13064,7 +13064,7 @@ var {
|
|
|
13064
13064
|
// package.json
|
|
13065
13065
|
var package_default = {
|
|
13066
13066
|
name: "postgresai",
|
|
13067
|
-
version: "0.14.0-dev.
|
|
13067
|
+
version: "0.14.0-dev.62",
|
|
13068
13068
|
description: "postgres_ai CLI",
|
|
13069
13069
|
license: "Apache-2.0",
|
|
13070
13070
|
private: false,
|
|
@@ -15887,7 +15887,7 @@ var Result = import_lib.default.Result;
|
|
|
15887
15887
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
15888
15888
|
var defaults = import_lib.default.defaults;
|
|
15889
15889
|
// package.json
|
|
15890
|
-
var version = "0.14.0-dev.
|
|
15890
|
+
var version = "0.14.0-dev.62";
|
|
15891
15891
|
var package_default2 = {
|
|
15892
15892
|
name: "postgresai",
|
|
15893
15893
|
version,
|
|
@@ -27748,27 +27748,54 @@ Stopping services and removing data...`);
|
|
|
27748
27748
|
process.exitCode = 1;
|
|
27749
27749
|
}
|
|
27750
27750
|
});
|
|
27751
|
-
mon.command("clean").description("cleanup monitoring services artifacts").action(async () => {
|
|
27752
|
-
console.log(`Cleaning up
|
|
27751
|
+
mon.command("clean").description("cleanup monitoring services artifacts (stops services and removes volumes)").option("--keep-volumes", "keep data volumes (only stop and remove containers)").action(async (options) => {
|
|
27752
|
+
console.log(`Cleaning up monitoring services...
|
|
27753
27753
|
`);
|
|
27754
27754
|
try {
|
|
27755
|
-
const
|
|
27756
|
-
|
|
27757
|
-
|
|
27758
|
-
|
|
27759
|
-
|
|
27760
|
-
console.log("\u2713 Removed stopped containers");
|
|
27755
|
+
const downArgs = options.keepVolumes ? ["down"] : ["down", "-v"];
|
|
27756
|
+
console.log(options.keepVolumes ? "Stopping and removing containers (keeping volumes)..." : "Stopping and removing containers and volumes...");
|
|
27757
|
+
const downCode = await runCompose(downArgs);
|
|
27758
|
+
if (downCode === 0) {
|
|
27759
|
+
console.log("\u2713 Monitoring services stopped and removed");
|
|
27761
27760
|
} else {
|
|
27762
|
-
console.log("\
|
|
27761
|
+
console.log("\u26A0 Could not stop services (may not be running)");
|
|
27762
|
+
}
|
|
27763
|
+
if (!options.keepVolumes) {
|
|
27764
|
+
const volumePatterns = [
|
|
27765
|
+
"monitoring_grafana_data",
|
|
27766
|
+
"monitoring_postgres_ai_configs",
|
|
27767
|
+
"monitoring_sink_postgres_data",
|
|
27768
|
+
"monitoring_target_db_data",
|
|
27769
|
+
"monitoring_victoria_metrics_data",
|
|
27770
|
+
"postgres_ai_configs_grafana_data",
|
|
27771
|
+
"postgres_ai_configs_sink_postgres_data",
|
|
27772
|
+
"postgres_ai_configs_target_db_data",
|
|
27773
|
+
"postgres_ai_configs_victoria_metrics_data",
|
|
27774
|
+
"postgres_ai_configs_postgres_ai_configs"
|
|
27775
|
+
];
|
|
27776
|
+
const { stdout: existingVolumes } = await execFilePromise("docker", ["volume", "ls", "-q"]);
|
|
27777
|
+
const volumeList = existingVolumes.trim().split(`
|
|
27778
|
+
`).filter(Boolean);
|
|
27779
|
+
const orphanedVolumes = volumeList.filter((v) => volumePatterns.includes(v));
|
|
27780
|
+
if (orphanedVolumes.length > 0) {
|
|
27781
|
+
let removedCount = 0;
|
|
27782
|
+
for (const vol of orphanedVolumes) {
|
|
27783
|
+
try {
|
|
27784
|
+
await execFilePromise("docker", ["volume", "rm", vol]);
|
|
27785
|
+
removedCount++;
|
|
27786
|
+
} catch {}
|
|
27787
|
+
}
|
|
27788
|
+
if (removedCount > 0) {
|
|
27789
|
+
console.log(`\u2713 Removed ${removedCount} orphaned volume(s) from previous installs`);
|
|
27790
|
+
}
|
|
27791
|
+
}
|
|
27763
27792
|
}
|
|
27764
|
-
await execFilePromise("docker", ["volume", "prune", "-f"]);
|
|
27765
|
-
console.log("\u2713 Removed unused volumes");
|
|
27766
27793
|
await execFilePromise("docker", ["network", "prune", "-f"]);
|
|
27767
27794
|
console.log("\u2713 Removed unused networks");
|
|
27768
27795
|
await execFilePromise("docker", ["image", "prune", "-f"]);
|
|
27769
27796
|
console.log("\u2713 Removed dangling images");
|
|
27770
27797
|
console.log(`
|
|
27771
|
-
Cleanup completed`);
|
|
27798
|
+
\u2713 Cleanup completed - ready for fresh install`);
|
|
27772
27799
|
} catch (error2) {
|
|
27773
27800
|
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
27774
27801
|
console.error(`Error during cleanup: ${message}`);
|
package/lib/metrics-embedded.ts
CHANGED
package/package.json
CHANGED
|
@@ -131,11 +131,11 @@ async function createTempPostgres(): Promise<TempPostgres> {
|
|
|
131
131
|
return c;
|
|
132
132
|
};
|
|
133
133
|
|
|
134
|
-
// Wait for Postgres to start
|
|
134
|
+
// Wait for Postgres to start (30s timeout for slower CI environments)
|
|
135
135
|
await waitFor(async () => {
|
|
136
136
|
const c = await connect();
|
|
137
137
|
await c.end();
|
|
138
|
-
});
|
|
138
|
+
}, { timeoutMs: 30000, intervalMs: 100 });
|
|
139
139
|
|
|
140
140
|
return { port, socketDir, cleanup, connect };
|
|
141
141
|
}
|
|
@@ -172,15 +172,16 @@ describe.skipIf(!!skipReason)("checkup integration: express mode schema compatib
|
|
|
172
172
|
let pg: TempPostgres;
|
|
173
173
|
let client: Client;
|
|
174
174
|
|
|
175
|
+
// 60s timeout for hooks - PostgreSQL startup can take 30s+ in slow CI
|
|
175
176
|
beforeAll(async () => {
|
|
176
177
|
pg = await createTempPostgres();
|
|
177
178
|
client = await pg.connect();
|
|
178
|
-
});
|
|
179
|
+
}, { timeout: 60000 });
|
|
179
180
|
|
|
180
181
|
afterAll(async () => {
|
|
181
182
|
if (client) await client.end();
|
|
182
183
|
if (pg) await pg.cleanup();
|
|
183
|
-
});
|
|
184
|
+
}, { timeout: 60000 });
|
|
184
185
|
|
|
185
186
|
// Test all checks supported by express mode
|
|
186
187
|
const expressChecks = Object.keys(checkup.CHECK_INFO);
|
|
@@ -137,10 +137,11 @@ async function createTempPostgres(): Promise<TempPostgres> {
|
|
|
137
137
|
return c;
|
|
138
138
|
};
|
|
139
139
|
|
|
140
|
+
// Wait for Postgres to start (30s timeout for slower CI environments)
|
|
140
141
|
await waitFor(async () => {
|
|
141
142
|
const c = await connectLocal();
|
|
142
143
|
await c.end();
|
|
143
|
-
});
|
|
144
|
+
}, { timeoutMs: 30000, intervalMs: 100 });
|
|
144
145
|
|
|
145
146
|
const postgresPassword = "postgrespw";
|
|
146
147
|
{
|