Skip to content

Commit 5405e95

Browse files
committed
Enable CI test
1 parent afd7c72 commit 5405e95

File tree

5 files changed

+21
-15
lines changed

5 files changed

+21
-15
lines changed

‎.github/workflows/test.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,11 @@ jobs:
3737
- name: Lint
3838
run: golint ./...
3939
- name: Test
40+
env:
41+
S3RPC_CLIENT_QUEUE: https://sqs.eu-north-1.amazonaws.com/656975317043/s3fptest_client
42+
S3RPC_SERVER_QUEUE: https://sqs.eu-north-1.amazonaws.com/656975317043/s3fptest_server
43+
S3RPC_CLIENT_ACCESS_KEY_ID: AKIAZR5WHZAZ6KZKRKWG
44+
S3RPC_CLIENT_SECRET_ACCESS_KEY: ${{ secrets.S3RPC_CLIENT_SECRET_ACCESS_KEY }}
45+
S3RPC_SERVER_ACCESS_KEY_ID: AKIAZR5WHZAZT55IVJWN
46+
S3RPC_SERVER_SECRET_ACCESS_KEY: ${{ secrets.S3RPC_SERVER_SECRET_ACCESS_KEY }}
4047
run: go test -race ./...

‎client.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,15 @@ func NewClient(opts ClientOptions) (*Client, error) {
5959

6060
}
6161

62+
// Client is a client for executing operations on a server.
6263
type Client struct {
6364
timeout time.Duration
6465
*common
6566
}
6667

6768
// ExecuteFilename executes the given op on a server with filename as its input.
6869
// This will block until the response is received or the timeout is reached.
70+
// Note that Output.Filename should be considered temporary and will be removed on Close.
6971
func (c *Client) ExecuteFilename(ctx context.Context, op, filename string) (Output, error) {
7072
id := uuid.New().String()
7173
key := fmt.Sprintf("%s/%s/%s_%s", toServer, op, id, filepath.Base(filename))
@@ -147,6 +149,7 @@ func (c *Client) ExecuteFilename(ctx context.Context, op, filename string) (Outp
147149

148150
}
149151

152+
// Close removes the temporary directory.
150153
func (c *Client) Close() error {
151154
return os.RemoveAll(c.tempDir)
152155
}

‎common.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ type common struct {
4545
infof func(format string, args ...interface{})
4646
}
4747

48-
func (r *common) Receive(ctx context.Context) ([]message, error) {
49-
result, err := r.sqsClient.ReceiveMessage(ctx,
48+
func (c *common) Receive(ctx context.Context) ([]message, error) {
49+
result, err := c.sqsClient.ReceiveMessage(ctx,
5050
&sqs.ReceiveMessageInput{
51-
QueueUrl: aws.String(r.queue),
51+
QueueUrl: aws.String(c.queue),
5252
MaxNumberOfMessages: 5,
5353
VisibilityTimeout: visibilitySeconds,
5454
// Wait for 20 seconds for a message to arrive.

‎roundtrip_test.go‎

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ import (
1414
)
1515

1616
func TestProcessFile(t *testing.T) {
17-
if os.Getenv("CI") != "" {
18-
// TODO(bep)
19-
t.Skip("skipping test in CI")
20-
}
2117
c := qt.New(t)
2218

2319
infofc := func(format string, args ...interface{}) {
@@ -85,18 +81,18 @@ func TestProcessFile(t *testing.T) {
8581
c.Assert(err, qt.IsNil)
8682
c.Assert(server, qt.Not(qt.IsNil))
8783

88-
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
89-
defer cancel()
90-
9184
go func() {
92-
if err := server.ListenAndServe(ctx); err != nil {
85+
if err := server.ListenAndServe(); err != nil {
9386
panic(err)
9487
}
9588
}()
9689

9790
wd, err := os.Getwd()
9891
c.Assert(err, qt.IsNil)
9992

93+
ctx, cancel := context.WithTimeout(context.Background(), 120*time.Second)
94+
defer cancel()
95+
10096
g, ctx := errgroup.WithContext(ctx)
10197
g.Go(func() error {
10298
res, err := client.ExecuteFilename(ctx, "dosomething", filepath.Join(wd, "go.mod"))
@@ -129,7 +125,7 @@ func TestSetup(t *testing.T) {
129125
t.Skip("Skipping in CI")
130126
}
131127

132-
prov, err := NewProvisioner("s3fptest", defaultRegion)
128+
prov, err := NewProvisioner("s3fpdev", defaultRegion) // s3fptest is used on GitHub
133129
if err != nil {
134130
t.Fatal(err)
135131
}

‎server.go‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,9 @@ func (s *Server) Close() error {
8282
}
8383

8484
// ListenAndServe listens for messages and processes them.
85-
// It blocks until the context is canceled or the server is closed.
86-
func (s *Server) ListenAndServe(ctx context.Context) error {
87-
g, ctx := errgroup.WithContext(ctx)
85+
// It blocks until the server is closed.
86+
func (s *Server) ListenAndServe() error {
87+
g, ctx := errgroup.WithContext(context.Background())
8888
g.Go(func() error {
8989
for {
9090
select {

0 commit comments

Comments
 (0)