@@ -2,6 +2,7 @@ package e2edb
22
33import (
44 "fmt"
5+ "path/filepath"
56 "strings"
67
78 "github.com/cortexproject/cortex/integration/e2e"
@@ -15,11 +16,23 @@ const (
1516
1617// NewMinio returns minio server, used as a local replacement for S3.
1718func NewMinio (port int , bktNames ... string ) * e2e.HTTPService {
18- minioKESGithubContent := "https://raw.githubusercontent.com/minio/kes/master"
19- commands := []string {
20- fmt .Sprintf ("curl -sSL --tlsv1.2 -O '%s/root.key' -O '%s/root.cert'" , minioKESGithubContent , minioKESGithubContent ),
19+ return newMinio (port , map [string ]string {}, bktNames ... )
20+ }
21+
22+ // NewMinioWithKES returns minio server, configured to talk to a KES service.
23+ func NewMinioWithKES (port int , kesEndpoint , rootKeyFile , rootCertFile , caCertFile string , bktNames ... string ) * e2e.HTTPService {
24+ kesEnvVars := map [string ]string {
25+ "MINIO_KMS_KES_ENDPOINT" : kesEndpoint ,
26+ "MINIO_KMS_KES_KEY_FILE" : filepath .Join (e2e .ContainerSharedDir , rootKeyFile ),
27+ "MINIO_KMS_KES_CERT_FILE" : filepath .Join (e2e .ContainerSharedDir , rootCertFile ),
28+ "MINIO_KMS_KES_CAPATH" : filepath .Join (e2e .ContainerSharedDir , caCertFile ),
29+ "MINIO_KMS_KES_KEY_NAME" : "my-minio-key" ,
2130 }
31+ return newMinio (port , kesEnvVars , bktNames ... )
32+ }
2233
34+ func newMinio (port int , envVars map [string ]string , bktNames ... string ) * e2e.HTTPService {
35+ commands := []string {}
2336 for _ , bkt := range bktNames {
2437 commands = append (commands , fmt .Sprintf ("mkdir -p /data/%s" , bkt ))
2538 }
@@ -33,17 +46,27 @@ func NewMinio(port int, bktNames ...string) *e2e.HTTPService {
3346 e2e .NewHTTPReadinessProbe (port , "/minio/health/ready" , 200 , 200 ),
3447 port ,
3548 )
36- m .SetEnvVars (map [string ]string {
37- "MINIO_ACCESS_KEY" : MinioAccessKey ,
38- "MINIO_SECRET_KEY" : MinioSecretKey ,
39- "MINIO_BROWSER" : "off" ,
40- "ENABLE_HTTPS" : "0" ,
41- // https://docs.min.io/docs/minio-kms-quickstart-guide.html
42- "MINIO_KMS_KES_ENDPOINT" : "https://play.min.io:7373" ,
43- "MINIO_KMS_KES_KEY_FILE" : "root.key" ,
44- "MINIO_KMS_KES_CERT_FILE" : "root.cert" ,
45- "MINIO_KMS_KES_KEY_NAME" : "my-minio-key" ,
46- })
49+ envVars ["MINIO_ACCESS_KEY" ] = MinioAccessKey
50+ envVars ["MINIO_SECRET_KEY" ] = MinioSecretKey
51+ envVars ["MINIO_BROWSER" ] = "off"
52+ envVars ["ENABLE_HTTPS" ] = "0"
53+ m .SetEnvVars (envVars )
54+ return m
55+ }
56+
57+ // NewKES returns KES server, used as a local key management store
58+ func NewKES (port int , serverKeyFile , serverCertFile , rootCertFile string ) * e2e.HTTPService {
59+ // Run this as a shell command, so sub-shell can evaluate 'identity' of root user.
60+ command := fmt .Sprintf ("/kes server --addr 0.0.0.0:%d --key=%s --cert=%s --root=$(/kes tool identity of %s) --auth=off --quiet" ,
61+ port , filepath .Join (e2e .ContainerSharedDir , serverKeyFile ), filepath .Join (e2e .ContainerSharedDir , serverCertFile ), filepath .Join (e2e .ContainerSharedDir , rootCertFile ))
62+
63+ m := e2e .NewHTTPService (
64+ "kes" ,
65+ images .KES ,
66+ e2e .NewCommandWithoutEntrypoint ("sh" , "-c" , command ),
67+ nil , // KES only supports https calls - TODO make Scenario able to call https or poll plain TCP socket.
68+ port ,
69+ )
4770 return m
4871}
4972
0 commit comments