UBER-536: Fix test stability ()

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2023-06-29 12:46:28 +07:00 committed by GitHub
parent ee0754422d
commit cf2ca2ee27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 175 additions and 179 deletions

View File

@ -357,7 +357,12 @@ export function devTool (
.action(async (email: string, cmd) => { .action(async (email: string, cmd) => {
const { mongodbUri } = prepareTools() const { mongodbUri } = prepareTools()
return await withDatabase(mongodbUri, async (db) => { return await withDatabase(mongodbUri, async (db) => {
const account = await getAccount(db, email)
if (account?.confirmed === true) {
console.log(`Already confirmed:${email}`)
} else {
await confirmEmail(db, email) await confirmEmail(db, email)
}
}) })
}) })

View File

@ -1 +1 @@
{ "major": 0, "minor": 6, "patch": 108 } { "major": 0, "minor": 6, "patch": 109 }

View File

@ -625,8 +625,7 @@ export async function restore (
model: 'upgrade' model: 'upgrade'
})) as unknown as CoreClient & BackupClient })) as unknown as CoreClient & BackupClient
async function processDomain (c: Domain): Promise<boolean> { async function processDomain (c: Domain): Promise<void> {
try {
const changeset = await loadDigest(storage, snapshots, c, date) const changeset = await loadDigest(storage, snapshots, c, date)
// We need to load full changeset from server // We need to load full changeset from server
const serverChangeset = new Map<Ref<Doc>, string>() const serverChangeset = new Map<Ref<Doc>, string>()
@ -666,8 +665,7 @@ export async function restore (
// Let's find difference // Let's find difference
const docsToAdd = new Map( const docsToAdd = new Map(
Array.from(changeset.entries()).filter( Array.from(changeset.entries()).filter(
([it]) => ([it]) => !serverChangeset.has(it) || (serverChangeset.has(it) && serverChangeset.get(it) !== changeset.get(it))
!serverChangeset.has(it) || (serverChangeset.has(it) && serverChangeset.get(it) !== changeset.get(it))
) )
) )
const docsToRemove = Array.from(serverChangeset.keys()).filter((it) => !changeset.has(it)) const docsToRemove = Array.from(serverChangeset.keys()).filter((it) => !changeset.has(it))
@ -797,21 +795,24 @@ export async function restore (
await connection.clean(c, part) await connection.clean(c, part)
} }
} }
return true
} catch (err: any) {
console.log('error', err)
return false
}
} }
try { try {
for (const c of domains) { for (const c of domains) {
console.log('loading server changeset for', c) console.log('loading server changeset for', c)
let retry = 3 let retry = 5
while (retry > 0) { while (retry > 0) {
retry-- retry--
if (await processDomain(c)) { try {
await processDomain(c)
break break
} catch (err: any) {
if (retry === 0) {
console.log('error', err)
} else {
console.log('Wait for few seconds for elastic')
await new Promise((resolve) => setTimeout(resolve, 1000))
}
} }
} }
} }

View File

@ -18,9 +18,6 @@ services:
- 9002:9000 - 9002:9000
elastic: elastic:
image: 'elasticsearch:7.14.2' image: 'elasticsearch:7.14.2'
command: |
/bin/sh -c "./bin/elasticsearch-plugin list | grep -q ingest-attachment || yes | ./bin/elasticsearch-plugin install --silent ingest-attachment;
/usr/local/bin/docker-entrypoint.sh eswrapper"
expose: expose:
- 9200 - 9200
ports: ports:

View File

@ -4,6 +4,8 @@ docker-compose -p sanity kill
docker-compose -p sanity down --volumes docker-compose -p sanity down --volumes
docker-compose -p sanity up -d --force-recreate --renew-anon-volumes docker-compose -p sanity up -d --force-recreate --renew-anon-volumes
./wait-elastic.sh 9201
# Creae workspace record in accounts # Creae workspace record in accounts
./tool.sh create-workspace sanity-ws -o SanityTest ./tool.sh create-workspace sanity-ws -o SanityTest
# Create user record in accounts # Create user record in accounts

View File

@ -1,26 +0,0 @@
res=''
port=$1
echo "Warning Elastic to up and running with attachment processor... ${port}"
while true
do
res=$(curl -s -XPUT "localhost:${port}/_ingest/pipeline/attachment?pretty" -H 'Content-Type: application/json' -d'
{
"description" : "Field for processing file attachments",
"processors" : [
{
"attachment" : {
"field" : "data"
},
"remove" : {
"field" : "data"
}
}
]
}
')
if [[ $res = *"acknowledged"* ]]; then
echo "Elastic processor is up and running..."
exit 0
fi
sleep 1
done

17
tests/wait-elastic.sh Executable file
View File

@ -0,0 +1,17 @@
res=''
port=$1
echo "Warning Elastic to up and running with attachment processor... ${port}"
for i in `seq 1 30`;
do
res=$(curl -s http://localhost:${port}/_cluster/health )
echo "$res"
if [[ $res = *"yellow"* ]]; then
echo "Elastic up and running..."
exit 0
fi
if [[ $res = *"green"* ]]; then
echo "Elastic up and running..."
exit 0
fi
sleep 1
done