Skip to content

Commit 184b49e

Browse files
committed
Remove deprecated test (because gsutil)
1 parent 371e476 commit 184b49e

File tree

9 files changed

+7
-965
lines changed

9 files changed

+7
-965
lines changed

components/content-service/go.mod

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -27,59 +27,45 @@ require (
2727

2828
require (
2929
github.com/fsouza/fake-gcs-server v1.38.3
30-
github.com/testcontainers/testcontainers-go v0.13.0
3130
golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c
32-
k8s.io/apimachinery v0.24.2
3331
)
3432

3533
require (
3634
cloud.google.com/go v0.102.1 // indirect
3735
cloud.google.com/go/compute v1.7.0 // indirect
3836
cloud.google.com/go/iam v0.3.0 // indirect
3937
cloud.google.com/go/pubsub v1.23.0 // indirect
40-
github.com/Azure/go-ansiterm v0.0.0-20210617225240-d185dfc1b5a1 // indirect
41-
github.com/Microsoft/go-winio v0.4.17 // indirect
42-
github.com/Microsoft/hcsshim v0.8.23 // indirect
38+
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
4339
github.com/beorn7/perks v1.0.1 // indirect
44-
github.com/cenkalti/backoff/v4 v4.1.2 // indirect
4540
github.com/cespare/xxhash/v2 v2.1.2 // indirect
46-
github.com/containerd/cgroups v1.0.4 // indirect
47-
github.com/containerd/containerd v1.5.9 // indirect
4841
github.com/davecgh/go-spew v1.1.1 // indirect
49-
github.com/docker/distribution v2.7.1+incompatible // indirect
50-
github.com/docker/docker v20.10.11+incompatible // indirect
51-
github.com/docker/go-connections v0.4.0 // indirect
52-
github.com/docker/go-units v0.4.0 // indirect
5342
github.com/dustin/go-humanize v1.0.0 // indirect
5443
github.com/felixge/httpsnoop v1.0.2 // indirect
55-
github.com/gogo/protobuf v1.3.2 // indirect
5644
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
5745
github.com/golang/protobuf v1.5.2 // indirect
5846
github.com/google/uuid v1.3.0 // indirect
5947
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
6048
github.com/googleapis/gax-go/v2 v2.4.0 // indirect
6149
github.com/googleapis/go-type-adapters v1.0.0 // indirect
50+
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
6251
github.com/gorilla/handlers v1.5.1 // indirect
6352
github.com/gorilla/mux v1.8.0 // indirect
6453
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
6554
github.com/hashicorp/golang-lru v0.5.1 // indirect
6655
github.com/heptiolabs/healthcheck v0.0.0-20211123025425-613501dd5deb // indirect
6756
github.com/inconshreveable/mousetrap v1.0.0 // indirect
6857
github.com/json-iterator/go v1.1.12 // indirect
58+
github.com/jtolds/gls v4.20.0+incompatible // indirect
6959
github.com/klauspost/compress v1.13.5 // indirect
7060
github.com/klauspost/cpuid v1.3.1 // indirect
71-
github.com/magiconair/properties v1.8.5 // indirect
61+
github.com/kr/text v0.2.0 // indirect
7262
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
7363
github.com/minio/md5-simd v1.1.0 // indirect
7464
github.com/minio/sha256-simd v0.1.1 // indirect
7565
github.com/mitchellh/go-homedir v1.1.0 // indirect
76-
github.com/moby/sys/mount v0.2.0 // indirect
77-
github.com/moby/sys/mountinfo v0.5.0 // indirect
78-
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
7966
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
8067
github.com/modern-go/reflect2 v1.0.2 // indirect
81-
github.com/morikuni/aec v0.0.0-20170113033406-39771216ff4c // indirect
82-
github.com/opencontainers/runc v1.0.2 // indirect
68+
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
8369
github.com/pkg/errors v0.9.1 // indirect
8470
github.com/pkg/xattr v0.4.7 // indirect
8571
github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -88,6 +74,7 @@ require (
8874
github.com/prometheus/procfs v0.7.3 // indirect
8975
github.com/rs/xid v1.2.1 // indirect
9076
github.com/sirupsen/logrus v1.8.1 // indirect
77+
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d // indirect
9178
github.com/spf13/pflag v1.0.5 // indirect
9279
github.com/stretchr/testify v1.7.5 // indirect
9380
github.com/uber/jaeger-client-go v2.29.1+incompatible // indirect
@@ -100,7 +87,7 @@ require (
10087
golang.org/x/time v0.0.0-20220609170525-579cf78fd858 // indirect
10188
google.golang.org/appengine v1.6.7 // indirect
10289
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
103-
gopkg.in/inf.v0 v0.9.1 // indirect
90+
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
10491
gopkg.in/ini.v1 v1.62.0 // indirect
10592
gopkg.in/yaml.v3 v3.0.1 // indirect
10693
)

components/content-service/go.sum

Lines changed: 0 additions & 630 deletions
Large diffs are not rendered by default.

components/content-service/pkg/storage/gcloud_test.go

Lines changed: 0 additions & 240 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,14 @@
55
package storage
66

77
import (
8-
"archive/tar"
98
"context"
10-
"crypto/rand"
11-
"crypto/tls"
12-
"flag"
13-
"io"
14-
"io/ioutil"
15-
"net/http"
16-
"os"
179
"strings"
1810
"testing"
19-
"time"
2011

2112
gcp_storage "cloud.google.com/go/storage"
2213
"github.com/fsouza/fake-gcs-server/fakestorage"
23-
"github.com/testcontainers/testcontainers-go"
24-
"github.com/testcontainers/testcontainers-go/wait"
2514
"google.golang.org/api/option"
26-
"k8s.io/apimachinery/pkg/api/resource"
2715

28-
csapi "github.com/gitpod-io/gitpod/content-service/api"
2916
"github.com/gitpod-io/gitpod/content-service/api/config"
3017
"github.com/gitpod-io/gitpod/content-service/pkg/archive"
3118
)
@@ -66,230 +53,3 @@ func TestObjectAccessToNonExistentObj(t *testing.T) {
6653
t.Errorf("gcloud storage reported object found despite it being non-existent")
6754
}
6855
}
69-
70-
var runWithDocker = flag.Bool("with-docker", false, "run fake-gcs-server in docker")
71-
72-
func TestObjectUpload(t *testing.T) {
73-
tests := []struct {
74-
Desc string
75-
Name string
76-
Stage config.Stage
77-
Owner string
78-
WorkspaceID string
79-
InstanceID string
80-
Payload func() (string, error)
81-
}{
82-
{"valid 1M backup", DefaultBackup, config.StageDevStaging, "fake-owner", "fake-workspace", "fake-instance", fakeTarPayload("1Mi")},
83-
{"valid 100M backup", DefaultBackup, config.StageDevStaging, "fake-owner", "fake-workspace", "fake-instance", fakeTarPayload("100Mi")},
84-
{"valid 1GB backup", DefaultBackup, config.StageDevStaging, "fake-owner", "fake-workspace", "fake-instance", fakeTarPayload("1Gi")},
85-
}
86-
87-
for _, test := range tests {
88-
t.Run(test.Desc, func(t *testing.T) {
89-
ctx, cancel := context.WithCancel(context.Background())
90-
defer cancel()
91-
92-
var err error
93-
var client *gcp_storage.Client
94-
95-
// use docker to run the fake GCS server
96-
// or start an embed server otherwise
97-
switch *runWithDocker {
98-
case true:
99-
var gcsContainer *fakeGCSContainer
100-
gcsContainer, err = setupFakeStorage(ctx)
101-
if err != nil {
102-
break
103-
}
104-
105-
defer gcsContainer.Terminate(ctx)
106-
107-
client, err = gcp_storage.NewClient(ctx,
108-
option.WithEndpoint(gcsContainer.URI),
109-
option.WithoutAuthentication(),
110-
option.WithHTTPClient(&http.Client{
111-
Transport: &http.Transport{
112-
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
113-
},
114-
}),
115-
)
116-
case false:
117-
// the downside of using the fake server as library is the amount or
118-
// memory used by the test binary (this makes too hard the use of pprof)
119-
var server *fakestorage.Server
120-
server, err = fakestorage.NewServerWithOptions(fakestorage.Options{
121-
Writer: os.Stdout,
122-
})
123-
if err != nil {
124-
break
125-
}
126-
127-
defer server.Stop()
128-
129-
server.CreateBucketWithOpts(fakestorage.CreateBucketOpts{
130-
Name: gcpBucketName(test.Stage, test.Owner),
131-
})
132-
133-
client = server.Client()
134-
}
135-
136-
if err != nil {
137-
t.Fatalf("failed to create GCS client: %v", err)
138-
}
139-
140-
storage := DirectGCPStorage{
141-
Stage: test.Stage,
142-
Username: test.Owner,
143-
WorkspaceName: test.WorkspaceID,
144-
InstanceID: test.InstanceID,
145-
GCPConfig: config.GCPConfig{
146-
Region: "fake-region",
147-
Project: "fake-project",
148-
},
149-
// replace internal (valid) client with fake one
150-
client: client,
151-
}
152-
153-
storage.ObjectAccess = storage.defaultObjectAccess
154-
155-
bucket := storage.client.Bucket(gcpBucketName(test.Stage, test.Owner))
156-
err = bucket.Create(context.Background(), "fake-project", nil)
157-
if err != nil {
158-
t.Fatal(err)
159-
}
160-
161-
t.Log("creating fake tar file...")
162-
payloadPath, err := test.Payload()
163-
if err != nil {
164-
t.Fatalf("error creating test file: %v", err)
165-
}
166-
defer os.Remove(payloadPath)
167-
168-
_, _, err = storage.Upload(ctx, payloadPath, test.Name, WithContentType(csapi.ContentTypeManifest))
169-
if err != nil {
170-
t.Fatalf("error uploading file: %v", err)
171-
}
172-
173-
dst, err := ioutil.TempDir("", "gcs-download")
174-
if err != nil {
175-
t.Fatalf("error creating temporal file: %v", err)
176-
}
177-
defer os.RemoveAll(dst)
178-
179-
found, err := storage.Download(ctx, dst, test.Name, []archive.IDMapping{})
180-
if err != nil {
181-
t.Fatalf("error downloading file: %v", err)
182-
}
183-
184-
if !found {
185-
t.Fatal("backup not found")
186-
}
187-
188-
files, err := ioutil.ReadDir(dst)
189-
if err != nil {
190-
t.Fatalf("error reading content of directory: %v", err)
191-
}
192-
193-
if len(files) != 1 {
194-
t.Fatalf("expected 1 file but found %v", len(files))
195-
}
196-
})
197-
}
198-
}
199-
200-
func fakeTarPayload(size string) func() (string, error) {
201-
return func() (string, error) {
202-
payload, err := ioutil.TempFile("", "test-payload-")
203-
if err != nil {
204-
return "", err
205-
}
206-
207-
defer os.Remove(payload.Name())
208-
209-
q, err := resource.ParseQuantity(size)
210-
if err != nil {
211-
return "", err
212-
}
213-
214-
_, err = io.CopyN(payload, rand.Reader, q.Value())
215-
if err != nil {
216-
return "", err
217-
}
218-
219-
tarFile, err := ioutil.TempFile("", "tar-payload-")
220-
if err != nil {
221-
return "", err
222-
}
223-
224-
defer tarFile.Close()
225-
226-
tarWriter := tar.NewWriter(tarFile)
227-
defer tarWriter.Close()
228-
229-
err = addFileToTar(payload.Name(), tarWriter)
230-
if err != nil {
231-
return "", err
232-
}
233-
234-
return tarFile.Name(), nil
235-
}
236-
}
237-
238-
func addFileToTar(filePath string, tarWriter *tar.Writer) error {
239-
file, err := os.Open(filePath)
240-
if err != nil {
241-
return err
242-
}
243-
defer file.Close()
244-
245-
stat, err := file.Stat()
246-
if err != nil {
247-
return err
248-
}
249-
250-
err = tarWriter.WriteHeader(&tar.Header{
251-
Name: file.Name(),
252-
Size: stat.Size(),
253-
Mode: int64(stat.Mode()),
254-
ModTime: stat.ModTime(),
255-
})
256-
if err != nil {
257-
return err
258-
}
259-
260-
_, err = io.Copy(tarWriter, file)
261-
if err != nil {
262-
return err
263-
}
264-
265-
return nil
266-
}
267-
268-
type fakeGCSContainer struct {
269-
testcontainers.Container
270-
271-
URI string
272-
}
273-
274-
func setupFakeStorage(ctx context.Context) (*fakeGCSContainer, error) {
275-
req := testcontainers.ContainerRequest{
276-
Image: "fsouza/fake-gcs-server",
277-
ExposedPorts: []string{"4443/tcp"},
278-
NetworkMode: "host",
279-
Entrypoint: []string{"/bin/fake-gcs-server", "-data=/data", "-backend=filesystem", "-public-host=localhost:4443"},
280-
WaitingFor: wait.ForLog("server started at").WithPollInterval(1 * time.Second),
281-
}
282-
283-
container, err := testcontainers.GenericContainer(ctx, testcontainers.GenericContainerRequest{
284-
ContainerRequest: req,
285-
Started: true,
286-
})
287-
if err != nil {
288-
return nil, err
289-
}
290-
291-
return &fakeGCSContainer{
292-
Container: container,
293-
URI: "https://localhost:4443/storage/v1/",
294-
}, nil
295-
}

components/supervisor/go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ require (
5151
github.com/fatih/structtag v1.2.0 // indirect
5252
github.com/googleapis/enterprise-certificate-proxy v0.1.0 // indirect
5353
github.com/gopherjs/gopherjs v1.17.2 // indirect
54-
github.com/jtolds/gls v4.20.0+incompatible // indirect
5554
github.com/smartystreets/assertions v1.13.0 // indirect
5655
golang.org/x/tools v0.1.5 // indirect
5756
)
@@ -84,15 +83,13 @@ require (
8483
github.com/klauspost/compress v1.15.1 // indirect
8584
github.com/klauspost/cpuid v1.3.1 // indirect
8685
github.com/kr/pretty v0.2.1 // indirect
87-
github.com/kr/text v0.2.0 // indirect
8886
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
8987
github.com/minio/md5-simd v1.1.0 // indirect
9088
github.com/minio/minio-go/v7 v7.0.26 // indirect
9189
github.com/minio/sha256-simd v0.1.1 // indirect
9290
github.com/mitchellh/go-homedir v1.1.0 // indirect
9391
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
9492
github.com/modern-go/reflect2 v1.0.2 // indirect
95-
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
9693
github.com/opencontainers/go-digest v1.0.0 // indirect
9794
github.com/opencontainers/image-spec v1.0.2 // indirect
9895
github.com/opentracing/opentracing-go v1.2.0 // indirect
@@ -114,7 +111,6 @@ require (
114111
google.golang.org/api v0.85.0 // indirect
115112
google.golang.org/appengine v1.6.7 // indirect
116113
google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad // indirect
117-
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect
118114
gopkg.in/ini.v1 v1.62.0 // indirect
119115
gopkg.in/segmentio/analytics-go.v3 v3.1.0 // indirect
120116
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)