[{"data":1,"prerenderedAt":480},["ShallowReactive",2],{"project-39960537":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":29,"sentiment":30,"stance_mix":31,"scored_comments":36,"aspects":37,"strip":46,"post_text":48,"what":49,"said":92,"maker_in_thread":227,"shape":234,"grid":238,"attempts":441,"same_week":442,"maker_shows":44,"maker_hidden":472,"reader_version":473,"card":474},"39960537","pgmock","I open-sourced the in-memory PostgreSQL I built at work for E2E tests","title","Show HN: I open-sourced the in-memory PostgreSQL I built at work for E2E tests","https:\u002F\u002Fgithub.com\u002Fstackframe-projects\u002Fpgmock","github.com","n2d4",1712495623,2024,379,79,127,3515,4,"legend","dev_tools","test database","library",[24,25,26,27,28],"postgres in-memory","postgresql testing","wasm postgres","e2e testing","pglite alternative","curious",-0.077,{"positive":32,"neutral":33,"mixed":34,"critical":35},9,22,1,12,44,{"idea":38,"execution":40,"design":41,"performance":43,"privacy":45},{"positive":39,"critical":39},7,{"positive":34,"critical":34},{"positive":42,"critical":42},0,{"positive":42,"critical":44},3,{"positive":42,"critical":34},[42,44,42,47,34,47,44,34,42,44,44,44,44,42,42,47,42,44,47,44,34,47,34,42,47,44,34,34,42,44,44,44,42,34,47,44,47,34,42,34],5,null,{"problem":50,"audience":60,"pricing":48,"motivation":69,"time_to_build":48,"stack":76,"openness":89,"stage":90,"team_size":91},{"value":51,"source":52,"evidence":53},"Running a real Postgres for E2E tests is slow and needs external processes or containers","maker",[54,57],{"id":55,"by":11,"text":56},"39960538","Hey HN! For a few months, I've been building an in-memory version of Postgres at work. It has full feature parity with production databases. The cool thing about it is that you…",{"id":58,"by":11,"text":59},"39962726","That's more or less what happens inside the emulator (the emulated disk is an in-memory 9P file system). It's in WebAssembly because that makes it more portable (same behaviour…",{"value":61,"source":62,"evidence":63},"Developers writing E2E or integration tests against Postgres","inferred",[64,65],{"id":55,"by":11,"text":56},{"id":66,"by":67,"text":68},"39965750","lelandbatey","These kinds of in-process\u002Fin-memory versions of dependencies take the startup time of those test from minutes\u002Fseconds to milliseconds, allowing you to run your tests vastly…",{"value":70,"source":52,"evidence":71},"Built at work for E2E tests and open-sourced",[72,73],{"id":55,"by":11,"text":56},{"id":74,"by":11,"text":75},"39965107","We're a startup, open-sourcing was as easy as getting the rest of the team's approval.",[77,81,85],{"value":78,"source":52,"evidence":79},"WebAssembly",[80],{"id":55,"by":11,"text":56},{"value":82,"source":52,"evidence":83},"x86 emulator",[84],{"id":55,"by":11,"text":56},{"value":86,"source":52,"evidence":87},"JavaScript",[88],{"id":55,"by":11,"text":56},"open_source","launched","company",{"praise":93,"objections":113,"requests":142,"questions":168,"alternatives":195},[94,106],{"value":95,"source":96,"evidence":97},"Fast startup makes tests much quicker","commenter",[98,99,102],{"id":66,"by":67,"text":68},{"id":100,"by":67,"text":101},"39965888","Nah, by having in-memory versions of your dependencies, in-memory versions which fulfill the same interfaces as those used in your E2E tests (or the majority of your E2E tests)…",{"id":103,"by":104,"text":105},"39967324","fullstackchris","This is amazing! I've been looking for an in-memory postgres mock for integration tests for ages!",{"value":107,"source":96,"evidence":108},"Runs in process with no cleanup needed",[109],{"id":110,"by":111,"text":112},"39965226","hamandcheese","The fact that this can run in-process is a big deal, as it means you don't have to worry about cleanup. As soon as you have external processes that your tests depend on, your…",[114,125,135],{"value":115,"source":96,"evidence":116},"Not true E2E since it is not real Postgres",[117,121],{"id":118,"by":119,"text":120},"39965216","sverhagen","It is, however, humanly possible, to run a real Postgres instance in a Docker container. You may use for example Testcontainers. So, I would not resort to an inferior Postgres…",{"id":122,"by":123,"text":124},"39964566","zer00eyz","The whole purpose of End to End testing is that your testing the system in a real state. It's an emulation of your live environment. Because of that you can do interesting things…",{"value":126,"source":96,"evidence":127},"Slow because it runs under emulation",[128,132],{"id":129,"by":130,"text":131},"39968184","danpalmer","> by emulating the Postgres server in an x86 emulator > because performance is not usually a concern in tests I hate to be a downer, especially because it sounds like a lot of…",{"id":133,"by":11,"text":134},"39962519","Yeah, that should be possible! Though, for audio processing, the performance will probably be terrible (because it's all emulated).",{"value":136,"source":96,"evidence":137},"Uses a lot of memory compared to alternatives",[138],{"id":139,"by":140,"text":141},"39967364","theage","For prisma\u002Fnodejs devs who just want postgres-in-a-can for local dev you are better off using the recently released serverizing of pglite, pglite-server:…",[143,150,161],{"value":144,"source":96,"evidence":145},"Support for pgvector extension",[146],{"id":147,"by":148,"text":149},"39965038","nborwankar","If it could support the pgvector extension it would be a super fast vector database with all the power of Pg - the relational aspect brings the ability to add and query using…",{"value":151,"source":96,"evidence":152},"Support for ORMs like Prisma, Sequelize, Drizzle",[153,157],{"id":154,"by":155,"text":156},"39965739","vivzkestrel","support for orms like sequelize, prisma, drizzle for testing?",{"id":158,"by":159,"text":160},"39964385","herpdyderp","This might be a stupid question, but do you know how this might be used with a Prisma client?",{"value":162,"source":96,"evidence":163},"Multi-connection mode and pg_notify support",[164],{"id":165,"by":166,"text":167},"39963649","samwillis","This looks really cool, awesome work! Correct on PGlite only being single user at the moment, and that certainly is a problem for using it for integration tests in some…",[169,181,188],{"value":170,"source":96,"evidence":171},"Why not run Postgres in Docker or on a RAM disk",[172,176,180],{"id":173,"by":174,"text":175},"39962634","rsyring","Why not just run Postgres with it's files on a ramdisk? Update: this can apparently run in a browser\u002FNode environment so can be created\u002Fupdated\u002Fdestroyed by the tests. I guess…",{"id":177,"by":178,"text":179},"39962894","rickette","I used to run all kinds of (custom) fake in-memory servers in my tests. Nowadays I just run the real thing using Testcontainers (https:\u002F\u002Ftestcontainers.com)",{"id":129,"by":130,"text":131},{"value":182,"source":96,"evidence":183},"Which Postgres version it is based on",[184],{"id":185,"by":186,"text":187},"39962679","andrelaszlo","Cool! Which pg version is this based on?",{"value":189,"source":96,"evidence":190},"Whether the binary blobs in src\u002Fbinaries are needed",[191],{"id":192,"by":193,"text":194},"39972561","henning","Why is there a set of binary blobs in the `src\u002Fbinaries` directory? I don't want to use projects that have that if there isn't a good reason for it.",[196,201,208,216],{"value":197,"source":96,"evidence":198},"PGlite",[199,200],{"id":165,"by":166,"text":167},{"id":139,"by":140,"text":141},{"value":202,"source":96,"evidence":203},"pg-mem",[204],{"id":205,"by":206,"text":207},"39965313","geuis","I've used pgmem https:\u002F\u002Fgithub.com\u002Foguimbal\u002Fpg-mem for the last couple of years for the same thing.",{"value":209,"source":96,"evidence":210},"Testcontainers",[211,212],{"id":177,"by":178,"text":179},{"id":213,"by":214,"text":215},"39962710","orphea","I don't get it either. I feel like this is so much unnecessary code, an emulator, a network stack... Why not use something like https:\u002F\u002Ftestcontainers.com\u002F? Is a container engine…",{"value":217,"source":96,"evidence":218},"Template databases with CREATE DATABASE FROM TEMPLATE",[219,223],{"id":220,"by":221,"text":222},"39966290","stickfigure","You can bring \"real postgres\" test startup times back to milliseconds with CREATE DATABASE ... FROM TEMPLATE. Every test gets a fresh database (without having to run migration…",{"id":224,"by":225,"text":226},"39966002","peter_l_downs","OK, that goal makes sense, thanks for explaining. For what it's worth I'm pretty sure you can do this with postgres, tmpfs, and template databases — see my project, pgtestdb [0].…",{"comments":47,"answered":44,"key":228},[229,230,231],{"id":55,"text":56},{"id":133,"text":134},{"id":232,"text":233},"39965141","My bad, gotta fix that one!",{"commenters":235,"max_depth":236,"maker_replies":47,"first_comment_mins":42,"lifespan_hours":237},58,6,53,[239,241,245,247,251,253,255,257,261,265,268,270,273,277,279,281,283,286,289,293,296,297,300,301,302,305,308,311,314,317,319,320,322,324,325,328,330,333,334,335,336,339,342,344,345,348,351,353,354,356,360,363,366,368,369,372,375,378,380,383,386,389,393,396,399,401,405,407,411,413,415,417,419,424,426,430,433,437,439],[55,42,42,240,11,34],"maker\u002Fneutral\u002Fidea",[242,42,44,243,244,42],"39962178","project\u002Fneutral\u002Fidea","waldrews",[133,42,42,246,11,34],"project\u002Fcritical\u002Fperformance",[248,42,42,249,250,42],"39963210","other\u002Fneutral\u002Fnone","jasonjmcghee",[252,42,42,249,244,42],"39965041",[254,42,42,249,250,42],"39966628",[165,42,47,256,166,42],"project\u002Fpositive\u002Fidea",[258,42,34,259,260,42],"39963710","project\u002Fcritical\u002Fexecution","justinclift",[262,42,44,263,264,42],"39964515","project\u002Fneutral\u002Fexecution","rezonant",[266,42,47,267,260,42],"39966904","project\u002Fpositive\u002Fexecution",[232,42,42,269,11,34],"maker\u002Fneutral\u002Fexecution",[271,42,44,243,272,42],"39964308","negus",[274,42,42,275,276,42],"39964322","commenter\u002Fneutral\u002Fnone","refulgentis",[118,42,34,278,119,42],"project\u002Fcritical\u002Fidea",[280,42,44,243,260,42],"39965766",[282,42,42,275,119,42],"39965795",[284,42,42,275,285,42],"39966329","wpietri",[287,42,42,275,288,42],"39967987","cqqxo4zV46cp",[290,42,44,291,292,42],"39964982","project\u002Fneutral\u002Fdesign","MuffinFlavored",[294,42,44,291,295,42],"39965112","anarazel",[147,42,44,243,148,42],[298,42,42,249,299,42],"39966227","J_Shelby_J",[173,34,44,243,174,42],[213,34,44,243,214,42],[303,34,42,275,304,42],"39963629","bastawhiz",[306,34,42,249,307,42],"39963851","medellin",[309,34,42,275,310,42],"39963901","dorianmariefr",[312,34,42,249,313,42],"39964250","c0balt",[315,34,42,249,316,42],"39964447","j45",[318,34,42,249,225,42],"39965357",[110,34,47,256,111,42],[321,34,42,275,214,42],"39967757",[323,34,42,275,111,42],"39982154",[58,34,42,240,11,34],[326,34,44,243,327,42],"39964292","gchamonlive",[329,34,44,243,225,42],"39965334",[331,34,47,256,332,42],"39965533","danmur",[66,34,47,256,67,42],[224,34,34,278,225,42],[220,34,34,278,221,42],[337,34,34,278,338,42],"39966337","CogitoCogito",[340,34,47,256,341,42],"39965942","augunrik",[343,34,42,275,225,42],"39966015",[122,34,34,278,123,42],[346,34,44,347,225,42],"39965345","project\u002Fneutral\u002Fperformance",[349,34,42,275,350,42],"39965834","RussianCow",[352,34,42,275,225,42],"39966027",[100,34,47,256,67,42],[355,34,42,275,285,42],"39966348",[357,34,44,358,359,42],"39966804","project\u002Fmixed\u002Fidea","majikandy",[361,34,44,243,362,42],"39971230","aeyes",[364,34,42,249,365,42],"39973670","LtWorf",[177,367,34,278,178,42],2,[139,44,34,246,140,42],[370,18,34,278,371,42],"39966809","xlii",[373,47,42,249,374,42],"39964531","tumidpandora",[376,47,42,249,377,42],"39964697","Gracana",[74,47,42,379,11,34],"maker\u002Fneutral\u002Fnone",[381,236,44,243,382,42],"39964371","drzaiusx11",[384,236,44,243,385,42],"39971495","noisy_boy",[387,39,44,240,388,42],"39965352","crakhamster01",[390,391,42,249,392,42],"39965500",8,"segmondy",[394,32,44,243,395,42],"39966759","andy_ppp",[397,32,42,249,398,42],"39978388","garashovb",[205,400,42,249,206,42],10,[402,403,42,249,404,42],"39966912",11,"davvid",[192,35,34,406,193,42],"project\u002Fcritical\u002Fprivacy",[408,409,44,347,410,42],"39966980",13,"KingOfCoders",[103,412,47,256,104,42],14,[185,414,44,263,186,42],15,[416,414,44,263,260,42],"39963726",[158,418,44,263,159,42],16,[420,421,47,422,423,42],"39967587",17,"maker\u002Fpositive\u002Fnone","camgunz",[129,425,34,246,130,42],18,[427,425,42,428,429,42],"39968787","commenter\u002Fneutral\u002Fidea","thibaut_barrere",[431,425,42,432,130,42],"39969007","commenter\u002Fcritical\u002Fidea",[434,425,42,435,436,42],"39969940","other\u002Fneutral\u002Fperformance","pmarreck",[438,425,34,246,130,42],"39970950",[154,440,44,263,155,42],19,[],[443,448,453,458,463,467],{"id":444,"name":445,"points":446,"category":447},"39976640","I made a discrete logic network card",541,"hardware",{"id":449,"name":450,"points":451,"category":452},"39980222","PriceLevel",532,"web_saas",{"id":454,"name":455,"points":456,"category":457},"39992817","Sonauto",454,"ai",{"id":459,"name":460,"points":461,"category":462},"39990346","ADS-B",339,"data",{"id":464,"name":465,"points":466,"category":20},"39955944","drawDB",311,{"id":468,"name":469,"points":470,"category":471},"39941232","Kyoo",258,"infrastructure",false,"v2",{"id":475,"name":5,"line":6,"ai":472,"cat":20,"year":13,"points":14,"comments":15,"rec":29,"s":476,"top":18,"kw":477,"maker":11,"domain":10,"tier":19,"attempts":42,"strip":478,"url":9,"mix":479,"praise":95,"objection":115,"sub":21},39960537,-0.08,[24,25,26,27,28],"0305153103333005035315105311033301535101",[32,33,34,35],1794036652581]