-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0b6d5ea
commit 87b565b
Showing
24 changed files
with
2,844 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Acceptance test | ||
|
||
## Description | ||
1. Runs main test: | ||
1. Creates snapshot from the disk (via `ycp`), then creates incremental snapshot and disk from this snapshot (via `ycp`). | ||
2. Creates pooled image from snapshot (via `ycp`), then creates disk from this image (via `ycp`). | ||
3. Creates image from disk, created on step 1.1 .(via `ycp`), then creates image from this image (via `ycp`). | ||
2. Runs cancel test: | ||
1. Asynchronously creates snapshot for every disk (via `ycp`). | ||
2. Tries to delete snapshot while it is in CREATING status (via `ycp`). | ||
3. Checks that snapshot was successfully deleted (via `ycp`). | ||
|
||
## Usage | ||
Install `ycp` and reload shell: | ||
```(bash) | ||
$ curl https://s3.mds.yandex.net/mcdev/ycp/install.sh | bash | ||
$ cat > ~/.bashrc <<EOF | ||
PATH="$HOME/ycp/bin/:$PATH" | ||
EOF | ||
``` | ||
|
||
Install `ycp` configuration for tests: | ||
```(bash) | ||
$ mkdir -p ~/.config/ycp/ | ||
$ mv ~/.config/ycp/config.yaml ~/.config/ycp/config.yaml.bak | ||
$ cp ../../../packages/yc-nbs-ci-tools/ycp-config.yaml ~/.config/ycp/config.yaml | ||
``` | ||
|
||
Patch `/etc/hosts` to be able to use `ycp` with `hw-nbs-stable-lab`: | ||
```(bash) | ||
$ export HW_NBS_STABLE_LAB_SEED_IP=$(host $(pssh list C@cloud_hw-nbs-stable-lab_seed) | awk '{print $5}') | ||
$ echo -e "\n# ycp hack for hw-nbs-stable-lab\n$HW_NBS_STABLE_LAB_SEED_IP local-lb.cloud-lab.yandex.net" | sudo tee -a /etc/hosts | ||
``` | ||
|
||
Create `/etc/ssl/certs/hw-nbs-stable-lab.pem` with the content https://paste.yandex-team.ru/3966169 | ||
|
||
Save private ssh key from https://yav.yandex-team.ru/secret/sec-01ehpt7c9ez5g4j9nx4g4yegj3/explore/version/ver-01ehpt7c9ng1t28517aqjpavd5 to ~/.ssh/overlay, then `ssh-add ~/.ssh/overlay` | ||
|
||
Build `acceptance-test`: | ||
```(bash) | ||
$ ya make | ||
``` | ||
|
||
Example: | ||
```(bash) | ||
$ ./acceptance --profile hw-nbs-stable-lab --folder-id yc.dogfood.serviceFolder --src-disk-ids <any_disk_id>,<another_disk_id> --verbose | ||
``` | ||
|
||
## Leaked resources | ||
There is a possibility when the test can leave leaked resources inside the cloud. So if it is happened: | ||
1. Find all snapshots inside the cluster with the name pattern `acceptance-test-snapshot-<suffix>-<timestamp>` and delete them manually. | ||
2. Find all images inside the cluster with the name pattern `acceptance-test-image-<suffix>-<timestamp>` and delete them manually. | ||
3. Find all disks inside the cluster with the name pattern `acceptance-test-disk-<suffix>-<timestamp>` and delete them manually. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#include <library/cpp/getopt/last_getopt.h> | ||
#include <library/cpp/logger/log.h> | ||
|
||
#include <util/datetime/base.h> | ||
#include <util/string/builder.h> | ||
#include <util/system/file.h> | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
struct TParams | ||
{ | ||
bool Verbose = false; | ||
size_t Bytes = 0; | ||
size_t IgnoreInitial = 0; | ||
size_t ChunkSize = 4 * 1024 * 1024; | ||
int MaxRetriesAfterFailure = 5; | ||
TString File1; | ||
TString File2; | ||
}; | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
int Run(const TParams& params) | ||
{ | ||
TLog log(CreateLogBackend("cout")); | ||
log.SetFormatter([] (ELogPriority, TStringBuf msg) { | ||
return TStringBuilder() << "[" << TInstant::Now().FormatLocalTime("%Y-%m-%d %H:%M:%S") << "] " << msg; | ||
}); | ||
|
||
auto f1 = TFile(params.File1, RdOnly | DirectAligned); | ||
auto f2 = TFile(params.File2, RdOnly | DirectAligned); | ||
|
||
f1.Seek(params.IgnoreInitial, sSet); | ||
f2.Seek(params.IgnoreInitial, sSet); | ||
|
||
TVector<ui8> buf1(params.ChunkSize); | ||
TVector<ui8> buf2(params.ChunkSize); | ||
|
||
int retriesAfterFailure = 0; | ||
size_t offset = 0; | ||
while (offset < params.Bytes) { | ||
f1.Load(buf1.data(), buf1.size()); | ||
f2.Load(buf2.data(), buf2.size()); | ||
|
||
bool failed = false; | ||
for (size_t i = 0; i < buf1.size(); i++) { | ||
if (buf1[i] != buf2[i]) { | ||
log << offset + i << " " << (ui32)buf1[i] << " " << (ui32)buf2[i] << Endl; | ||
failed = true; | ||
} | ||
} | ||
|
||
if (failed) { | ||
if (retriesAfterFailure < params.MaxRetriesAfterFailure) { | ||
retriesAfterFailure++; | ||
log << "files mismatch, retry " << retriesAfterFailure << Endl; | ||
|
||
f1.Seek(-params.ChunkSize, sCur); | ||
f2.Seek(-params.ChunkSize, sCur); | ||
continue; | ||
} | ||
|
||
log << "max number of retries after failure reached, abort" << Endl; | ||
return 1; | ||
} | ||
|
||
if (retriesAfterFailure > 0) { | ||
log << "retry after failure succeeded at offset " << offset << Endl; | ||
return 1; | ||
} | ||
|
||
offset += params.ChunkSize; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
int main(int argc, char** argv) | ||
{ | ||
TParams params; | ||
|
||
NLastGetopt::TOpts opts; | ||
opts.AddLongOption("verbose").NoArgument().StoreResult(¶ms.Verbose); | ||
opts.AddLongOption("bytes").StoreResult(¶ms.Bytes); | ||
opts.AddLongOption("ignore-initial").StoreResult(¶ms.IgnoreInitial); | ||
opts.AddLongOption("chunk-size").StoreResult(¶ms.ChunkSize); | ||
opts.AddLongOption("max-retries-after-failure").StoreResult( | ||
¶ms.MaxRetriesAfterFailure); | ||
opts.AddFreeArgBinding("file1", params.File1); | ||
opts.AddFreeArgBinding("file2", params.File2); | ||
opts.SetFreeArgsMax(2); | ||
|
||
NLastGetopt::TOptsParseResult r(&opts, argc, argv); | ||
|
||
return Run(params); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
OWNER(g:cloud-nbs) | ||
|
||
PROGRAM(acceptance-cmp) | ||
|
||
SRCS( | ||
main.cpp | ||
) | ||
|
||
PEERDIR( | ||
library/cpp/getopt/small | ||
library/cpp/logger | ||
) | ||
|
||
END() |
Oops, something went wrong.