Skip to content
This repository has been archived by the owner on Apr 3, 2024. It is now read-only.

FIx base config loading and add TLS integration test #141

Merged
merged 4 commits into from
Sep 23, 2022

Conversation

cretz
Copy link
Member

@cretz cretz commented Sep 23, 2022

What changed?

  • Set some base config defaults before loading config
  • Add integration test running CLI with mTLS

Why?

  • Config loading failed if you didn't set a couple of values in YAML which is unreasonable to ask of a Temporalite user
  • Python SDK needs mTLS support in its tests with Temporalite, so we added a test here to ensure it will continue to work

@cretz
Copy link
Member Author

cretz commented Sep 23, 2022

Note, this seems to add ~15s to Windows tests due to costs of go run compiling so many things (of course if these integration tests are reused, we could share a built binary, so it's a one-time cost).

(I am actively working on fixing the nix child process closing issue)

EDIT: All statements above no longer apply

cmd/temporalite/main_integ_test.go Outdated Show resolved Hide resolved
cmd/temporalite/main_integ_test.go Outdated Show resolved Hide resolved
return fmt.Errorf("wait failed: %w", err)
}
return nil
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it might be possible to simplify some of the test setup/teardown by using the CLI as a library. Right now this doesn't make me want to write more of these style tests 😓

Eg.

ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()

go func() {
	if err := buildCLI().RunContext(ctx, []string{"start", "--ephemeral", "--config", "."}); err != nil {
		t.Fatal(err)
	}
}()

// Run some tests
// ...

If we dropped that test into the tls example directory, I think it would work without any runtime shenanigans.

Copy link
Member Author

@cretz cretz Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 WIll try (of course shouldn't call Fatal from other goroutines)

Copy link
Member Author

@cretz cretz Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we dropped that test into the tls example directory

Getting:

import "github.com/temporalio/temporalite/cmd/temporalite" is a program, not an importable package

Just gonna leave test in cmd dir for now. May not be worth abstracting buildCLI to another package yet

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'd be up for moving the CLI to an internal package eventually. I guess we should be able to use a relative path to get to the tls example config in the mean time.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately I will be making a dynamic YAML because it is unreasonable for me to set the working directory of tests and use relative paths to the certs inside my config. Oh well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done using temp dir and templated config. Probably fine for now, will want a more robust harness w/ helpers if we make more of these.

cmd/temporalite/mtls_test.go Show resolved Hide resolved
Comment on lines +114 to +119
for i := 0; i < 50; i++ {
if c, err = client.Dial(options); err == nil {
break
}
time.Sleep(100 * time.Millisecond)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just double checking, is there an internal timeout/retry mechanism in the Go SDK we could rely on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not for dialing any more than net.Dial. We fail eagerly. There is a lazy client, but just does the same thing before the first high-level call is made.

@jlegrone
Copy link
Collaborator

lgtm, please feel free to dismiss remaining questions if they're not actionable.

@cretz cretz merged commit 9a56995 into temporalio:main Sep 23, 2022
@cretz cretz deleted the config-tls branch September 23, 2022 17:32
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants