also looking at this
test(fleet): prove the database and hostname halves of a transfer on real machines
#184
4 files
+363
-3
| @@ -149,6 +149,17 @@ describe('buildSetHostnameScript', () => { | ||
| 149 | 149 | it('replaces the existing 127.0.1.1 line rather than appending a second', () => { |
| 150 | 150 | const script = buildSetHostnameScript('hq-production-server') |
| 151 | 151 | expect(script).toContain('s/^127\\.0\\.1\\.1.*/127.0.1.1\\thq-production-server/') |
| 152 | expect(script).toContain('if grep -q "127.0.1.1" /etc/hosts; then') | |
| 152 | expect(script).toContain('if grep -q "^127.0.1.1" /etc/hosts; then') | |
| 153 | }) | |
| 154 | ||
| 155 | /** | |
| 156 | * `sed -i` renames a temp file over the target, which fails outright when | |
| 157 | * /etc/hosts is a bind mount — every container — or is hard-linked. Writing | |
| 158 | * the content back in place keeps the inode and works either way. | |
| 159 | */ | |
| 160 | it('rewrites /etc/hosts in place rather than renaming over it', () => { | |
| 161 | const script = buildSetHostnameScript('hq-production-server') | |
| 162 | expect(script).not.toContain('sed -i') | |
| 163 | expect(script).toContain('> /etc/hosts') | |
| 153 | 164 | }) |
| 154 | 165 | }) |